Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Constraints satisfaction and exporting solution

    Posted Sat April 08, 2017 11:57 PM

    Originally posted by: ClemsonTiger


    Hi, I have 2 questions 

    First: I have a CP model that I solve and get a solution, I want to test if this solution satisfies a set of new constraints. That is get the number of "new" constraints violations for the given solution. Is there an easy way to do this?

    The second question is about exporting the solution to excel, I tried to do replicate the write to excel command given in the oil example but for some reason I get the OS not supported error while the Oil example works perfectly. I was wondering if this is because of the size of the decision variable (interval variable with optional intervals) because I can't even copy it from the solution window in the Cplex Optimization studio.

    I am using version 12.7

    Thanks

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Constraints satisfaction and exporting solution

    Posted Wed April 19, 2017 03:10 AM

    Hi,

    for the first question, let me give you a small example:

    int n=10;
    range r=0..n;

    dvar int x in r;

    maximize x;
    subject to
    {
    x<=5;
    }

    int isxlessthanv[v in r]=(x<=v);

    int nbViolations=sum(v in r) (1-isxlessthanv[v]);

    execute
    {
    writeln("nb violations =",nbViolations)
    }

    gives

    nb violations =5

    For the 2nd question, if you use SheetWrite you should first turn your intervals into an array or a tuple set

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Constraints satisfaction and exporting solution

    Posted Wed April 19, 2017 01:04 PM

    Originally posted by: ClemsonTiger


    Thanks for your reply,

    Is there an easy way to do the number of violations in a schedule using interval variables. For example I am using the noOverlap constrain and want to count how many violations of overlapping that may occur if I switch that constraint off. So I copy my solution SOL without the noOverlap constraint and then rerun the problem with the noOverlap constraints while enforcing the SOL using presenceOf (intVar[i][j])==1 and startOf(job[a])==starttimefromSOL

    but the problem is I get problem is infeasible at root! 

    is there an easy work around for the noOverlap constraint to count the number of violations (number of actual overlaps)?

    For the 2nd part I will look up how to convert it to an array, is there an easy way to export just the active optional intervals (that are present) to reduce the size of the array? 

    Thanks again.

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Constraints satisfaction and exporting solution

    Posted Wed April 19, 2017 03:51 PM

    Hi,

    what you could try is replace noOverlap by a forall that will propagate less but will let you allow relaxation with a smaller granularity

    Take the example in CPLEX_Studio127\opl\examples\opl\models\sched_mmasp

    you may read

    // No overlap on machines
       forall(m in Machines)
         noOverlap(tool[m]);

    that you could turn into

    forall(m in Machines) forall(ordered j1,j2 in Jobs)
        ctnoOverlap:overlapLength(opttask[j1][m],opttask[j2][m]) == 0;

    This way you could get some conflicts instead of a plain no solution if the model is not feasible.

    regards

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Constraints satisfaction and exporting solution

    Posted Wed April 19, 2017 03:56 PM

    Originally posted by: ClemsonTiger


    Thank you


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Constraints satisfaction and exporting solution

    Posted Thu April 20, 2017 08:03 AM

    Originally posted by: ClemsonTiger


    Hi,

    even after using the overlaplengh I still get "Problem found infeasible at the root node" while I don't get this error if I remove this constraint. 


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: Constraints satisfaction and exporting solution

    Posted Thu April 20, 2017 08:43 AM

    Hi,

    ok then you could try to turn

    forall(m in Machines) forall(ordered j1,j2 in Jobs)
        ctnoOverlap:overlapLength(opttask[j1][m],opttask[j2][m]) == 0;

    into

    objNoOverlap==sum(m in Machines) sum(ordered j1,j2 in Jobs)
        (overlapLength(opttask[j1][m],opttask[j2][m]) == 0);

    and try to maximize objNoOverlap that is a dvar int

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: Constraints satisfaction and exporting solution

    Posted Thu April 20, 2017 09:20 AM

    Originally posted by: ClemsonTiger


    Thanks it worked but this will give me the number of satisfied constraints not the violated ones right?

    For the number of violations is this correct?

    objNoOverlap==sum(m in Machines) sum(ordered j1,j2 in Jobs)
        (overlapLength(opttask[j1][m],opttask[j2][m]) != 0);

     minimize objNoOverlap


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: Constraints satisfaction and exporting solution

    Posted Thu April 20, 2017 09:23 AM

    Yes indeed. So you should maximize


    #DecisionOptimization
    #OPLusingCPOptimizer