Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Ilocplex getvalue returns only first value

    Posted Wed March 30, 2016 01:42 PM

    Originally posted by: Mahesh Bakshi


    I wrote LP model using java cplex, I have a problem using IloCplex.getValue.

    IloCplex.getValue(z[0][0]) only returns first value of the solution.

    For example, in one instance, I have z[0][0] present three times in optimal LP solution. But I am only interested in z[0][0] with label "BS" (i.e 0.5) but it always return first available z[0][0] (i.e 0).

    Following is the output of iloCplex.writeSolution:

      <variable name="z-0-0" index="2112" status="LL" value="0" reducedCost="1"/>
      <variable name="z-0-0" index="2113" status="LL" value="0" reducedCost="1"/>
      <variable name="z-0-0" index="2114" status="BS" value="0.5" reducedCost="0"/>

    Is there any way to fetch IloCplex.getValue(z[0][0]) with label "BS" (i.e 0.5) ? (other than parsing complete writeSolution).

    Thank you for your help in advance.


    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Ilocplex getvalue returns only first value

    Posted Wed March 30, 2016 04:27 PM

    There is something very wrong with your code. You don't have variable z[0][0] three times in your model. Instead you have three different variables, all of which have name "z-0-0", so you have three different variables with the same name! The variable stored in z[0][0] apparently is the one with index 2112 or 2113. You need to figure out where in your code you stored the other variables and why you have three different variables with the same name. Once you figure that out it is probably easy to get at the values of the other variables.


    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Ilocplex getvalue returns only first value

    Posted Wed March 30, 2016 04:29 PM

    Originally posted by: Mahesh Bakshi


    Okay, Thank you, I will look as you suggested.

    Thank you, it is answer, I fixed bug and it is working fine.


    #DecisionOptimization
    #MathematicalProgramming-General