Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

opl cplex defining array by tuples

  • 1.  opl cplex defining array by tuples

    Posted Thu June 21, 2018 06:30 PM

    Originally posted by: lennartDigital


    Hi, my problem is the following:

    External I get a set of tours (tuples), but I would like to define an array, with a tuple <day,id> as the index of the array.

    ////////////////////////////////

    tuple tours{...}

    {tour} allTours = ...;
    {idx} indexSet = { <t.day, t.id>| t in allTours};

    tour tourArray[indexSet] = [ t | t in allTours];       ///this is the line, that doesn't work

    /////////////////////////////

     

    Does anybody has an idea with what I could replace the fourth line?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: opl cplex defining array by tuples

    Posted Fri June 22, 2018 02:05 AM

    Hi,

    let me give you an example:

    tuple tours{
      int day;
      int id;
      string name;
     }
     
     tuple idx{
      int day;
      int id;
     
     }
     

    {tours} allTours = {<1,1,"A">,<1,2,"B">,<2,3,"C">};
    {idx} indexSet = { <t.day, t.id>| t in allTours};

    {tours} tourArray[i in indexSet] = { t | t in allTours : t.day==i.day && t.id==i.id};       

    execute
    {
    writeln(tourArray);
    }

    regards


    #CPLEXOptimizers
    #DecisionOptimization