Decision Optimization

Decision Optimization

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

 View Only
  • 1.  How to get the node LP in a C++ project?

    Posted Thu June 12, 2025 02:45 AM

    Dear all,

    I am using lazyconstraintcallback in a C++ project. I saw there was an easy way to output nodel LP by CPXgetcallbacknodelp in C project.

    Is there a similar way in a C++ project?

    Thanks,

    Shaon



    ------------------------------
    XY Li
    ------------------------------


  • 2.  RE: How to get the node LP in a C++ project?

    Posted Fri June 13, 2025 01:16 AM

    Hi,

    To Get Node LP in a C++ Project below given description: -

    If by "node LP" you mean the Linear Programming (LP) relaxation solution at a node in a branch-and-bound algorithm (e.g., using a solver like SCIP, CPLEX, or Gurobi), then:

    In short:

    Access the current node's LP solution by querying the solver's API during the branch-and-bound process.

    Typically, you retrieve variable values using functions like:

    SCIPgetVarSol() for SCIP

    CPXgetx() for CPLEX

    GRBget() or similar for Gurobi

    Example snippet in SCIP (C++) to get LP variable values at the current node:

    SCIP_VAR** vars = SCIPgetVars(scip);
    int nvars = SCIPgetNVars(scip);

    for (int i = 0; i < nvars; ++i) {
        SCIP_Real val = SCIPgetVarSol(scip, vars[i]);  // LP value at node
        // Use val as needed
    }



    ------------------------------
    Kamal Hinduja
    ------------------------------



  • 3.  RE: How to get the node LP in a C++ project?

    Posted Fri June 13, 2025 03:58 AM

    Thanks. I mean to get the node LP model at each node of the B&B tree.  



    ------------------------------
    XY Li
    ------------------------------



  • 4.  RE: How to get the node LP in a C++ project?

    Posted Fri June 13, 2025 04:19 AM

    There is unfortunately no way to access the node LP from a callback in C++, this is only available in C. In the C interface the cplex model is given with a matrix structure using environment and lp pointers and the callback returns a pointer to the same structure. In C++ the model is given as an instance of IloModel, and there is no translation of the node lp matrix structure to an IloModel instance to give access to it.