Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce constant term in QP to be default 0 #607

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions gtsam_unstable/linear/QPSParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class QPSVisitor {
varname_to_key; // Variable QPS string name to key
std::unordered_map<Key, std::unordered_map<Key, Matrix11>>
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 name_; // the quadratic program has a name in the QPS
std::unordered_map<Key, double>
Expand Down Expand Up @@ -175,10 +175,11 @@ class QPSVisitor {
string var_ = fromChars<1>(vars);
string row_ = fromChars<3>(vars);
double coefficient = at_c<5>(vars);
if (row_ == obj_name)
if (row_ == obj_name) {
f = -coefficient;
else
} else {
b[row_] = coefficient;
}

if (debug) {
cout << "Added RHS for Var: " << var_ << " Row: " << row_
Expand All @@ -194,15 +195,17 @@ class QPSVisitor {
string row2_ = fromChars<7>(vars);
double coefficient1 = at_c<5>(vars);
double coefficient2 = at_c<9>(vars);
if (row1_ == obj_name)
if (row1_ == obj_name) {
f = -coefficient1;
else
} else {
b[row1_] = coefficient1;
}

if (row2_ == obj_name)
if (row2_ == obj_name) {
f = -coefficient2;
else
} else {
b[row2_] = coefficient2;
}

if (debug) {
cout << "Added RHS for Var: " << var_ << " Row: " << row1_
Expand Down