Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Consecutive solves

    Posted Tue June 14, 2016 02:43 AM

    Originally posted by: ZoharFeldman


    Hi,

     

    I am running multiple cp solves sequentially one after another.

    Each one of the corresponding models has a very large part that is mutual to all models and a smaller part that is unique.

    Since extraction takes a significant time of the process (more than the solve time), I'd hope I could extract the base model (that is mutual to all) once and then just add and remove constraints to the model in each solve.

    I understand that such additions\removals entail a full extraction of the model, so it doesn't save me anything, right?

    Is it possible to tell the solver not to perform a full extraction of the model when adding a new constraint?

     

    Thanks,

    Zohar


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Consecutive solves

    Posted Tue June 14, 2016 03:47 AM

    Hi,

    you may change an already extracted model and then you do not need to extract again when you change the model.

    Let me give you an example in OPL since very easy to read but you can do the same with C++:

    using CP;

    dvar int+ Gas;
    dvar int+ Chloride;


    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
      ctMaxTotal2:    
        3 * Gas + 4 * Chloride <= 180;
      ctMaxChloride:  
        Chloride <= 40;
       ctEmpty:
         Gas<=infinity;
    }
     
     main
     {
       thisOplModel.generate();
       cp.solve();
       writeln(thisOplModel.Gas," ",thisOplModel.Chloride);
       thisOplModel.ctEmpty.UB=5;
       thisOplModel.ctEmpty.setCoef(thisOplModel.Gas,-1);
       thisOplModel.ctEmpty.setCoef(thisOplModel.Chloride,1);
       cp.solve();
       writeln(thisOplModel.Gas," ",thisOplModel.Chloride);
       
     }  

    Here I modify a new constraint ctEmpty without extracting. You can do the same in C++

    regards

     


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Consecutive solves

    Posted Tue June 14, 2016 04:00 AM

    Originally posted by: ZoharFeldman


    Perhaps this is a slightly different case (modifying an existing constraint opposed to adding constraint)?

    According to a previous correspondence with GGR: "The engine is fully recreated when constraint are added or removed in the model."

    Doesn't it mean that when I add or remove constraints in the model, the extraction process is invoked?

     

    Thanks,

    Zohar


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: Consecutive solves

    Posted Tue June 14, 2016 04:13 AM

    Hi,

    indeed but here I do not add or remove a constraint, I change some coefficients.

    This is why this is incremental. And does not lead to extraction again.

    ==> In fact, this is no longer true, extraction will happen again

    Unlike

    dvar int+ Gas;
    dvar int+ Chloride;


    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
      ctMaxTotal2:    
        3 * Gas + 4 * Chloride <= 180;
      ctMaxChloride:  
        Chloride <= 40;
       ctEmpty:
         Gas<=infinity;
    }
     
     main
     {
       thisOplModel.generate();
       cplex.solve();
       writeln(thisOplModel.Gas," ",thisOplModel.Chloride);
       thisOplModel.ctEmpty.UB=5;
       thisOplModel.ctEmpty.setCoef(thisOplModel.Gas,-1);
       thisOplModel.ctEmpty.setCoef(thisOplModel.Chloride,1);
       cplex.solve();
       writeln(thisOplModel.Gas," ",thisOplModel.Chloride);
       
     }  

    where only one extraction

    regards


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: Consecutive solves

    Posted Tue June 14, 2016 06:26 AM

    Originally posted by: ZoharFeldman


    Makes sense.

    So, returning now to my original question, is it possible to add a new constraint to the model without reactivate the extraction process again?

     

    Thanks,

    Zohar


    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: Consecutive solves

    Posted Tue June 14, 2016 09:34 AM

    Originally posted by: PhilippeLaborie


    The short answer is "no", if you add a new constraint to the model, then the next solve will re-extract.
    Still, depending of your exact context and in particular if you are coding your own search with IlcGoals, there are two things that you can think of:
    1- If you can have an idea in advance of the type (and number) of constraints you will add in your model in the future solve, you can add these constraints in the initial model, probably with additional variables to "parameterize" these constraints. For example if at some point you add xi<=K, you can plan in advance this constraint by adding a place-holder constraint xi<=y in the model with y initially unconstrained and, before your search goal, execute a goal that fixes y=K when you want to "add" the "xi<=K".
    2- You can also of course directly add these constraints (in Ilc) in a goal that would be executed before your own search goal. See the constraints available in http://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.cpo.help/refcppcpoptimizer/html/optim.cpoptimizer.extensions/group.html

     


    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: Consecutive solves

    Posted Tue June 14, 2016 10:08 AM

    Originally posted by: ZoharFeldman


    Thanks for your reply, Philippe.

     

    I have thought about something similar to option 1 (with use of constraint indicators that I set to true in the appropriate solve). However, I have no way of knowing all the constraints in advance.

    I am therefore left with option 2, which is also not very trivial. The problem is that I now have to transform all my IloConstraints to IlcConstraint. Since I have many constraints and they are created in many different places in my code, this is going to be a very exhaustive work. 

    I really wish there was some utility that transforms iloConstraint to IlcConstraint or have the option of extracting additional constraints without having all the model extracted again (even at the expense of performance as this is also happens when you add IlcConstraint to the solver)

     

    Thanks,

    Zohar


    #CPOptimizer
    #DecisionOptimization