Merge remote-tracking branch 'origin/feature/LPSolver' into feature/LPSolver

release/4.3a0
= 2016-06-15 12:00:44 -04:00
commit 1102a0e425
1 changed files with 7 additions and 5 deletions

View File

@ -183,11 +183,13 @@ pair<VectorValues, VectorValues> QPSolver::optimize(
pair<VectorValues, VectorValues> QPSolver::optimize() const { pair<VectorValues, VectorValues> QPSolver::optimize() const {
//Make an LP with any linear cost function. It doesn't matter for initialization. //Make an LP with any linear cost function. It doesn't matter for initialization.
LP initProblem; LP initProblem;
Key newKey = 0; // make an unrelated key for a random variable cost // make an unrelated key for a random variable cost: max key + 1
for (Key key : qp_.cost.getKeyDimMap() | boost::adaptors::map_keys) Key newKey = *qp_.cost.keys().rbegin();
if (newKey < key) if (!qp_.equalities.empty())
newKey = key; newKey = std::max(newKey, *qp_.equalities.keys().rbegin());
newKey++; if (!qp_.inequalities.empty())
newKey = std::max(newKey, *qp_.inequalities.keys().rbegin());
++newKey;
initProblem.cost = LinearCost(newKey, Vector::Ones(1)); initProblem.cost = LinearCost(newKey, Vector::Ones(1));
initProblem.equalities = qp_.equalities; initProblem.equalities = qp_.equalities;
initProblem.inequalities = qp_.inequalities; initProblem.inequalities = qp_.inequalities;