Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

getDual failed for all constraint but solver success on IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 12.8.0.0

  • 1.  getDual failed for all constraint but solver success on IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 12.8.0.0

    Posted Fri November 04, 2022 09:09 AM

    Hi,

     

    I have a doubt:

     
    i hava a mip problem,i getDual failed for all constraint but solver success.

    Here's how I set my constraint:

    //con41
    IloExpr conCargo3(env);
    for (const auto &aircraft: aircraftList) {
    auto aircraftRoutes = yarMap[aircraft];
    for (const auto &item: aircraftRoutes) {
    if (item.first.lineSet.count(flightI) > 0 && item.first.lineSet.count(flightJ) > 0) {
    conCargo3 += aircraft.capacity * item.second;
    }
    }
    }
    //Records the index added to get the dual variable
    zetaCon[{flightI, flightJ}] = con.getSize();
    con.add(conCargo3 - otherIloVar >= 0);

    con is

    IloRangeArray con;


    Here's how I solved it

    vector<IloNumVar> solution() {
    vector<IloNumVar> solveVars;
    BOOST_LOG_TRIVIAL(info) << "solution...";
    solver.setParam(IloCplex::RootAlg,IloCplex::Dual);
    solver.setParam(IloCplex::Param::Emphasis::MIP, 4);
    solver.setParam(IloCplex::Param::MIP::Tolerances::MIPGap, 0);
    vector<string> notExtractedVars;
    if (solver.solve()) {
    for (int l = 0; l < vars.getSize(); ++l) {
    try {
    if (solver.getValue(vars[l]) == 1) {
    solveVars.emplace_back(vars[l]);
    cout << vars[l].getName() << ":" << solver.getValue(vars[l]) << endl;
    }
    } catch (IloAlgorithm::NotExtractedException) {
    notExtractedVars.emplace_back(vars[l].getName());
    }
    }
    }
    BOOST_LOG_TRIVIAL(error) << "notExtractedVars:" << notExtractedVars.size();
    BOOST_LOG_TRIVIAL(info) << solver.getCplexStatus();
    return solveVars;
    }



    Here's how I get the dual variable

    for (int l = 0; l < con.getSize(); ++l) {
    try {
    solver.getDual(con[l]);
    } catch (...) {
    BOOST_LOG_TRIVIAL(info) << con[l] << " " << "ERROR";
    }
    }

    but i getDual failed for all constraint but solver success.



    Thanks a lot!!!

     



    ------------------------------
    友 罗
    ------------------------------

    #DecisionOptimization


  • 2.  RE: getDual failed for all constraint but solver success on IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 12.8.0.0

    Posted Fri November 04, 2022 11:44 AM
    Dual solutions are not defined for integer and mixed integer programs. The getDual() method only works for linear programs and certain nonlinear problems with continuous variables. (The documentation mentions second order cone problems.)

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------