Skip to content

Commit 2960a1b

Browse files
Update optimization_problems.jl
Added num_dimensions, fitness_scheme for BBO wrapper.
1 parent bfd5a7f commit 2960a1b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/problems/optimization_problems.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ OptimizationProblem{iip}(f, u0, p = SciMLBase.NullParameters(),;
3131
lcons = nothing,
3232
ucons = nothing,
3333
sense = nothing,
34+
num_dimensions = nothing,
35+
fitness_scheme = nothing,
3436
kwargs...)
3537
```
3638
@@ -77,7 +79,8 @@ Any extra keyword arguments are captured to be sent to the optimizers.
7779
Defaults to `nothing`, implying no upper bounds for the constraints (i.e. the constraint bound is `Inf`)
7880
* `sense`: the objective sense, can take `MaxSense` or `MinSense` from Optimization.jl.
7981
* `kwargs`: the keyword arguments passed on to the solvers.
80-
82+
* `num_dimensions`: For BBO optimization.
83+
* `fitness_scheme`: For BBO optimization.
8184
## Inequality and Equality Constraints
8285
8386
Both inequality and equality constraints are defined by the `f.cons` function in the [`OptimizationFunction`](https://docs.sciml.ai/Optimization/stable/API/optimization_function/#optfunction)
@@ -95,7 +98,7 @@ Note that these vectors must be sized to match the number of constraints, with o
9598
As described above the second argument of the objective definition can take a full batch or a [`DataLoader`](https://juliaml.github.io/MLUtils.jl/stable/api/#MLUtils.DataLoader) object for mini-batching which is useful for stochastic optimization solvers. Thus the data either as an Array or a `DataLoader` object should be passed as the third argument of the `OptimizationProblem` constructor.
9699
For an example of how to use this data handling, see the `Sophia` example in the [Optimization.jl documentation](https://docs.sciml.ai/Optimization/dev/optimization_packages/optimization) or the [mini-batching tutorial](https://docs.sciml.ai/Optimization/dev/tutorials/minibatch/).
97100
"""
98-
struct OptimizationProblem{iip, F, uType, P, LB, UB, I, LC, UC, S, K} <:
101+
struct OptimizationProblem{iip, F, uType, P, LB, UB, I, LC, UC, S, ND, FS, K} <:
99102
AbstractOptimizationProblem{iip}
100103
f::F
101104
u0::uType
@@ -106,21 +109,23 @@ struct OptimizationProblem{iip, F, uType, P, LB, UB, I, LC, UC, S, K} <:
106109
lcons::LC
107110
ucons::UC
108111
sense::S
112+
num_dimensions::ND
113+
fitness_scheme::FS
109114
kwargs::K
110115
@add_kwonly function OptimizationProblem{iip}(
111116
f::Union{OptimizationFunction{iip}, MultiObjectiveOptimizationFunction{iip}},
112117
u0,
113118
p = NullParameters();
114119
lb = nothing, ub = nothing, int = nothing,
115120
lcons = nothing, ucons = nothing,
116-
sense = nothing, kwargs...) where {iip}
121+
sense = nothing, num_dimensions = nothing, fitness_scheme = nothing, kwargs...) where {iip}
117122
if xor(lb === nothing, ub === nothing)
118123
error("If any of `lb` or `ub` is provided, both must be provided.")
119124
end
120125
warn_paramtype(p)
121126
new{iip, typeof(f), typeof(u0), typeof(p),
122127
typeof(lb), typeof(ub), typeof(int), typeof(lcons), typeof(ucons),
123-
typeof(sense), typeof(kwargs)}(f, u0, p, lb, ub, int, lcons, ucons, sense,
128+
typeof(sense), typeof(num_dimensions), typeof(fitness_scheme), typeof(kwargs)}(f, u0, p, lb, ub, int, lcons, ucons, sense, num_dimensions, fitness_scheme,
124129
kwargs)
125130
end
126131
end

0 commit comments

Comments
 (0)