Decision Optimization

Decision Optimization

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

 View Only
  • 1.  IloCP::getValue - variable is not fixed

    Posted Fri May 06, 2016 09:48 AM

    Originally posted by: anahana


    Hello,

     

    I am trying to optimize a nonlinear program with one decision variable using IloCP, it works fine until I get this error message: IloCP::getValue - variable is not fixed, after the .solve() method returns true. This is strange because I assume that since the .solve() method returned a true, I should be able to obtain the value of the decision variable. I have seen one similar discussion about the same error on the forum, but it wasn't helpful. Any idea why I can't query for the value of a decision variable although the problem is reported as solved?

     

    Regards,


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 03:21 AM

    Originally posted by: PhilippeLaborie


    It is indeed strange. Could you export the model in .cpo format and attach it?

    Philippe

     


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 03:56 AM

    Originally posted by: anahana


    I'm using the C++ API under VS2012, and the code depends on the Boost statistics library. I can upload the source and header files to recreate the problem. Would that do? Or if you can think of a simpler way, please let me know. 

    Regards, 


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 04:52 AM

    Originally posted by: PhilippeLaborie


    If you are using a reasonably recent version (V12.6.x), you should be able to export your model into a .cpo file. For that, all you need to do is writing:

    cp.exportModel("myModel.cpo");

    Just before or after solving your model.

    Then you can attach the exported file. 


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 06:19 AM

    Originally posted by: anahana


    Thanks for the tip, I didn't know of it. I am using 12.6.3 by the way. 

    I exported the model just before calling the .solve() method and after it. See the attached files. They are identical for some reason. After the .solve() method returns true, I run the .getValue(x) method and get the exception.

    Thanks. 


    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 07:58 AM

    Originally posted by: PhilippeLaborie


    Thank you. It is what I suspected: your model uses some floating point decision variables. The automatic search of CP Optimizer does not fix this type of variables and, ore generally, floating point decision variables are not supported in CP Optimizer. If you want to use CP Optimizer you would have to discretize the domain of your floating point variables. Of course CP Optimizer supports floating point expressions like: 163.37 / IloSquare(17.19 * x) but the leaf nodes of the expressions (the decision variables) have to be integer.

    Philippe

     


    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 08:19 AM

    Originally posted by: anahana


    Thanks for your reply. Just to be sure, does the decision variable have to be an integer, or just discretized? I already tried to define x as an integer, but no feasible solutions could be found. I might have a chance of finding a solution if x is discretized to have values like 1.5, 1.6, 1.7, etc. Though I have to figure out how.

    One issue remains, CP can still find a solution even if x is a real variable. The files I sent before are for one run, here are the files for another run where a solution is found though x is a real number. The value of x is 128.604.

    Any thoughts?


    #CPOptimizer
    #DecisionOptimization


  • 8.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 08:41 AM

    Originally posted by: PhilippeLaborie


    The decision variables have to be integer. 

    So if you discretize it at regular values (as suggested by your example), you can model you floating point variable as y=0.1*x for instance.

    If you choose to discretize it at specific values you can store these values in an array VAL and use the so called "element" expressions: y=VAL[x] where integer variable x will represent the index of the floating point value.

    Concerning your remaining issue: it may be that the automatic search tries to do something with the floating point variables but this feature is not supported so you cannot rely on it.

    Philippe

     


    #CPOptimizer
    #DecisionOptimization


  • 9.  Re: IloCP::getValue - variable is not fixed

    Posted Mon May 09, 2016 08:47 AM

    Originally posted by: anahana


    Thank you. Much appreciated. 


    #CPOptimizer
    #DecisionOptimization