Skip to content

Commit

Permalink
Add preeval
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Oct 5, 2019
1 parent 2d976d0 commit b7f2a45
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/objectives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct SteadyStateObjective{
TCL <: Lens,
TPL <: Lens,
TSSS,
TE,
TNLC,
}
loss::TL # loss(u, condition, sso)
Expand All @@ -19,6 +20,7 @@ struct SteadyStateObjective{
conditionsetter::TCL
parameterlens::TPL
steadystatesolver::TSSS
preeval::TE
nlsolvecallback::TNLC
end

Expand Down Expand Up @@ -72,13 +74,15 @@ SteadyStateObjective(
conditionsetter,
parameterlens,
steadystatesolver = NLSolver();
preeval = donothing,
nlsolvecallback = donothing,
) =
SteadyStateObjective(
loss, ode.f.f, ode.f.jac, ode.p,
deepcopy(fill(ode.u0, size(conditions))),
conditions, conditionsetter, parameterlens,
steadystatesolver,
preeval,
nlsolvecallback,
)

Expand Down Expand Up @@ -122,6 +126,8 @@ _steadystate(sso::SteadyStateObjective, u0, condition) =
# f(x)
(sso::SteadyStateObjective)(x) =
let sso = setparameter(sso, x)
y = sso.preeval(sso)
y === nothing || return y
states = map(sso.states, sso.conditions) do u0, condition
_steadystate(sso, u0, condition)
end
Expand Down

0 comments on commit b7f2a45

Please sign in to comment.