Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  how to prune a node

    Posted 10/26/09 06:16 PM

    Originally posted by: SystemAdmin


    [shaon said:]

    Dear all,



    I use a cutcallback and branchcallback in my own B&C.  In cutcallback, I can check whehter I should prune a node.  If one node is identified for pruning, then in the branchcallback, I set nodecnt=0 (the 7th parameter in mybranchcallback) and set *useraction_p = CPX_CALLBACK_SET.

    Is my implementation is correct? Thanks.


    Shaon
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: how to prune a node

    Posted 10/27/09 07:18 PM

    Originally posted by: SystemAdmin


    [achterberg said:]

    As far as I can see in the source code, this should work. In order to be sure, you should set look at the log output. Set the MIP interval to 1 in order to see every node. Also, use depth first search as node selection rule and only 1 thread. Then look at your 'cplex.log' file. In the right most columns you see how the search tree look like.
    When you prune a node, display a message and verify that the next node is not a child of your node.

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: how to prune a node - with C API

    Posted 08/04/12 03:59 PM

    Originally posted by: frangio


    Sorry to re-ignite this old posting, but we have an issue. Similarly to another thread, we have an alternative LB computation (a Lagrangian one, as you may guess) that we can potentially use to fathom nodes. As suggested in the threads I could find here, we tried to implement this in a branchcallback.

    Now, the suggestion in the threads basically boils down to this: in the branchcallback, do

    if( my bound is > than the incumbent value ) {
    nodecnt = 0;
    *useraction_p = CPX_CALLBACK_SET;
    }
    else
    *useraction_p = CPX_CALLBACK_DEFAULT;

    Unfortunately, this does not work for us (at least on Cplex 12.4): we got an Error 1006 when the branchcallback returns, which we don't know how to interpret.

    Yet, at least one thing is clear: setting

    nodecnt = 0;

    makes no sense at all, since this is a change to a local variable that is not "seen" outside. Is the idea instead that we should call

    int CPXbranchcallbackbranchbds( CPXCENVptr env , void *cbdata , int wherefrom ,
    double nodeest , int cnt , const int * indices ,
    const char *lu , const int *bd , void *userhandle ,
    int *seqnum_p )

    within our branchcallback with cnt = 0? Is it because we don't do that that we get the error 1006?

    Thanks in advance

    Antonio Frangioni
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: how to prune a node - with C API

    Posted 08/10/12 08:08 PM

    Originally posted by: SystemAdmin


    I haven't used the C API in eons, so don't take the following as gospel, but ...

    The nodecnt argument is CPLEX telling you how many children it plans to create (if you let it). So you are correct that there is no utility in setting the value of nodecnt within the callback. Specifying action CPX_CALLBACK_SET (and then never calling CPXbranchcallbackbranchbds, thus creating no children and effectively fathoming the node) when your bound says to fathom and action CPX_CALLBACK_DEFAULT (letting CPLEX branch as usual) when your bound says not to fathom looks correct to me. I don't know if it's necessary to call CPXbranchcallbackbranchbds with cnt = 0, but it seems a bit unlikely. (Should be easy enough for you to test, though.)

    Is your bound computation done within the callback? If so, are you sure it is innocent of creating problems? (If you simplify the callback so that "my bound" is (essentially) first -infinity, then +infinity, forcing first one branch of the if-else and then the other without doing anything else, do you still get the 1006 error?

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: how to prune a node - with C API

    Posted 08/11/12 12:48 PM

    Originally posted by: frangio


    Dear Paul,

    > I don't know if it's necessary to call CPXbranchcallbackbranchbds with cnt = 0, but it seems a bit unlikely.
    > (Should be easy enough for you to test, though.)

    Yes, we tested, and actually it's not necessary: rather it is wrong. To my understanding, doing so causes one son node to be created which is identical to the father, thus looping Cplex.

    > Is your bound computation done within the callback? If so, are you sure it is innocent of creating problems?
    > (If you > simplify the callback so that "my bound" is (essentially) first -infinity, then +infinity, forcing
    > first one branch of the if-else and then the other without doing anything else, do you still get the 1006 error?

    I made some further tests, and it looks you're right: it was probably our fault (though I've not identified the exact culprit yet). So currently we have a code which does (more or less)

    if( my_bound >= cutoff_value * ( 1 - eps ) ) {
    *useraction_p = CPX_CALLBACK_SET;
    return( 0 );
    }

    and it seems to work fine: no Error 1006. Thank you.

    Regards

    Antonio
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: how to prune a node - with C API

    Posted 08/15/12 05:19 AM

    Originally posted by: SystemAdmin


    The error 1006 is CPXERR_CALLBACK. This is returned, for example, when you query certain data from the model that is not available from inside a callback. It is also the error code that CPLEX would produce if your callback method exits with a non-zero return code, or if useraction is neither CPX_CALLBACK_FAIL, CPX_CALLBACK_SET, nor CPX_CALLBACK_DEFAULT.

    Tobias
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: how to prune a node - with C API

    Posted 09/19/12 04:04 AM

    Originally posted by: SystemAdmin


    The way to prune a node is to set useraction_p to CPX_CALLBACK_SET and do nothing else, in particular do not call any of the CPXbranchcallbackbranch... methods.
    So the 1006 error code must be coming from somewhere else. What is the return value of your callback? Does it return 0 or something else?
    Is your callback invoked at all? Do you try to make any kind of modifications to the model being solved within your callback?
    #CPLEXOptimizers
    #DecisionOptimization