Decision Optimization

 View Only
Expand all | Collapse all

Error when running configuration

  • 1.  Error when running configuration

    Posted Thu May 19, 2022 09:59 AM
    Hey! May you help me with it?

    data:

    month = {1,2,3,4,5,6};

    prodweeks = [3,4,5,4,5,4];

    demandweeks = [4,4,5,4,5,4];

    workdays = [16,23,21,22,23,20];

    workhours = [160,230,210,220,230,200];

    location = {1,2,3};

    FL = {FL1,FL2,FL3,FL4,FL5,FL6};

    type = {1,2};

    prodcosts = [[51.51,50.72,39.74],[40,43,1000000]];

    prodcap = [[0.1875616,0.4992653,0.0310645],[0.135673782,0.53,0]];

    holdcosts = [4.46,8];

    sscosts = [17.89,32];

    lsc = [469.54,519.55];

    transportcosts = [0.523689573,0.946969697];

    Demand = [[[2427,4343,3757],

    [2742,4489,4355],

    [3097,5739,5207],

    [2307,3968,3718],

    [2626,5029,4004],

    [1945,3796,3135]],[[537,1067,803],

    [522,1049,795],

    [643,1412,914],

    [498,1023,797],

    [650,1413,1042],

    [516,925,666]]];

    Distance = [[0,485,199],

    [485,0,427],

    [199,427,0]];

    RT = [[0.97,0.92],[0.96,0.92],[0,0.955]];

    OT = [[0.98,0.98],[0.98,0.98],[0,0.99]];

    InInv = [[2651,5690,3843],

    [1173,2651,1139]];

    SStype = [[[299,535,463],

    [338,553,536],

    [305,565,513],

    [284,489,458],

    [259,495,394],

    [240,467,386]],[[67,132,99],

    [65,130,98],

    [64,139,90],

    [62,126,99],

    [64,140,103],

    [64,114,82]]];

    OvertimeCosts = 350; 

    WorkHours = 10; 

    MaxOvertime = 6;


    mod:

    {int} month = ...;

    {int} location = ...;

    {int} type = ...;

    {string} FL = ...;

    int prodweeks [month] = ...; 

    int demandweeks [month]= ...;

    int workdays [month]= ...;

    int workhours [month]= ...;

    float prodcosts [type][location] = ...; 

    float prodcap [type][location] = ...; 

    float holdcosts [type] = ...;

    float sscosts [type] = ...;

    float lsc [type] = ...;

    float transportcosts [type] = ...; 

    float Demand [type][month][location] = ...; 

    float Distance [location][location] = ...; 

    float RT [location][type] = ...;

    float OT [location][type] = ...;

    float InInv [type][location] = ...; 

    float SStype [type][month][location] = ...; 

    int OvertimeCosts = ...; 

    int WorkHours = ...; 

    int MaxOvertime = ...;

    // decision variables

    dvar float+ RP[type][location][month];

    dvar float+ OP[type][location][month];

    dvar float+ LS[type][location][month];

    dvar float+ EI[type][location][month];

    dvar float+ SS[type][location][month];

    dvar float+ TU[type][location][location][month];

    dvar float+ OH[location][month];

     

    // objective function

    minimize sum(t in type, l in location, m in month) RP[t][l][m]*prodcosts[t][l]+

    sum(t in type, l in location, m in month) OP[t][l][m]*prodcosts[t][l]+

    sum(t in type, l in location, m in month)LS[t][l][m]*lsc[t]+

    sum(t in type, l in location, m in month)holdcosts[t]*EI[t][l][m]+

    sum(t in type, l in location, m in month)SS[t][l][m]*sscosts[t]+

    sum(t in type, l in location, l2 in location, m in month)transportcosts[t]*TU[t][l][l2][m]*Distance[l][l2]+

    sum(l in location, m in month)OH[l][m]*OvertimeCosts;

    // constraints

    subject to {

    forall (t in type, l in location, m in month) EI[t][l][m]+(-1)*EI[t][l][m-1]+RP[t][l][m]+OP[t][l][m]+

    sum (l2 in location) TU[t][l2][l][m]+(-1)*sum (l2 in location) TU[t][l][l2][m]+(-1)*Demand[t][l][m]+LS[t][l][m] == 0;

    forall (t in type, l in location) EI[t][l][0]+(-1)*InInv [t][l] == 0;

    forall (t in type, l in location, m in month) EI[t][l][m]+(-1)*SStype[t][l][m]+SS[t][l][m] >= 0;

    forall (t in type, l in location, m in month) prodcap[t][l]*RP[t][l][m]+(-1)*workhours[m]*RT[t][l] <= 0;

    forall (t in type, l in location, m in month) prodcap[t][l]*OP[t][l][m]+(-1)*workhours[m]*OT[t][l] <= 0;

    forall (l in location, m in month) OH[l][m]/workdays[m] <= 6;

    }

    ERRORS:

    CPLEX(default) kann den Ausdruck nicht extrahieren: forall(t in type, l in location, m in month) 0 <= EI[t][l][m]+SStype[t][l][m]*(-1)+SS[t][l][m]. 
    CPLEX(default) kann den Ausdruck nicht extrahieren: forall(t in type, l in location, m in month) EI[t][l][m]+EI[t][l][(m+(-1))]*(-1)+RP[t][l][m]+OP[t][l][m]+sum(l2 in location) TU[t][l2][l][m]+(sum(l2 in location) TU[t][l][l2][m])*(-1)+Demand[t][l][m]*(-1)+LS[t][l][m] == 0
    ...
    Der Index für den Array "RT(1)" liegt außerhalb des gültigen Bereichs: 3
    ...
    OPL kann den Ausdruck nicht extrahieren: 0 <= EI[t][l][m]+SStype[t][l][m]*(-1)+SS[t][l][m]

    Thanks in advance!



    ------------------------------
    Oleksandr Nazaruk
    ------------------------------



  • 2.  RE: Error when running configuration

    Posted Thu May 19, 2022 11:10 AM
    Hi,

    you have many out of bounds and mixed ranges.

    If you write

    subject to {
    
    forall (t in type, l in location, m in month:(m-1) in month) EI[t][l][m]+(-1)*EI[t][l][m-1]+RP[t][l][m]+OP[t][l][m]+
    
    sum (l2 in location) TU[t][l2][l][m]+(-1)*sum (l2 in location) TU[t][l][l2][m]+(-1)*Demand[t][m][l]+LS[t][l][m] == 0;
    
    //forall (t in type, l in location) EI[t][l][0]+(-1)*InInv [t][l] == 0;
    
    forall (t in type, l in location, m in month) EI[t][l][m]+(-1)*SStype[t][m][l]+SS[t][l][m] >= 0;
    
    forall (t in type, l in location, m in month) prodcap[t][l]*RP[t][l][m]+(-1)*workhours[m]*RT[l][t] <= 0;
    
    forall (t in type, l in location, m in month) prodcap[t][l]*OP[t][l][m]+(-1)*workhours[m]*OT[l][t] <= 0;
    
    forall (l in location, m in month) OH[l][m]/workdays[m] <= 6;
    
    }​

    all errors will go away



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------