You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Mathematical Specification of an Optimization Problem
9
9
10
10
To define an optimization problem, you need the objective function ``f``
11
-
which is minimized over the domain of ``x``, the collection of optimization variables:
11
+
which is minimized over the domain of ``u``, the collection of optimization variables:
12
12
13
13
```math
14
-
min_u f(x,p)
14
+
min_u f(u,p)
15
15
```
16
16
17
-
``x₀`` is an initial guess for the minimizer. `f` should be specified as `f(x,p)`
17
+
``u₀`` is an initial guess for the minimizer. `f` should be specified as `f(u,p)`
18
18
and `u₀` should be an `AbstractArray` whose geometry matches the
19
-
desired geometry of `x`. Note that we are not limited to vectors
20
-
for `x₀`; one is allowed to provide `x₀` as arbitrary matrices /
19
+
desired geometry of `u`. Note that we are not limited to vectors
20
+
for `u₀`; one is allowed to provide `u₀` as arbitrary matrices /
21
21
higher-dimension tensors as well.
22
22
23
23
## Problem Type
24
24
25
25
### Constructors
26
26
27
27
```julia
28
-
OptimizationProblem{iip}(f, x0, p = SciMLBase.NullParameters(),;
28
+
OptimizationProblem{iip}(f, u0, p = SciMLBase.NullParameters(),;
29
29
lb = nothing,
30
30
ub = nothing,
31
31
lcons = nothing,
@@ -44,12 +44,12 @@ will be used, which will throw nice errors if you try to index non-existent
44
44
parameters.
45
45
46
46
`lb` and `ub` are the upper and lower bounds for box constraints on the
47
-
optimization variables. They should be an `AbstractArray` matching the geometry of `x`,
48
-
where `(lb[i],ub[i])` is the box constraint (lower and upper bounds) for `x[i]`.
47
+
optimization variables. They should be an `AbstractArray` matching the geometry of `u`,
48
+
where `(lb[i],ub[i])` is the box constraint (lower and upper bounds) for `u[i]`.
49
49
50
50
`lcons` and `ucons` are the upper and lower bounds in case of inequality constraints on the
51
51
optimization and if they are set to be equal then it represents an equality constraint.
52
-
They should be an `AbstractArray` matching the geometry of `x`, where `(lcons[i],ucons[i])`
52
+
They should be an `AbstractArray` matching the geometry of `u`, where `(lcons[i],ucons[i])`
53
53
are the lower and upper bounds for `cons[i]`.
54
54
55
55
The `f` in the `OptimizationProblem` should typically be an instance of [`OptimizationFunction`](https://docs.sciml.ai/Optimization/stable/API/optimization_function/#optfunction)
@@ -65,10 +65,10 @@ Any extra keyword arguments are captured to be sent to the optimizers.
65
65
### Fields
66
66
67
67
* `f`: the function in the problem.
68
-
* `x0`: the initial guess for the optimization variables.
68
+
* `u0`: the initial guess for the optimization variables.
69
69
* `p`: the constant parameters used for defining the problem. Defaults to `NullParameters`.
70
-
* `lb`: the lower bounds for the optimization variables `x`.
71
-
* `ub`: the upper bounds for the optimization variables `x`.
70
+
* `lb`: the lower bounds for the optimization variables `u`.
71
+
* `ub`: the upper bounds for the optimization variables `u`.
72
72
* `int`: integrality indicator for `u`. If `int[i] == true`, then `u[i]` is an integer variable.
73
73
Defaults to `nothing`, implying no integrality constraints.
74
74
* `lcons`: the vector of lower bounds for the constraints passed to [OptimizationFunction](https://docs.sciml.ai/Optimization/stable/API/optimization_function/#optfunction).
@@ -81,12 +81,12 @@ Any extra keyword arguments are captured to be sent to the optimizers.
81
81
## Inequality and Equality Constraints
82
82
83
83
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)
84
-
description of the problem structure. This `f.cons` is given as a function `f.cons(x,p)` which computes
85
-
the value of the constraints at `x`. For example, take `f.cons(x,p) = x[1] - x[2]`.
84
+
description of the problem structure. This `f.cons` is given as a function `f.cons(u,p)` which computes
85
+
the value of the constraints at `u`. For example, take `f.cons(u,p) = u[1] - u[2]`.
86
86
With these definitions, `lcons` and `ucons` define the bounds on the constraint that the solvers try to satisfy.
87
-
If `lcons` and `ucons` are `nothing`, then there are no constraints bounds, meaning that the constraint is satisfied when `-Inf < f.cons < Inf` (which of course is always!). If `lcons[i] = ucons[i] = 0`, then the constraint is satisfied when `f.cons(x,p)[i] = 0`, and so this implies the equality constraint `u[1] = u[2]`. If `lcons[i] = ucons[i] = a`, then ``x[1] - x[2] = a`` is the equality constraint.
87
+
If `lcons` and `ucons` are `nothing`, then there are no constraints bounds, meaning that the constraint is satisfied when `-Inf < f.cons < Inf` (which of course is always!). If `lcons[i] = ucons[i] = 0`, then the constraint is satisfied when `f.cons(u,p)[i] = 0`, and so this implies the equality constraint `u[1] = u[2]`. If `lcons[i] = ucons[i] = a`, then ``u[1] - u[2] = a`` is the equality constraint.
88
88
89
-
Inequality constraints are then given by making `lcons[i] != ucons[i]`. For example, `lcons[i] = -Inf` and `ucons[i] = 0` would imply the inequality constraint ``x[1] <= x[2]`` since any `f.cons[i] <= 0` satisfies the constraint. Similarly, `lcons[i] = -1` and `ucons[i] = 1` would imply that `-1 <= f.cons[i] <= 1` is required or ``-1 <= x[1] - x[2] <= 1``.
89
+
Inequality constraints are then given by making `lcons[i] != ucons[i]`. For example, `lcons[i] = -Inf` and `ucons[i] = 0` would imply the inequality constraint ``u[1] <= u[2]`` since any `f.cons[i] <= 0` satisfies the constraint. Similarly, `lcons[i] = -1` and `ucons[i] = 1` would imply that `-1 <= f.cons[i] <= 1` is required or ``-1 <= u[1] - u[2] <= 1``.
90
90
91
91
Note that these vectors must be sized to match the number of constraints, with one set of conditions for each constraint.
92
92
@@ -150,7 +150,3 @@ end
150
150
151
151
isinplace(f::OptimizationFunction{iip}) where {iip} = iip
152
152
isinplace(f::OptimizationProblem{iip}) where {iip} = iip
153
-
154
-
function Base.getproperty(prob::OptimizationProblem, sym::Symbol)
Copy file name to clipboardExpand all lines: src/solutions/ode_solutions.jl
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -605,11 +605,14 @@ function sensitivity_solution(sol::ODESolution, u, t)
605
605
return@set sol.interp = interp
606
606
end
607
607
608
-
struct LazyInterpolationException <:Exception
608
+
struct LazyInterpolationException <:Exception
609
609
var::Symbol
610
610
end
611
611
612
-
Base.showerror(io::IO, e::LazyInterpolationException) =print(io, "The algorithm", e.var, " uses lazy interpolation, which is incompatible with `strip_solution`.")
612
+
function Base.showerror(io::IO, e::LazyInterpolationException)
613
+
print(io, "The algorithm", e.var,
614
+
" uses lazy interpolation, which is incompatible with `strip_solution`.")
0 commit comments