Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex.solve() not giving correct result

    Posted 05/05/12 07:55 AM

    Originally posted by: Inspiredlallu


    Heylo,

    I am reading linear equations from two files in java. Merging them into one IloCplex object. Then without exporting the model, give it to cplex to solve. That is, the entire cplex model is in memory object and has not been written to file before solving.
    When I give this object to cplex to solve using cplex.solve(), it gives the result as 'optimal'.

    But when I export the model from the cplex object to an lp file, then import it back to the same cplex object and call cplex.solve(), the result comes as 'infeasible'.

    If I check my result by not using java apl's and directly test them in cplex solver, I get the result as infeasible. So, this means that the result given by java api's after exporting the model and then importing it back is correct.

    Can someone tell me the reason why the exporting of model and then importing it back gives the correct result? And is there any way in which without the export & import also, the cplex gives correct result? I do not want to read and write files as it will take time and I do not want my application to take more time.

    This is very urgent and any help would be appreciated.

    Thanks and Regards,
    Neha Bhatia
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex.solve() not giving correct result

    Posted 05/05/12 04:09 PM

    Originally posted by: Laci Ladanyi


    The first step to track this down is to use a sav file instead of an LP file. The sav file is a binary representation of the problem and preserves the exact precision while the LP file prints only so many digits and may lose precision. If you experience the same issue with a sav file then post your sav file (or email it to ladanyi at us.ibm.com) and we can take a look at it.

    --Laci
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex.solve() not giving correct result

    Posted 05/06/12 04:42 AM

    Originally posted by: Inspiredlallu


    Hi,

    Thanks for the reply. I tried saving the files in .sav format and then importing it back, the problem still exists. This time the solution is completely the opposite of the expected output.

    When I export my file in .lp format it attaches '_' to every numeral. Maybe the problem is because of that because when i remove the underscores and run it in cplex directly, it gives the desired output.

    Although my main problem still exists. I do not want to export/import the files and want to directly give it to cplex.solve() to solve. But am not getting the desired results.

    PFA the sample lp file generated by the program.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex.solve() not giving correct result

    Posted 05/06/12 05:29 AM

    Originally posted by: Inspiredlallu


    PFA The correct LP file
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex.solve() not giving correct result

    Posted 05/10/12 03:17 PM

    Originally posted by: SystemAdmin


    As Paul suggested there is something very wrong with the way you create your model. The constraints in your LP file all look like this:
    IloC0:  - _1.0w - _0.0x - _0.0y - _0.0z <= -96
    

    This means that you created a variable with name "_1.0w" or "1.0w" (and so on). Most probably not what you intended to do. I guess you wanted to create variables w, x, y, z with coefficients -1, 0, 0, 0 in the above constraint?
    In Java you can do
    System.out.println(cplex);
    

    which will print a description of the model to the screen. Does this model look as expected? Maybe also loop through your variables and print out their names to see whether they have weird names like "1.0w".
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex.solve() not giving correct result

    Posted 05/11/12 01:25 AM

    Originally posted by: Inspiredlallu


    Daniel you are absolutely right. That was exactly that was happening.

    I changed the way the model was being created and the lp file generated sorted out itself.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex.solve() not giving correct result

    Posted 05/10/12 11:24 AM

    Originally posted by: SystemAdmin


    I think your Java code to convert the imported equations to a CPLEX model is probably wrong. I assume the equations are read as strings. Do you parse them to separate coefficients from variables?

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization