Commit a260eaa 1 parent a2e7d6c commit a260eaa Copy full SHA for a260eaa
File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ class NLModel {
69
69
// / Add linear objective (only single objective supported.)
70
70
// / Sense: NLW2_ObjSenseM....
71
71
// / Coefficients: dense vector.
72
- void SetLinearObjective (int sense, double c0, const double * c)
72
+ void SetLinearObjective (int sense, double c0,
73
+ const double * c = nullptr )
73
74
{ obj_sense_=sense; obj_c0_=c0; obj_c_=c; }
74
75
75
76
// / Add Q for the objective quadratic part 0.5 @ x.T @ Q @ x.
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ class NLFeeder2_Easy
83
83
auto c = NLME ().ObjCoefficients ();
84
84
for (int j=0 ; j<header_.num_vars ; ++j)
85
85
if (obj_grad_supp_[j])
86
- svw.Write (VPerm (j), c[j]);
86
+ svw.Write (VPerm (j), c ? c [j] : 0.0 );
87
87
}
88
88
}
89
89
@@ -378,9 +378,11 @@ class NLFeeder2_Easy
378
378
379
379
void FillObjNonzeros () {
380
380
obj_grad_supp_.resize (NLME ().NumCols ());
381
- // Linear part
382
- for (auto i=NLME ().NumCols (); i--; )
383
- obj_grad_supp_[i] = (NLME ().ObjCoefficients ()[i]);
381
+ // Linear part -- if provided
382
+ if (NLME ().ObjCoefficients ()) {
383
+ for (auto i=NLME ().NumCols (); i--; )
384
+ obj_grad_supp_[i] = (NLME ().ObjCoefficients ()[i]);
385
+ }
384
386
// QP part
385
387
auto Q = NLME ().Hessian ();
386
388
if (Q.num_nz_ ) {
You can’t perform that action at this time.
0 commit comments