Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Interactive Cplex solves a LP but solution cannot be found by Concert

    Posted 02/19/19 07:03 PM

    Originally posted by: DianaHuerta


    Dear all!

    I'm working on the creation of a heuristic that needs to obtain a feasible solution by solving the LP relaxation of a MILP. First, I create the model and then I solve it using Concert - Cplex 12.6. After 1 hour, the solution status is unkown. However, if I export the .sav file and then use the interactive cplex it can solve it using dual or barrier method. Even fixing the method to Barrier, the concert cannot solve it. I have tried  using 1 / more threads and it is not able to return a solution. Do you have an idea of what would be happening?

    You can find attached the logfile created by interactive cplex. Using concert, I only obtain an "unknown" solution after 1 hour of optimization (interactive cplex took 852 s to obtain the best solution).

     

    Thanks in advance!

     

    DH


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex interactive solve a LP but solution cannot be found by Concert

    Posted 02/19/19 08:06 PM

    There are many things that might explain this and we'll probably need more information to help. You didn't mention which API you're using. Are you using Java, C++, .NET? I'll assume Java below, but it should be very similar for the others.

    What happens if you try solving your .sav file using the LPex2.java program that is included when you install CPLEX?

    Is it possible that you might be exporting a slightly different model than the one being solved? That is, are you calling exportModel at the line just before calling solve?

    Are you using callbacks? If so, this might change the behavior. Have you set any non-default parameters in your program (try writing these out with the writeParam method at the same location where you call exportModel())? Can you share the engine log created when running your program (if it's convenient, you can write this to a file using the setOut method)?

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex interactive solve a LP but solution cannot be found by Concert

    Posted 02/20/19 08:06 PM

    Originally posted by: DianaHuerta


    Hi, Ryankersh!...

     

    I answer your questions:

     

    You didn't mention which API you're using. Are you using Java, C++, .NET?

    - I'm using Concert / C++ (now I'm using the 12.8 version as suggested by DanielJunglas) and Visual Studio 2017.

     

    What happens if you try solving your .sav file using the LPex2.java program that is included when you install CPLEX?

    - I have done 2 different tests.

    --- One is solving my model (.SAV) by using concert / interactive cplex and setting some parameters (TimLim 3600 s, 1 thread, Barrier alg, parallel mode - deterministic)

    --- The second test  is solving the same model with concert/interactive-cplex and setting only TimLim to 3600 s (the remaining ones keep their default values)

     

    In both cases, interactive cplex could solve the LP and concert+vs2017 couldn't.

     

    Is it possible that you might be exporting a slightly different model than the one being solved? That is, are you calling exportModel at the line just before calling solve?

    - I use .SAV files for the tests because, as far as I know, these files are more precise than the .LP files, I'm not sure if there is another way to avoid differences.  

    - Yes, I'm calling exportModel() just before solve(). You can see my implementation code of this part in SolveModel.txt (attached)

     

    Are you using callbacks? Have you set any non-default parameters in your program (try writing these out with the writeParam method at the same location where you call exportModel())?

    - No, I don't use callbacks. 

    - Yes, for one of my tests (in order to analyze this case), I'm considering some non-default parameters (see SolveModel.txt), but in both cases (concert/interactive) I set them in the same way.

     

    Can you share the engine log created when running your program (if it's convenient, you can write this to a file using the setOut method)?

    - Of course!. I copy the description from the reply I have done to DanielJunglas about a related comment (I will attached the same files, just in case).

     

    You can find 4 files attached:

    -- *defaultparam.log: Are the log files cplex(interactive)/pmed38(concert) obtained using all parameters with their corresponding default value (except for time - TimLim 3600 s)

    -- *barrier.log: Are the log files cplex(interactive)/pmed38(concert) obtained using ... TimLim 3600 s, Barrier algorithm, 1 thread, Parallelmode - deterministic.

     

    I hope it can help.

     

    Thank you!

     

    Diana.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex interactive solve a LP but solution cannot be found by Concert

    Posted 02/20/19 02:53 AM

    First thing I would try would be to switch from this very old 12.6 version to a more recent version, like 12.8 :-)

    In any case, can you also attach the log for the solve that is run from within Concert? How exactly do you create the LP relaxation in Concert?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex interactive solve a LP but solution cannot be found by Concert

    Posted 02/20/19 07:44 PM

    Originally posted by: DianaHuerta


    Hi, Daniel!... 

     

    I listed my answers according to your questions:

     

    First thing I would try would be to switch from this very old 12.6 version to a more recent version, like 12.8 :-)

    - Today I have made the upgrade to the new version and I have repeted the tests, it was the same case: the .SAV is solved by the interactive cplex but not by the concert c++ api

     

    In any case, can you also attach the log for the solve that is run from within Concert?

    You can find 4 files attached:

    -- *defaultparam.log: Are the log files cplex(interactive)/pmed38(concert) obtained using all parameters with their corresponding default value (except for time - TimLim 3600 s)

    -- *barrier.log: Are the log files cplex(interactive)/pmed38(concert) obtained using ... TimLim 3600 s, Barrier algorithm, 1 thread, Parallelmode - deterministic.

     

    How exactly do you create the LP relaxation in Concert?

    1.- Create the MILP formulation

    2.- As I need to solve (first) the LP relaxations of that MILP, I transform the binary variables to continuous by doing this:

     

        IloModel modelRelax(env);
        modelRelax.add(model); //model is the MILP

        modelRelax.add(IloConversion(env, y, ILOFLOAT));

     

    3.- I create a cplex object and solve the relations calling the function solveModel(...) ... this is part of the code:

     

        loCplex cplexRelax(modelRelax);    
        cplexRelax.extract(modelRelax);
        IloAlgorithm::Status iIloStatus = solveModel(cplexRelax, dMILPTime, dDummyUB, dTotalTime, dDummyStatus, -1,0); 

    * You can see how solveModel(...) is implemented in file SolveModel.txt

     

    4.- Finally, I make "End" to the objects:

        cplexRelax.end();
        modelRelax.end();

     

    I hope my explanation is clear enough. I do not  know what could be happening, I cannot see clearly what I'm doing wrong.

     

    Thanks in advance, Daniel!

     

    Diana.

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex interactive solve a LP but solution cannot be found by Concert

    Posted 02/21/19 02:09 AM

    Hello,
    I think you are mixing several things up here.

    If you look at the cplex-defaultparam.log then you can see these things:

    Parallel mode: deterministic, using up to 4 threads for concurrent optimization.
    ...
    Barrier solved model.

    So CPLEX uses 4 threads and concurrentopt. That means it runs Simplex and barrier algorithm concurrently and stops as the first of them finishes. For your model the barrier algorithm is the faster algorithm.

    Then, in the other log files you change parameters Threads and/or LPMethod. If you explicitly set Threads=1 then CPLEX will no longer use concurrentopt but will use dual simplex to solve your model (unless you also set LPMethod). If you set LPMethod=4 then CPLEX will not use concurrentopt or dual simplex to solve your model but will use the barrier algorithm (on 1 thread if you set Threads=1 and on 4 threads if you don't set the Threads parameter).

    In your logs, there are no two solves with the same parameter settings. I think what you have to do is to make sure you use the same parameter settings in Concert and in the interactive. Since you switched to 12.8 you can now see this output at the beginning of each solve (in both the interactive and Concert):

    CPXPARAM_TimeLimit                               3600
    CPXPARAM_Threads                                 1
    CPXPARAM_Parallel                                1

    This tells you exactly which parameters were set to which values for the solve. Can you try to use the exact same parameters for interactive and Concert and see if the problem persists? From your logs it seems you always want Threads=1 and LPMethod=4 since that is the fastest?


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex interactive solve a LP but solution cannot be found by Concert

    Posted 02/21/19 03:42 AM

    Originally posted by: DianaHuerta


    Hi, Daniel!,

     

    I have seen my mistake, one of the parameters that I use for the SaveModel function was not taking the correct value. In one of the many tests I have done I have changed that part and I did not realize that. 

    As you have said,  it is easier to know the information of the parameters used for each optimization (nice point!).  

    Thank you very much for your help, Daniel! (and RyanKersh). I hope I have not bothered a lot with my doubt whose answer was very obvious (although at that moment I could not see it).

     

    Best!

     

    Diana.


    #CPLEXOptimizers
    #DecisionOptimization