Decision Optimization

 View Only
  • 1.  2D matrix to tuple set conversion

    Posted Wed July 01, 2020 12:53 AM
    here in my data-
    num_shifts = 50; (declared in .dat code)

    following is a code block in .mod file-
    int num_shifts
     = ...;
    range shift_range = 1..num_shifts;

    tuple tDMInvIndex
    {
    int bom_elem_id;
    string component;
    }
    {tDMInvIndex} DMInvIndex={<BM.bom_elem_id,BM.component> | BM in BomMappings};

    int DMInvValue[DMI in DMInvIndex][shift in shift_range]=cumulFunctionValue(dm_inv[DMI],(shift*720));

    //This is the 2D matrix
    //Now, my goal is convert this 2D matrix into tuple set
    //following is what I have done-

    tuple tK
    {
    key int DMI;
    key int shift;
    int value;
    }
    {tK} K={<DMI, shift, DMInvValue[DMI][shift ]> | DMI in DMInvIndex, shift in shift_range}

    is this correct sir? but when I have done this, it is throwing an error...
    OR

    tuple tK
    {
    int value;
    }
    {tK} K={<DMInvValue[DMI][shift ]> | DMI in DMInvIndex, shift in shift_range}
    is this correct way?


    ------------------------------
    Sai Sampath Bethu
    ------------------------------

    #DecisionOptimization


  • 2.  RE: 2D matrix to tuple set conversion

    Posted Wed July 01, 2020 01:48 AM
    What is the error you get? Does the second variant also raise an error? One problem definitely is that the values in DMInvIndex are instances of tDMInvIndex while in your definition of tK you define the field DMI to be of type int. This field should have type tDMInvIndex, otherwise the types do not match.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: 2D matrix to tuple set conversion

    Posted Wed July 01, 2020 10:39 AM
    Edited by System Fri January 20, 2023 04:15 PM
    The first one is throwing python stopped working error(when I am running using doopl ). Second variant worked fine but the values are not matching before and after converting that 2D matrix into tuple set..
    So, what is the correct way to convert it to tuple set?


    ------------------------------
    Sai Sampath Bethu
    ------------------------------