如何在Barrier算法迭代后访问当前解决方案?

问题描述 投票:2回答:1

我希望在Barrier算法迭代后访问当前的QP解决方案。每次迭代后都会触发一个回调ContinuousCallbackI。我修改了回调代码示例:

static ILOBARRIERCALLBACK2(MyCallback, IloCplex, cplex, IloNumVarArray, x) {
    cout << "Iteration " << getNiterations() << ": ";

    if (isFeasible()) {
        cout << "Objective = " << getObjValue() << endl;
        //cout << "x[0] = " << (float)cplex.getValue(x[0]) << endl; 
        //CPLEX Error  1217: No solution exists.
    }
    else {
        cout << "Infeasibility measure = " << getInfeasibility() << endl;
    }
}

但是cplex没有解决方案(错误)。迭代后有没有办法访问当前的解决方案?

c++ callback cplex
1个回答
0
投票

无法访问当前的解决方案。

从回调内部,只应调用回调类的成员函数。这些成员函数在https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.ide.help/refcppopl/html/classes/IloCplex_BarrierCallbackI.html中列出,并且没有一个允许查询当前解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.