Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  ilog.cplex.IloCplex$MultipleUseException

    Posted 05/11/12 02:10 AM

    Originally posted by: Inspiredlallu


    Hello,

    I am trying to extract linear inequations from a cplex object and put them in another cplex object. I can see that the pRange extracted below is not null.

    In the following code it prints till "matrix not null". Then it gives "ilog.cplex.IloCplex$MultipleUseException" in line http://resultMatrix.addRows(pRange). What possibly could be the cause of the exception?

    IloLPMatrix pMatrix = (IloLPMatrix)pCplex.LPMatrixIterator().next();
    IloRange[] pRange = pMatrix.getRanges();

    IloLPMatrix resultMatrix = resultCplex.addLPMatrix();

    if(pRange.length!=0)
    {
    if(pRange!=null)
    {
    System.out.println("range added");
    if(resultMatrix!=null)
    {
    System.out.println("matrix not null");
    resultMatrix.addRows(pRange);
    }
    else
    System.out.println("oops");
    }

    }

    Thanks and Regards,
    Neha Bhatia
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: ilog.cplex.IloCplex$MultipleUseException

    Posted 05/11/12 02:29 AM

    Originally posted by: SystemAdmin


    If you want to have an IloRange in more than one model then you have to proceed as described here. You have to use an IloCopyManager and explicitly create a copy of each range. The copied ranges can then safely be added to the second IloCplex instance.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: ilog.cplex.IloCplex$MultipleUseException

    Posted 05/11/12 03:09 AM

    Originally posted by: Inspiredlallu


    Hi,

    Thanks for the post. It was very useful.

    But there is again a problem.

    I have to add constraints in the resultCplex object from two different cplex objects. If I exactly use the below lines, then the constraints of the name also remain the same. And hence, two constraints get same constraint name. (As the name of constraints in the two objects is same)

    IloRange temp = (IloRange)lp.getRange(r).makeCopy(cm);
    cplex.add(temp);

    I tried changing the name of the constraints by adding the constraints as below:

    IloRange temp = (IloRange)qMatrix.getRange(r).makeCopy(qCM);
    resultCplex.addRange(temp.getLB(), temp.getExpr(),temp.getUB(),"IloC"+count);

    Hence, each constraint name gets different constraint name.

    But now the problem is that the resultCplex object created considers the repeated variables, w, x, y, z as different variables. As in each occurence of w is treated as a different variable.

    Any idea on how to resolve this.

    Regards,
    Neha
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: ilog.cplex.IloCplex$MultipleUseException

    Posted 05/16/12 04:40 AM

    Originally posted by: SystemAdmin


    CPLEX does not merge variables with the same name. Names are used mainly for debugging. You can have different variables with the same name (and that is almost certainly going to cause trouble sooner or later).
    I think the answer I posted here should give you an idea how to solve the problem.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: ilog.cplex.IloCplex$MultipleUseException

    Posted 05/17/12 07:31 AM

    Originally posted by: Inspiredlallu


    Thanks for the solution.

    It worked :)
    #CPLEXOptimizers
    #DecisionOptimization