Merge pull request #607 from borglab/fix/306
Enforce constant term in QP to be default 0release/4.3a0
commit
ea2064e74d
|
@ -81,7 +81,7 @@ class QPSVisitor {
|
||||||
varname_to_key; // Variable QPS string name to key
|
varname_to_key; // Variable QPS string name to key
|
||||||
std::unordered_map<Key, std::unordered_map<Key, Matrix11>>
|
std::unordered_map<Key, std::unordered_map<Key, Matrix11>>
|
||||||
H; // H from hessian
|
H; // H from hessian
|
||||||
double f; // Constant term of quadratic cost
|
double f = 0; // Constant term of quadratic cost
|
||||||
std::string obj_name; // the objective function has a name in the QPS
|
std::string obj_name; // the objective function has a name in the QPS
|
||||||
std::string name_; // the quadratic program has a name in the QPS
|
std::string name_; // the quadratic program has a name in the QPS
|
||||||
std::unordered_map<Key, double>
|
std::unordered_map<Key, double>
|
||||||
|
@ -175,10 +175,11 @@ class QPSVisitor {
|
||||||
string var_ = fromChars<1>(vars);
|
string var_ = fromChars<1>(vars);
|
||||||
string row_ = fromChars<3>(vars);
|
string row_ = fromChars<3>(vars);
|
||||||
double coefficient = at_c<5>(vars);
|
double coefficient = at_c<5>(vars);
|
||||||
if (row_ == obj_name)
|
if (row_ == obj_name) {
|
||||||
f = -coefficient;
|
f = -coefficient;
|
||||||
else
|
} else {
|
||||||
b[row_] = coefficient;
|
b[row_] = coefficient;
|
||||||
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
cout << "Added RHS for Var: " << var_ << " Row: " << row_
|
cout << "Added RHS for Var: " << var_ << " Row: " << row_
|
||||||
|
@ -194,15 +195,17 @@ class QPSVisitor {
|
||||||
string row2_ = fromChars<7>(vars);
|
string row2_ = fromChars<7>(vars);
|
||||||
double coefficient1 = at_c<5>(vars);
|
double coefficient1 = at_c<5>(vars);
|
||||||
double coefficient2 = at_c<9>(vars);
|
double coefficient2 = at_c<9>(vars);
|
||||||
if (row1_ == obj_name)
|
if (row1_ == obj_name) {
|
||||||
f = -coefficient1;
|
f = -coefficient1;
|
||||||
else
|
} else {
|
||||||
b[row1_] = coefficient1;
|
b[row1_] = coefficient1;
|
||||||
|
}
|
||||||
|
|
||||||
if (row2_ == obj_name)
|
if (row2_ == obj_name) {
|
||||||
f = -coefficient2;
|
f = -coefficient2;
|
||||||
else
|
} else {
|
||||||
b[row2_] = coefficient2;
|
b[row2_] = coefficient2;
|
||||||
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
cout << "Added RHS for Var: " << var_ << " Row: " << row1_
|
cout << "Added RHS for Var: " << var_ << " Row: " << row1_
|
||||||
|
|
Loading…
Reference in New Issue