Merge remote-tracking branch 'origin/feature/LPSolver' into feature/LPSolver
commit
1102a0e425
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue