Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  [Java] Modifying Model Constraints

    Posted 09/07/16 04:35 PM

    Originally posted by: midkiffj


    Hello,

    I am using Cplex 12.6.3 with Java and am looking to solve a model, modify multiple constraints, solve again, and repeat.

    I have many constraints similar to U*x_i - U <= z_i where I'll need to update the value of U in between solutions.

     

    At the current time I found that something along the following works:

    IloNumExpr constraint = cplex.numExpr()
    // .....
    // Creating constraint
    // .....
    IloRange[] constraints = new IloRange[10];
    constraints[0] = cplex.addLe(constraint, 0);
    

    I store the constraints in IloRange arrays and can then modify the expression and bounds on the ranges to edit the constraints. My question is: Is there a better, more efficient way to edit the constraints? Similar to some strategies I've been told exist in the c++ library, is there a way to modify the value of U without having to recreate the expressions in the IloRange arrays. Preferably a method that would lower the amount of work cplex would have to do between solutions to modify the problem.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: [Java] Modifying Model Constraints

    Posted 09/08/16 01:45 AM

    For this task it may be a good idea to use an IloLPMatrix to store the constraints (create via IloCplex.LPMatrix() or IloCplex.addLPMatrix()). The setNZ() method allows you to directly set the coefficient of a variable in a constraint. So you just need to store the non-zero indices of U and can then update very fast.

    In case you have to update multiple constraints you should use setNZs(), that should be faster than calling setNZ() in a loop.


    #CPLEXOptimizers
    #DecisionOptimization