Skip to content

Commit

Permalink
ResidualFunction now calls ResourcesFunction before all others.
Browse files Browse the repository at this point in the history
  • Loading branch information
allanleal committed Jul 30, 2021
1 parent 2957d17 commit 29c79fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Optima/ResidualFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct ResidualFunction::Impl
/// The current state of the residual vector.
ResidualVector residual;

/// The optional function that precomputes shared resources among f, h, v functions
ResourcesFunction r;

/// The objective function *f(x, p)*.
ObjectiveFunction f;

Expand Down Expand Up @@ -96,6 +99,7 @@ struct ResidualFunction::Impl
hres.resize(nz, nx, np, nc);
vres.resize(np, nx, np, nc);
echelonizerW.initialize(dims, problem.Ax, problem.Ap);
r = problem.r;
f = problem.f;
h = problem.h;
v = problem.v;
Expand Down Expand Up @@ -147,6 +151,7 @@ struct ResidualFunction::Impl
ObjectiveOptions fopts{{eval_ddx, eval_ddp && np, eval_ddc && nc}, ibasicvars};
ConstraintOptions hopts{{eval_ddx, eval_ddp && np, eval_ddc && nc}, ibasicvars};
ConstraintOptions vopts{{eval_ddx, eval_ddp && np, eval_ddc && nc}, ibasicvars};
r(x, p, c, fopts, hopts, vopts);
f(fres, x, p, c, fopts);
if(nz) h(hres, x, p, c, hopts);
if(np) v(vres, x, p, c, vopts);
Expand Down

0 comments on commit 29c79fd

Please sign in to comment.