Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  keping the cuts while not being able toretrive them

    Posted 05/10/11 04:51 AM

    Originally posted by: SystemAdmin


    Hi everybody,

    Assume I solve a MIP and would like to terminate on the first node by setting NodeLim to 1.
    I expect that cplex solves an lp and also adds a lot of cuts to the model because cplex thinks it is going to solve a MIP but we terminate at the first node.

    Now I need to save the model and perhaps add my own cuts and again repeat the same process.

    The question is actually, which one the output formats indicated e.g. here URLhttp://web.njit.edu/all_topics/Prog_Lang_Docs/cplex80/doc/refman/html/appendixE.htmlURL
    is the best to do that?

    My guess is that PRE is the best one is that correct?

    any comment is appreciated.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: keping the cuts while not being able toretrive them

    Posted 05/10/11 05:11 AM

    Originally posted by: SystemAdmin


    If I understand you correctly, you want to
    1. solve the root node for a given model,
    2. write the model including CPLEX root node cuts to a file,
    3. modify the file (for example, adding your own cuts),
    4. goto 1.

    In this case, the PRE format is not what you want to use. First, this is a binary format (like SAV), and you cannot extend it with your own cuts.
    Second, it does not store what you want, namely the cuts added by CPLEX.

    In order to get the cuts (only possible in the C API!), you need to use a callback and get the nodelp with CPXgetcallbacknodelp(). The nodelp contains the cuts, and you can write it to disk. But note that the nodelp is specified in terms of the presolved model, and it does not contain the integrality conditions, i.e., it is a pure LP.

    In order to implement your procedure as above, you need to use a more complicated approach:
    1. Make sure that the MIPCBREDLP parameter is set to 1, and set the nodelimit to 1.
    2. Install a branch callback that
    (a) gets the MIP with CPXgetcallbacklp(env, cbdata, wherefrom, &lp),
    (b) queries the number of original rows: origrows = CPXgetnumrows(env, lp),
    (c) gets the nodelp with CPXgetcallbacknodelp(env, cbdata, wherefrom, &nodelp),
    (d) gets the number of rows in nodelp: cutrows = CPXgetnumrows(env, nodelp),
    (e) for i = origrows..cutrows-1:
    (i) Get the row from nodelp: CPXgetrows
    (ii) Uncrush the row to the original variable space: CPXuncrushform(). Note that this may fail, in which case you just skip the row.
    (iii) Store the uncrushed row somewhere.
    3. After CPXmipopt() comes back, add the rows stored in 2.(e)(iii) to your model. Then write the model to disk, for example in LP file format.
    Hope this helps..

    Tobias

    (b) does nothing on subsequent calls
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: keping the cuts while not being able toretrive them

    Posted 05/10/11 05:12 AM

    Originally posted by: SystemAdmin


    If I understand you correctly, you want to
    1. solve the root node for a given model,
    2. write the model including CPLEX root node cuts to a file,
    3. modify the file (for example, adding your own cuts),
    4. goto 1.

    In this case, the PRE format is not what you want to use. First, this is a binary format (like SAV), and you cannot extend it with your own cuts.
    Second, it does not store what you want, namely the cuts added by CPLEX.

    In order to get the cuts (only possible in the C API!), you need to use a callback and get the nodelp with CPXgetcallbacknodelp(). The nodelp contains the cuts, and you can write it to disk. But note that the nodelp is specified in terms of the presolved model, and it does not contain the integrality conditions, i.e., it is a pure LP.

    In order to implement your procedure as above, you need to use a more complicated approach:
    1. Make sure that the MIPCBREDLP parameter is set to 1, and set the nodelimit to 1.
    2. Install a branch callback that
    (a) gets the MIP with CPXgetcallbacklp(env, cbdata, wherefrom, &lp),
    (b) queries the number of original rows: origrows = CPXgetnumrows(env, lp),
    (c) gets the nodelp with CPXgetcallbacknodelp(env, cbdata, wherefrom, &nodelp),
    (d) gets the number of rows in nodelp: cutrows = CPXgetnumrows(env, nodelp),
    (e) for i = origrows..cutrows-1:
    (i) Get the row from nodelp: CPXgetrows
    (ii) Uncrush the row to the original variable space: CPXuncrushform(). Note that this may fail, in which case you just skip the row.
    (iii) Store the uncrushed row somewhere.
    3. After CPXmipopt() comes back, add the rows stored in 2.(e)(iii) to your model. Then write the model to disk, for example in LP file format.
    Hope this helps..

    Tobias

    (b) does nothing on subsequent calls
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: keping the cuts while not being able toretrive them

    Posted 05/10/11 05:28 AM

    Originally posted by: SystemAdmin


    Thanks Tobias for your comment.

    It is indeed very useful.

    If i modify your the earlier steps to this do I get any easier way?

    1. solve the root node for a given model,
    2. write the model including CPLEX root node cuts to a file,
    3. retrieve the solution (which is perhaps accessible even in C++ interface) and generate your own cuts by some other separation.
    4. load the file(import the problem) which contains the reduced model and all the cuts added by cplex.
    5. add your cut to the model as a new constraint
    6. goto 1.
    Because the idea is not actually to access to the cplex cuts but implementing a different cutting plane approach.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: keping the cuts while not being able toretrive them

    Posted 05/10/11 05:42 AM

    Originally posted by: SystemAdmin


    Well, the issue is how to implement step 2 in your algorithm. There is no other way than using callbacks and querying the nodelp to get the CPLEX root node cuts. There is no API method to write the model including CPLEX root node cuts to a file. Therefore, you have to extract the cuts manually via a callback. And I think that this is only possible in the C API.
    #CPLEXOptimizers
    #DecisionOptimization