Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Printing in CP Optimizer how a constraint is being evaluated

    Posted 08/06/22 09:06 AM
    Hello all

    I am wondering if there exists a way to print in console (and/or export to a text file) how CP Optimizer is evaluating a constraint for a particular scheduling instance. 

    Let's say we have the following constraint in our .mod file

    forall (j in Jobs)
    noOverlap(jobs[j]);

    If we previously defined in the .mod file: 

    int nbJobs = ...;
    range Jobs = 0..nbJobs-1;

    And in the .dat file we set: nbJobs = 3;

    Then, "printing" the constraint must show the following:

    noOverlap(jobs[0]);
    noOverlap(jobs[1]);
    noOverlap(jobs[2]);

    There exists a way to do that? (For someone who is familiar with AMPL, I am looking for something equivalent to display nameOfConstraint;)

    Thank you in advance
    Francisco Y.




    ------------------------------
    Francisco Yuraszeck
    Yuraszeck
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Printing in CP Optimizer how a constraint is being evaluated

    Posted 08/08/22 03:52 AM
    Edited by System Admin 01/20/23 04:32 PM
    Dear Francisco,

    Assuming "jobs[i]" is a sequence on which noOverlap applies, what you can do is print each sequence in the scripting block by writing:

    writeln(jobs[i])
    

    It will display the list of the intervals present in the sequence.
    You can iterate over a sequence in a scripting block with:

    var cur = jobs[i].first();
    var next;
    while(cur) {
        # write the interval name
        writeln('cur ', cur.name);
        next = s[m].next(cur);
        cur = next;
    }


    During scripting, you can also test for optional interval presence by accessing the 'present' property.
    Naturally, this property be always true for all optional intervals you'll find in the sequence iterated on it  in the scripting block block.
    Writing a sequence name is simply done with:

    write(jobs[i].name)


    I hope this helps,
    Cheers,





    ------------------------------
    Renaud Dumeur
    ------------------------------