Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Interrupted Solves and Cuts

    Posted 02/20/14 02:47 PM

    Originally posted by: VKV7_Anulark_Naber


    Here is my implementation. I create a cut pool before solve() and set the number of integer solution to one to interrupt solve(). When solve stops, I use the incumbent to add more cuts into the cut pool and repeat solve again. This way, I hope the cuts are stronger each time.

    Here are my questions:

    1.    1.   Now I got the problem that when I restart solve(), the LP best bound get worse than the previous solve. See the attached output for example. In the 12. Solve, the incumbent is 36.2268 and best bound is 36.7039, but the 13. Solve starts with best bound of 33.5714, which is worse. What happened here? Does Cplex remove all cuts that were added? If then, how do I retain them for the next solve or retain the best bound?

    2.    2.   After solve() stops, can I manipulate the user cut pool to delete all or some selected ones or to replace those with stronger ones, and how?

            3. How to add constraint(s) to the current IloOplModel,using concert?

    Thanks in advance.

     

    I would appreciate your help on these questions.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Interrupted Solves and Cuts

    Posted 02/24/14 01:41 AM
    1. The dual bound is not only driven by cuts. For any node other than the root node it is the minimum of all open nodes. I guess what happens in your case is the following: In the 12th solve CPLEX finds the feasible solution at node 476908. At this point CPLEX has already managed to prune a lot of nodes, hence the dual bound is larger than that of the initial LP relaxation (including cuts).
      Due to the solution limit you drop out of the optimization as expected.
      Now you add some user cuts. This is considered a modification of the model being optimized. However, when you change the model being optimized then the current search tree is no longer valid and CPLEX needs to start over from scratch (you can see that the 13th solve starts at the root node again). Since we resolve from scratch we have no nodes pruned and the dual bound is not as good as before.
      You could try the following trick to work around that: Instead of adding cuts directly via IloCplex::addUserCut() put all cuts into a table (that you implement yourself) and install a cut callback. The cut callback then checks if any cut in that table is violated and if so it injects it. When you return from a solve() you don't use IloCplex::addUserCut() either. Instead you add the cut to the table. This way CPLEX does not consider your model changed.
    2. There is function IloCplex::clearUserCuts() that deletes all user cuts. There is no API to deal with individual cuts. So the only thing you can do is to delete all user cuts and then add back the ones you want to keep.
    3. Please turn to the OPL Forum for this question. If nothing else helps you can also get the Concert model via IloCplex::getModel() and then operate on the concert model directly. However, I am not sure if that may cause trouble with OPL post processing or other OPL features.

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Interrupted Solves and Cuts

    Posted 08/15/14 05:21 AM

    Originally posted by: VKV7_Anulark_Naber


    Daniel,  

    1. is your answer 1 still valid for cplex 12.6.0.1, which you mentioned in another thread that cplex will not restart from scratch after an interrupted solve? You did not mention if cplex would throw cuts out or not. In my case, i also changed the bounds of one variable and some A-coefficients. I suppose in this case, cplex would consider this a new model and would in any case start from scratch. Am I right or wrong in that point? From the log file, it seemed like cplex started from scratch and threw out all cuts, which I do not prefer.

    If I choose not to change bounds and a-coefficients, would remaining cuts be kept into the next solve? 

    2. Before cplex exits the solve, can I ask cplex to write all user cuts remained into a file? The number of cuts is reported anyway when cplex exits.

    2. If I have to create a cut table myself according to your suggestion above, what could be the form of cuts stored? Example codes would be appreciated. I suppose the cut callback is run in a different environment than eplex, i cannot just simply use a IloConstraintArray.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Interrupted Solves and Cuts

    Posted 08/21/14 01:43 AM
    1. If you modify the integer feasible region (change bounds, for example) then CPLEX has no choice but to start from scratch. The current tree/solution may be invalid. So CPLEX throws out everything, including cuts. If you only change cuts then this by definition of cuts does not change the integer feasible region and CPLEX does not start from scratch. However, as I mentioned in that other thread, currently CPLEX does restart from scratch if you modify cuts. This is considered a bug but the bug is not yet fixed in 12.6.0.1.
    2. No way to do that. With the callablle library you could get the LP at the current node in a callback and extract the cuts from it (or write it to disk) but in the Concert API this is not possible.
    3. Just use containers from the STL instead of Ilo* containers. For example, when separating a cut I would create a std:.vector<IloNum> for the coefficients, std::vector<IloNumVarArray> for the variables, a flag for the sense and an IloNum for the right-hand side. if you put all this in a class then you can easily store all cuts in a std::list. It should also be easy to create an IloRange from the vectors, the flag and the right-hand side once you need to add the cut to an IloCplex instance.

    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Interrupted Solves and Cuts

    Posted 08/21/14 04:23 AM

    Originally posted by: VKV7_Anulark_Naber


    Thank you.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Interrupted Solves and Cuts

    Posted 09/30/14 01:56 PM

    Originally posted by: maiklb2005


    I have a clarifying question with respect to p. 1. If the integer feasible region is not modified and previously obtained cuts are not modified but kept "as is", then cuts are still valid.

    In my implementation, I add cuts by using

    cplex.importModel(model,"ProbWithCuts.lp", obj, var, rng); \\ ProbWithCuts.lp is an output file that contains CPLEX-generated cuts that are extracted by using admipex1.c

    model.remove(obj);
    model.add(rng);
    model.remove(var);

    I assume that rng is where constraints and cuts are.

    Then I add the objective function and declare constraints. The constraints are the same as those used in generation of cuts in "ProbWithCuts.lp."

    After extracting the model, and exporting the model, I can see the .lp file. The .lp file seems to contain all the original constraints and the cuts.

    However, it seems that constraints and cuts in rng are not really added to the model. Attached are two screenshots. "CutsAreGenerated.jpg" shows the optimization and it is clear the that lower bound is driven by the cuts only (you can see that there are not branching operations). After the optimization is finished, cuts are saved to "ProbWithCuts.lp."  "CutsAreAddedAndProblemIsSolved.jpg" shows the optimization with the cuts that are imported from "ProbWithCuts.lp." However, we can see that the initial lower bound is not the lower bound that was obtained by the cuts. It appears to me that model.add(rng) does not really add cuts to the formulation. 

    When I run a formulation that was output to an .lp file (it contains the original formulation + the cuts), the same situation occurs as shown in "CutsAreAddedAndProblemIsSolved.jpg." Based on this, I can also conclude that while cuts are added to the .lp file, the are ignored. 

    I use Cplex 12.5.1. Thank you.

    P.S. I also merged .lp files with the original formulation and with the cuts manually. I pasted the cuts from "ProbWithCuts.lp" and gave then a unique identifier starting with the letter "c." In doing so, I imposed the cuts as constraints. The result is a little better, but still not as expected. Please see the "CutsAreAddedManuallyAndProblemIsSolve.lp." On an unrelated note, is there a way to impose CPLEX-generated cuts as constraints and give them unique names automatically? Thank you.


    #CPLEXOptimizers
    #DecisionOptimization