Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problem with IloCplex::MIPCallbackI::NodeData

    Posted 06/04/10 06:00 PM

    Originally posted by: bendinio


    Hi!

    I'm about to implement an algorithm using ILOBRANCHCALLBACK with passing
    NodeData through the search-tree. I defined my NodeData class as follows:

    class passNext : public IloCplex::MIPCallbackI::NodeData {
    public:
    IloInt level;
    IloIntArray sel_vars;
    IloIntArray sel_vals;

    passNext();

    passNext(IloInt lvl, IloIntArray vars, IloIntArray vals) {
    level = lvl + 1;
    sel_vars = vars;
    sel_vals = vals;}

    passNext(IloInt lvl, IloInt var, IloInt val) {
    level = lvl + 1;
    sel_vars.add(var);
    sel_vals.add(val);}

    ~passNext(){}; };

    I'm compiling under Microsoft Visual Studio 2008 (C++) and there occurs no
    error while compiling, though the execution fails on creating an object
    of passNext. Visual Studio redirects me to the osfinfo.c file.

    I did a lot of searching for real examples of NodeData being used to pass
    information to subnodes, but i can't find anything. So I would be glad if
    somebody could at least give his opinion or maybe the solution.

    Thanks for reading.

    bendinio
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Problem with IloCplex::MIPCallbackI::NodeData

    Posted 06/04/10 06:18 PM

    Originally posted by: bendinio


    just figured it out, forgot the IloEnv.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Problem with IloCplex::MIPCallbackI::NodeData

    Posted 06/05/10 06:37 AM

    Originally posted by: bendinio


    i'm sorry, there still remains a problem.

    i want to access the data passed in NodeData, this seems not so simply as you think.
    Here's the code:
    NodeData *nd = getNodeData();
    if( nd != 0 ) {
    passNext *node_data = dynamic_cast<passNext*> (nd);
    }

    It doesn't work since the cast is not welldefined. But are there any alternatives?

    Thanks in advance!
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Problem with IloCplex::MIPCallbackI::NodeData

    Posted 06/07/10 09:11 AM

    Originally posted by: SystemAdmin


    As far as I can see that is exactly what I would do.
    What is the exact problem you are facing? Does your code compile? If not, what is the error message? Does your code crash at run-time? If so, were does it crash?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Problem with IloCplex::MIPCallbackI::NodeData

    Posted 07/20/10 07:34 AM

    Originally posted by: SystemAdmin


    I have a similar problem: when compiling the code (written in Concert) with Visual Studio 2008, I get this compilation error:

    "error C2352: 'IloCplex::ControlCallbackI::getNodeData' : illegal call of non-static member function C:\ILOG\CPLEX121\include\ilcplex/ilocplexi.h(2015) : see declaration of 'IloCplex::ControlCallbackI::getNodeData'"
    My piece of code is

    NodeData *nd = IloCplex::ControlCallbackI::getNodeData();
    if( nd != 0 ) nodenumber *node_data = dynamic_cast<nodenumber*> (nd);

    and the nodenumber structure has been defined as follows:

    struct nodenumber : public IloCplex::MIPCallbackI::NodeData
    {
    IloInt nn;

    nodenumber() {nn=-1;}
    nodenumber(IloInt a) {nn=a;}
    };
    What should I do to correctly get the NodeData information I have already stored? Thanks.

    Sergio.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Problem with IloCplex::MIPCallbackI::NodeData

    Posted 07/20/10 07:59 AM

    Originally posted by: SystemAdmin


    You can invoke getNodeData() only from callback member functions (it is a non-static member function as correctly indicated by your compiler).
    So, for example in the main() function of your callback you can do:
    void MyCallback::main() {
       nodenumber *node_data = dynamic_cast<nodenumber *>(getNodeData());
    }
    

    This will return the node data for the node at which the callback is currently being invoked.
    Did you try to invoke getNodeData() from a non-member or a static member function?
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Problem with IloCplex::MIPCallbackI::NodeData

    Posted 07/20/10 10:05 AM

    Originally posted by: SystemAdmin


    After trying your suggestion, I've realized that I was using a MIPCallback instead of a CutCallback. Now it works. Thanks.

    Sergio.
    #CPLEXOptimizers
    #DecisionOptimization