Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  OPL Script Extracting value from tuple

    Posted 10/08/18 08:06 PM

    Originally posted by: AndyHam


    Dear IBM,
    I am trying to extract a value from tuple and use it to decide a SIZE of interval variable. But I have an error in the following code.
    dvar interval itvJob[a in A][b in B] size D.get(a.l, b.l).d;   //syntax error, unexpected '(', expecting ';'

    Can you please see if what I have done wrong?

    using CP;

    tuple t_D {key int f; key int t; int d; } 
    {t_D} D= { <10, 11, 6>, <10, 12, 4>, <11, 10, 2>, <11, 12, 2>, <12, 10, 3>, <12, 11, 7>};
     
    tuple t_A {
      key int id; 
      int l;
    } {t_A} A = { <1, 10>, <2, 11> };
     
    tuple t_B {
      key int id; 
      int l;
    } {t_B} B = { <1, 12>, <2, 13> };
     
    execute {
       writeln(D.get(10,12).d);
    dvar interval itvJob[a in A][b in B] size D.get(a.l, b.l).d;

    Thanks,
    Andy

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: OPL Script Extracting value from tuple

    Posted 10/09/18 06:49 AM

    Hi,

    you seem to mix modeling and scripting syntax.

    Can you turn

    dvar interval itvJob[a in A][b in B] size D.get(a.l, b.l).d;

    into

    dvar interval itvJob[a in A][b in B] size item(D,<a.l, b.l>).d;

    ?

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: OPL Script Extracting value from tuple

    Posted 10/09/18 08:22 AM

    Originally posted by: AndyHam


    It now works beautifully!
    Thanks for your patience ^^
    I am getting really close to understand OPL script ^^
    Thanks again!
    Andy


    #DecisionOptimization
    #OPLusingCPOptimizer