Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Modifying constraints ??

    Posted 12/30/13 10:35 AM

    Originally posted by: khan49


    Hello  All!

    I am using CP optimizer to get multiple solution of a constraint satisfaction problem. but due its size I am interested to solve sequentially i.e. get an a solution for first period and then fixed the binary variables that are assigned to the first period and then to move to the next period and so on. I know there are modifiers for fixing the extracted variables values , but I am interested to know that

     

    it it possible to modify a constraint as well

     

    like just modify the RHS of a an extracted constraint 

     

    or

    delete a constraint and add a new constraint with the desired RHS to engine directly  

     

    Kindly let me know if know you know something about it.

     

    Kind regards 


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Modifying constraints ??

    Posted 12/31/13 05:59 AM

    Hi,

    let me give you a small example:

     

    using CP;
     
     dvar int x in 0..4;
     
     maximize x;
     subject to
     {
      ct:x<=2;
     }  
     
     execute
     {
     writeln(x);
    }  
     
     main
     
     {
       thisOplModel.generate();
       cp.solve();
       writeln(thisOplModel.x);
       thisOplModel.ct.UB=3;
       cp.solve();
        writeln(thisOplModel.x);
       
     }   
     
     

     

    gives

     

    2

     

    and then

    3

    Regards


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Modifying constraints ??

    Posted 12/31/13 08:20 AM

    Originally posted by: khan49


    Hi Alex!

     

    Thanks for the reply , Basically I am writing my code using C++ concert technology . While doing different experiments I found out that  the value of variable can only be changed only one time using the engine variables corresponding to a decision variable.

    so then I thought there might be some way by using which I can remove a constraint and add a new constraint without extracting the whole model again and again by using the engine constraint .

     

    IloModel mod(env);
     
    // 1D Array of Variables
     
    IloNumVarArray B(env,Nblocks,0,1, ILOINT);
     
    IloExpr total_blocks(env);
     
    int i = 0;
     
    for(InputIterator current = start; current!= end ; current ++,i++){
     
    total_blocks += B[i]*BLOCK_TONNAGE;   
     
    }  
     
     
    mod.add(total_blocks <= upper_limmit);
    mod.add(total_blocks >= lower_limmit);
     
     
     
     
    // Slope Constraint
     
    for(int i = 0; i<Nblocks;i++){
     
        for(int j = 0; j < max_successor ; j++){
     
       if((Pre_deccessor_Matrix [i][j]!= -1)){
     
    mod.add(B[i] - B[j] <= 0);
     
    }
    }
     
    }
     
     
    IloCP cp(env);
    cp.extract(mod);
     
    cp.setParameter(IloCP::LogVerbosity, IloCP::Quiet);
     
    int sol = 0;
    int t = 1;
     
    cp.startNewSearch();
    while(cp.next() && sol < N_Solutions && t < 3){
     
    for(int i = 0; i<Nblocks; i++){
     
      if (cp.getValue(B[i])>0){
     
      initial_solutions[sol][i] = t; 
     
    (cp.getIntVar(B[i])).setValue(1);
     
          }
    }
     
     
    t++;
     
    }

     

    after getting each solution I want to modify the RHS of capacity constraints to accommodate the variables already fixed to 1.

     

    Kindly let me know if there is any way to change the value of a variable multiple time using the engine variable if not 

     

    is there any procedure to delete a constraint or modify it using IlcConstraint .

     

    Kind regards 


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: Modifying constraints ??

    Posted 12/31/13 10:52 AM

    Originally posted by: GGR


    Hi

    There is no way to remove a constraint in a model without re-extracting. The reason why is that after extraction and initial propagation the engine has taken account the to be removed constraints and must be totally reinitialized.

    Anyway in your case you could think in designing a model that iteratively solve a problem period by period.

    E.g for the first period having a model that work on affection on the first period or not and solve it. (basically there is two case for each affection). then the following period is a similar model with additional constraints that may come from the  affectation form the past period.

    That is a common practice in Mixed Integer Programming that you could exploit.

    Hope that helps

     

     


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: Modifying constraints ??

    Posted 01/07/14 07:45 AM

    Originally posted by: khan49


    Hi!

     

    Thanks for the reply, can you please explain the procedure you have proposed.

    with an example as I am unable to understand it.

     

    Kind regards 


    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: Modifying constraints ??

    Posted 01/08/14 05:13 AM

    Originally posted by: rdumeur


    Hi,

    I believe GGR suggests that you generate multiple models (one per period) and "stitch" them by adding in model of period t+1 constraints that assign variables of this model that were assigned by the previously solved model for period t.

    Am I right GGR?

     

    Cheers,


    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: Modifying constraints ??

    Posted 01/10/14 12:24 PM

    Originally posted by: GGR


    Hi

    You have got the point. Anyway, I suggest to relax the far away problem,  being correct by only considering the next open periods.For example, you may want to make optional the demand that are not urgent and iteratively repeat the process.

    Anyway my proposal is not necessarely a solution for the problem of Khan49. It is only the classical way big timetatble constraints are made tractable.

     

    Hope that helps


    #CPOptimizer
    #DecisionOptimization