fix a crash due to problems with boost adaptors on rvalue (https://svn.boost.org/trac/boost/ticket/9578)

release/4.3a0
Duy-Nguyen Ta 2016-06-15 09:35:43 -04:00
parent c90304398e
commit 3b897950a6
1 changed files with 5 additions and 5 deletions

View File

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