fix bad bugs when constrained graphs are empty
parent
3b897950a6
commit
3c85e2d625
|
@ -184,10 +184,12 @@ pair<VectorValues, VectorValues> QPSolver::optimize() const {
|
|||
//Make an LP with any linear cost function. It doesn't matter for initialization.
|
||||
LP initProblem;
|
||||
// make an unrelated key for a random variable cost: max key + 1
|
||||
std::array<Key, 3> maxKeys = {*qp_.cost.keys().rbegin(),
|
||||
*qp_.equalities.keys().rbegin(),
|
||||
*qp_.inequalities.keys().rbegin()};
|
||||
Key newKey = *std::max_element(maxKeys.begin(), maxKeys.end()) + 1;
|
||||
Key newKey = *qp_.cost.keys().rbegin();
|
||||
if (!qp_.equalities.empty())
|
||||
newKey = std::max(newKey, *qp_.equalities.keys().rbegin());
|
||||
if (!qp_.inequalities.empty())
|
||||
newKey = std::max(newKey, *qp_.inequalities.keys().rbegin());
|
||||
++newKey;
|
||||
initProblem.cost = LinearCost(newKey, Vector::Ones(1));
|
||||
initProblem.equalities = qp_.equalities;
|
||||
initProblem.inequalities = qp_.inequalities;
|
||||
|
|
Loading…
Reference in New Issue