Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to implement CPLEX defined cuts only at Root Node

    Posted 06/27/17 06:36 AM

    Originally posted by: prasenjit mandal


    I am using CPLEX to implement a branch-and-cut procedure to solve an integer programming problem. 

     

    Now, I want to use CPLEX defined cuts only at the root node.

    I don't want to add those cuts (all those cuts provided by cplex only) beyond the root nodes (at the child nodes).

    How, can I implement that?


    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: How to implement CPLEX defined cuts only at Root Node

    Posted 06/28/17 05:18 AM

    Originally posted by: AndreaTramontani


    Dear Prasenjit,

    there are two possibilities to achieve what you ask for.


    1. If you use control callbacks, this can be obtained by using a usercut callback.
    Here's a quick description. For more details, please refer to the documentation of the usercut callback for C APIs (for other APIs the behavior is the same) at https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/refcallablelibrary/mipapi/setusercutcallbackfunc.html.

    If you install a usercut callback function of name (say) "mycutcallback()" with CPXXsetusercutcallbackfunc(), then your function mycutcallback() is called whenever CPLEX separate the cuts.
    The signature of your callback function must be

    int CPXPUBLIC mycutcallback (CPXCENVptr env, void *cbdata, int wherefrom, void *cbhandle, int *useraction_p);
    

    Whenever CPLEX decides to separate cuts at a given node in the tree (the root node or a child node), your function mycutcallback() is called.
    The first time it is invoked happens before CPLEX generate its own cuts.
    If you set *useraction_p = CPX_CALLBACK_ABORT_CUT_LOOP then CPLEX will abort the cutloop without generating its cuts.
    So, from the callback, you can query the depth of the node you are in, with CPXXgetcallbacknodeinfo() (see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/refcallablelibrary/mipapi/getcallbacknodeinfo.html).
    If the depth is 0, then you are at the root node and you can simply set

     *useraction_p = CPX_CALLBACK_DEFAULT;
    

    If the depth is greater than 0, then you are at a child node and you can simply set

    *useraction_p = CPX_CALLBACK_ABORT_CUT_LOOP;
    

     

    2. If you don't use control callbacks, then you can first solve the root node with default parameters, then disable all cuts and restart.
    With CPLEX interactive it would be something like this:

       read myprob.lp
       set mip limits nodes 1
       opt
       set mip cuts all -1
       set mip limits nodes DEFAULT_VALUE
       opt
    

    The same can be done easily with all CPLEX APIs.


    Best,
    Andrea


    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: How to implement CPLEX defined cuts only at Root Node

    Posted 06/28/17 06:14 PM

    Originally posted by: AndreaTramontani


    Dear Prasenjit,

    just an addendum to my previous reply.
    There might other ways to force CPLEX to generate cuts only at the root node.
    So, if you are not happy with any of the two options I described in my previous answer, please contact me directly by email at andrea"dot"tramontani"at"it"dot"ibm"dot"com.

    Best,

    Andrea


    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: How to implement CPLEX defined cuts only at Root Node

    Posted 06/29/17 02:30 AM

    Originally posted by: prasenjit mandal


    Hi Andrea,

    Thank you very much for your reply.

     

    1. Actually, I was talking about cplex generated cuts (like cover, clique, zero-half etc.) . These cuts are generated by CPLEX. 

    So I was talking about default cuts, not a user defnied cut ( I guess that usecutcallback is required to implement user-defined cuts).

     

    Then, how to control CPLEX for not executing it's default cuts at all the child nodes.

     

     

    2. I am using C++ for implementation purpose. 


    #DecisionOptimization
    #MathematicalProgramming-General


  • 5.  Re: How to implement CPLEX defined cuts only at Root Node

    Posted 06/29/17 09:42 AM

    Originally posted by: AndreaTramontani


    Hi again Prasenjit,


    > 1. Actually, I was talking about cplex generated cuts (like cover, clique, zero-half etc.).
    > These cuts are generated by CPLEX.
    > So I was talking about default cuts, not a user defnied cut
    > ( I guess that usecutcallback is required to implement user-defined cuts).

     

    The usercut callback is generally used to separate user defined cuts, that's true.
    However, it can also be used to force some actions, like aborting the cut loop.
    As I described in my previous reply, if you implement a usercut callback that does not separate any user defined cuts but:
    .. sets "*useraction_p = CPX_CALLBACK_DEFAULT;" when called at the root node (i.e., when the depth of the node is 0)
    .. sets "*useraction_p = CPX_CALLBACK_ABORT_CUT_LOOP;" when called at a child node (i.e., when the depth of the node is > 0)
    you will the obtain exactly what you ask for. Indeed, the usercut callback is called by CPLEX before it generate its own cuts, and if you set
    the useraction to CPX_CALLBACK_ABORT_CUT_LOOP CPLEX will skip the separation of its cuts.
    The behavior is described for Callable Library APIs but it is the very same for all other APIs, please refer to the documentation for your favorite API.

     

    > 2. I am using C++ for implementation purpose.

     

    Ok, but the behavior I described with the interactive optimizer can be easily achieved with any API.
    You just need to do those steps:
    A. Get the default value for the nodelimit (limit on number of branch-and-bound nodes) and store it somewhere.
       This is typically a huge number (infinite) that might however depend on the platform.
    B. Install a nodelimit of 1.
    C. Optimize (CPLEX will stop at the end of the root node due to the nodelimit of 1)
    D. Disable all CPLEX cuts.
    E. Install back the default nodelimit
    F. Optimize again. CPLEX will restart from the end of the root node, with all cuts produced at the root, but will no generate cuts anymore because now all the cuts are disabled.

     

    Best,
    Andrea

     


    #DecisionOptimization
    #MathematicalProgramming-General