Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Empty value in a set

    Posted 08/22/19 12:08 PM

    Originally posted by: JCGar


    Hello,

    I have the following code and I would like to be able to evaluate a "null or empty" value in a position. I've been trying with the null function.

    {int} conjuPred [h in 1..2, i in 1..5] = [  [ {} {1} {2} {2} {4} ]
                                                                [ {} {1} {} {} {} ]  ] ;

    string phi = "Bad";
    execute{
         if (conjunPred[1][1] == null){
                  phi = "Good";
         }  
    }
    execute{
        writeln("Result: "+phi)
    }

     ¿ What would be the correct function to be able to enter to the "if" conditional ?

     

    Many thanks in advance.


    Best Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Empty value in a set

    Posted 08/23/19 12:23 AM

    Hi

    if (conjunPred[1][1].size==0)

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Empty value in a set

    Posted 08/23/19 05:56 AM

    Originally posted by: JCGar


    Hello,

    Thank you so much, it runs fine. But I tried using the code for a restriction and it doesn't work. I get an error: a type of tuple was expected, but an int was found.

    I attached a part of the code:

    int nbL = 2;

    range H = 1..nbL;

    tuple conjPrecedesor{
        int h;   // line
        int i;   // task
        int taskP;     // task predecesor  ;
    }

    {int} conjPred [h in H, i in 1..5] = [  [{} {1} {2} {2} {4}]
                                                           [{} {1} {} {} {}]  ];

    {conjPrecedesor} index_IPhi = { <h,i,taskP> | h in H, i in conjTask[h], taskP in conjPred[h][i] };

    subject to {

      forall (h in H, u in qh[h], i in conjTask[h] : conjPred[h][i].size == 0  )      
          ST[<h,u,i>] >= cth[h]* sum(c in qh[h])(c-1) * x[<h,u,c>];                                    
          
        forall (h in H, u in qh[h], i in conjTask[h]  : conjSuce[h][i].size == 0   )         
          ST[<h,u,i>] + item(conjuntoTiempos [h][i],0) <= cth[h] * sum(c in qh[h]) c * x[<h,u,c>];

    }

     

    Regards.

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Empty value in a set

    Posted 08/23/19 06:16 AM

    Hi

    in subject to you should not use JavaScript but opl so change

    conjPred[h][i].size == 0

    into

    card(conjPred[h][i])== 0

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Empty value in a set

    Posted 08/23/19 06:28 AM

    Originally posted by: JCGar


    Thank you very much, it works great.

    Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer