Decision Optimization

 View Only
  • 1.  Retrieving the solution atcertain time during the execution

    Posted Thu November 18, 2021 09:05 AM
    Hello everyone,
    I coded my MIP model on c++ and calling the cplex to solve it. I need to test by limiting compuation time and see the results. In the very beginning step, we thought to check bestObjectiveValue (Best LB) and best UB at the end of 60s,300s. Instead of running the instances for 60s and 300s , I want to set the computation time to 300s and retrieve the Best LB and UB values found at 60s. Is it possible ? How can I do that ? ( The execution will nnot stop at 60s , it will go on non stop (if there is no optimal solution until that time)  until 300s)
    Thank you so much

    ------------------------------
    milena kafka
    ------------------------------


  • 2.  RE: Retrieving the solution atcertain time during the execution

    Posted Thu November 18, 2021 11:13 AM
    Call solve() with a time limit of 60s, retrieve the bounds, then call solve() again with a time limit of 240s. As long as you leave the advanced start switch (IloCplex::Param::Advance) at its default setting of 1, change only parameters (time limit in this case) and do not change the model, the second call to solve() will resume working with the partially completed search tree from the first call.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Retrieving the solution atcertain time during the execution

    Posted Wed November 24, 2021 08:52 AM
    Thank you so much Prof.Rubin, 
    Then , following your proposition, I can retrieve the first Relaxed solution as follows: 
    cplex.nodelimit=1
    cplex. cplex.getBestObjValue()

    Would not it be correct ? Thank you so much

    ------------------------------
    milena kafka
    ------------------------------



  • 4.  RE: Retrieving the solution atcertain time during the execution

    Posted Wed November 24, 2021 10:59 AM
    That should get you the objective value of the LP relaxation at the root node (after CPLEX has added any cuts it is going to add to the root).

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 5.  RE: Retrieving the solution atcertain time during the execution

    Posted Tue December 07, 2021 07:13 AM
    Hello Prof. Rubin, 
    Thank you so much for your response. Corcerning my first question, I tested an instance and I face a case which I can not explain. To see the bounds at the end of 180s, I firstly limit the time 180s and called cplex.solve(). Secondly, I limit the execution time with 60s and called cplex.solve() and limit the time 120s and called cplex.solve(). While trying the second version, as you suggested, I set the parameter as follows: cplex.setParam(IloCplex::Param::Advance, 1). However, in two cases, the lower bounds and upper bounds I obtain are different. I can not understand why it happens? I would be very happy if you can give me a hint. I send the log files of two versions called 180_direct where I directly limit the time as 180s and called 60s+120s where I implement second version. 
    Thank you so much  in advance

    ------------------------------
    milena kafka
    ------------------------------

    Attachment(s)

    txt
    180s-direct.txt   7 KB 1 version
    txt
    180s_twostep60+120.txt   8 KB 1 version


  • 6.  RE: Retrieving the solution atcertain time during the execution

    Posted Tue December 07, 2021 02:55 PM
    This is not entirely surprising, since CPLEX is inherently not very deterministic in its behavior. You can try setting the parallel mode switch (IloCplex::Param::Parallel) to 1 (deterministic), which will make it try to be a bit more deterministic in its use of threads. That's not guaranteed to help, though, for the following reason.

    Even with that switch set to deterministic, CPLEX makes some decisions based on random numbers. I'm not sure which ones, but I'm pretty sure that one example is breaking a tie in the choice of incoming basis variable during simplex pivots. There is a parameter (IloCplex::Param::RandomSeed) you can use to set a seed for its random number generator. If you do not set that, it uses the same default value at the start of each run. So in your first run it starts from the default seed value and generates random numbers as needed until the end of the run. In the second case, it starts the 60 second run with the default value, then reseeds the generator with the same default value when it starts the 120 second run. So the 120 second run is getting different random numbers than the last 120 seconds of the first run got, and there is nothing you can do about that (since you cannot know the correct seed value to use to make the 120 second run match what was going on in the 180 second run.

    The only way I can see to avoid this randomness is to use an information callback that checks the clock, records some information (once) after 60 seconds, and otherwise does nothing.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------