Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Closed
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
13 changes: 9 additions & 4 deletions src/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
constraints::C
end

struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, P, C, M} <:
struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, P, C, M, ND, FS} <:

Check warning on line 8 in src/cache.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"ND" should be "AND".
SciMLBase.AbstractOptimizationCache
f::F
reinit_cache::RC
Expand All @@ -20,6 +20,8 @@
manifold::M
analysis_results::AnalysisResults
solver_args::NamedTuple
num_dimensions::ND

Check warning on line 23 in src/cache.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"ND" should be "AND".
fitness_scheme::FS
end

function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt;
Expand All @@ -39,7 +41,10 @@
reinit_cache = OptimizationBase.ReInitCache(prob.u0, prob.p)
reinit_cache_passedon = reinit_cache
end


num_dimensions=prob.num_dimensions
fitness_scheme = prob.fitness_scheme

num_cons = prob.ucons === nothing ? 0 : length(prob.ucons)

if !(prob.f.adtype isa DifferentiationInterface.SecondOrder ||
Expand Down Expand Up @@ -75,7 +80,7 @@
prob.ucons, prob.sense,
opt, progress, callback, manifold, AnalysisResults(obj_res, cons_res),
merge((; maxiters, maxtime, abstol, reltol),
NamedTuple(kwargs)))
NamedTuple(kwargs)), num_dimensions, fitness_scheme)
end

function SciMLBase.__init(prob::SciMLBase.OptimizationProblem, opt;
Expand All @@ -87,7 +92,7 @@
progress = false,
kwargs...)
return OptimizationCache(prob, opt; maxiters, maxtime, abstol, callback,
reltol, progress,
reltol, progress, prob.num_dimensions, prob.fitness_scheme,
kwargs...)
end

Expand Down
16 changes: 12 additions & 4 deletions src/function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ function OptimizationBase.instantiate_function(
for i in 1:num_cons]
expr = symbolify(f.expr)
cons_expr = symbolify.(f.cons_expr)

num_dimensions = f.num_dimensions === nothing ? nothing : f.num_dimensions
fitness_scheme = f.fitness_scheme === nothing ? nothing : f.fitness_scheme

return MultiObjectiveOptimizationFunction{true}(
f.f, SciMLBase.NoAD(); jac = jac, hess = hess,
hv = hv,
Expand All @@ -74,7 +76,9 @@ function OptimizationBase.instantiate_function(
cons_hess_prototype = cons_hess_prototype,
expr = expr, cons_expr = cons_expr,
sys = f.sys,
observed = f.observed)
observed = f.observed,
num_dimensions,
fitness_scheme)
end

function OptimizationBase.instantiate_function(
Expand All @@ -98,7 +102,9 @@ function OptimizationBase.instantiate_function(
for i in 1:num_cons]
expr = symbolify(f.expr)
cons_expr = symbolify.(f.cons_expr)

num_dimensions = f.num_dimensions === nothing ? nothing : f.num_dimensions
fitness_scheme = f.fitness_scheme === nothing ? nothing : f.fitness_scheme

return MultiObjectiveOptimizationFunction{true}(
f.f, SciMLBase.NoAD(); jac = jac, hess = hess,
hv = hv,
Expand All @@ -108,7 +114,9 @@ function OptimizationBase.instantiate_function(
cons_hess_prototype = cons_hess_prototype,
expr = expr, cons_expr = cons_expr,
sys = f.sys,
observed = f.observed)
observed = f.observed,
num_dimensions,
fitness_scheme)
end

function OptimizationBase.instantiate_function(
Expand Down
Loading