Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Tuple component type not supported

  • 1.  Tuple component type not supported

    Posted 03/11/15 10:24 AM

    Originally posted by: mikeab


    Hey Guys,

    I have this tuple in my OPL code before main block:

     
    tuple Solution_Pool{
         key int sol_num;
         int sol_obj;
         int sol_y[DOT_F_S];
    }

    Then I have the following main block:

    if(cplex.populate()){
     
    var nsolns = cplex.solnPoolNsolns;
    writeln("Number of Solutions = ", nsolns);
    var z = new Array();
     
    for(var s = 0 ; s < nsolns ; s++){
    writeln(" --------- ");
    writeln("sol = ", s, "   objective= ", cplex.getObjValue(s));
    writeln("Iteration Solution= ", thisOplModel.Sol);
    thisOplModel.setPoolSolution(s);
    z[s] = thisOplModel.y ;
     
    writeln("z[s]=  ", z[s], " ", "s = ", s);
    thisOplModel.Sol.add(s, cplex.getObjValue(s), z[s]);
     
     
    }

    However I end up with an error like this when I run my main block:

    Description Resource Path Location Type
    Scripting runtime error: Tuple component type not supported., " [0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0]"
     

    Can you guys help me understanding whats going on here ?

    The variable in my main block aka thisOplModel.y is boolean decision variable in the MIP. I'm trying to store the damn thisOplModel.y in the int tuple array. Is this ok ? How can I resolve this issue ?

     

    Thanks

    Mike


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Ответ: Tuple component type not supported

    Posted 03/11/15 10:55 AM

    Hi

    let me share with you a small example to show you what you did wrong:

     range DOT_F_S = 1..2;
     
     tuple Solution_Pool{
         key int sol_num;
         int sol_obj;
         int sol_y[DOT_F_S];
    }

    int a2[1..2];

    {Solution_Pool} sp={};

    execute
    {
    var a=new Array();
    a[1]=2;
    a[2]=3;
    a2[1]=2;
    a2[2]=3;

    //sp.add(1,2,a);   // NOT WORKING
    sp.add(1,2,a2);
    }

    execute
    {
    writeln(sp);
    }
     

    You are mixing Array from scripts and arrays from OPL.

    If you use OPL arrays for the tuple OPL array, then it works

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer