Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to assign a value to dexpr using if statement?

    Posted 06/09/20 06:37 PM
    I want to assign a value of either 0 or 1 to each value in unitLateness depending on if the completion time is greater than the due date. I'm not sure how the syntax should work as I am new to CPLEX.



    using CP;
    int numberOfJobs = ...;
    range jobIndices = 1..numberOfJobs;
    int p[jobIndices] = ...;
    int dueDate[jobIndices] = ...;
    dvar interval job[j in jobIndices] size p[j];
    dvar sequence machine in all (j in jobIndices) job[j];
    dexpr int completionTimes[j in jobIndices] = endOf(job[j]);
    dexpr int unitLateness[j in jobIndices]= if(completionTimes[j]>dueDate[j]) = 0 else =1;

    //data file
    numberOfJobs = 8;
    p=[ 8,2,3,6,3,5,6,2];
    dueDate=[ 8,11,14,15,17,19,21,21];

    ------------------------------
    Michael Morrissey
    ------------------------------

    #DecisionOptimization


  • 2.  RE: How to assign a value to dexpr using if statement?

    Posted 06/10/20 01:00 AM
    I think in this case you can directly use the truth value of the comparison:
    dexpr int unitLateness[j in jobIndices]= (completionTimes[j]>dueDate[j]);

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: How to assign a value to dexpr using if statement?

    Posted 06/10/20 05:21 AM
    Thank you!

    ------------------------------
    Michael Morrissey
    ------------------------------