Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt;
g = SciMLBase.requiresgradient(opt), h = SciMLBase.requireshessian(opt),
hv = SciMLBase.requireshessian(opt), fg = SciMLBase.allowsfg(opt),
fgh = SciMLBase.allowsfgh(opt), cons_j = SciMLBase.requiresconsjac(opt), cons_h = SciMLBase.requiresconshess(opt),
cons_vjp = SciMLBase.allowsconsjvp(opt), cons_jvp = SciMLBase.allowsconsjvp(opt), lag_h = SciMLBase.requireslagh(opt))
cons_vjp = SciMLBase.allowsconsjvp(opt), cons_jvp = SciMLBase.allowsconsjvp(opt), lag_h = SciMLBase.requireslagh(opt), sense = prob.sense)

if structural_analysis
obj_res, cons_res = symify_cache(f, prob, num_cons, manifold)
Expand Down
5 changes: 3 additions & 2 deletions src/function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ end

function OptimizationBase.instantiate_function(
f::OptimizationFunction{true}, x, ::SciMLBase.NoAD,
p, num_cons = 0; kwargs...)
p, num_cons = 0; sense, kwargs...)
if f.grad === nothing
grad = nothing
else
Expand Down Expand Up @@ -205,7 +205,8 @@ function OptimizationBase.instantiate_function(
expr = symbolify(f.expr)
cons_expr = symbolify.(f.cons_expr)

return OptimizationFunction{true}(f.f, SciMLBase.NoAD();
obj_f = (x,p) -> sense == MaxSense ? -1.0* f.f(x,p) : f.f(x,p)
return OptimizationFunction{true}(obj_f, SciMLBase.NoAD();
grad = grad, fg = fg, hess = hess, fgh = fgh, hv = hv,
cons = cons, cons_j = cons_j, cons_h = cons_h,
cons_vjp = cons_vjp, cons_jvp = cons_jvp,
Expand Down
Loading