@@ -16,16 +16,16 @@ abstract type AbstractBoundaryFunction <: MOI.AbstractScalarFunction end
16
16
# # Initial & Final
17
17
18
18
"""
19
- Initial{DF}(dyn_fun ::DF) where {DF<:AbstractDynamicFunction}
19
+ Initial{DF}(evaluand ::DF) where {DF<:AbstractDynamicFunction}
20
20
21
21
Represents the evaluation of an [`AbstractDynamicFunction`](@ref) at the initial
22
22
point of its phase.
23
23
24
24
It is a sub-type of [`AbstractBoundaryFunction`](@ref). The dynamic function is stored
25
- in the `dyn_fun ` field.
25
+ in the `evaluand ` field.
26
26
"""
27
27
struct Initial{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
28
- dyn_fun :: DF
28
+ evaluand :: DF
29
29
end
30
30
31
31
function MOI. Utilities. _to_string (
@@ -35,22 +35,22 @@ function MOI.Utilities._to_string(
35
35
)
36
36
return string (
37
37
" Initial(" ,
38
- MOI. Utilities. _to_string (options, model, initial. dyn_fun ),
38
+ MOI. Utilities. _to_string (options, model, initial. evaluand ),
39
39
" )" ,
40
40
)
41
41
end
42
42
43
43
"""
44
- Final{DF}(dyn_fun ::DF) where {DF<:AbstractDynamicFunction}
44
+ Final{DF}(evaluand ::DF) where {DF<:AbstractDynamicFunction}
45
45
46
46
Represents the evaluation of an [`AbstractDynamicFunction`](@ref) at the final
47
47
point of its phase.
48
48
49
49
It is a sub-type of [`AbstractBoundaryFunction`](@ref). The dynamic function is stored
50
- in the `dyn_fun ` field.
50
+ in the `evaluand ` field.
51
51
"""
52
52
struct Final{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
53
- dyn_fun :: DF
53
+ evaluand :: DF
54
54
end
55
55
56
56
function MOI. Utilities. _to_string (
@@ -60,7 +60,7 @@ function MOI.Utilities._to_string(
60
60
)
61
61
return string (
62
62
" Final(" ,
63
- MOI. Utilities. _to_string (options, model, final. dyn_fun ),
63
+ MOI. Utilities. _to_string (options, model, final. evaluand ),
64
64
" )" ,
65
65
)
66
66
end
69
69
70
70
"""
71
71
Linkage{DF}(
72
- final::Final{DF} ,
73
- initial::Initial{DF} ,
72
+ final_evaluand::DF ,
73
+ initial_evaluand::DF ,
74
74
) where {DF<:AbstractDynamicFunction}
75
75
76
76
Represents the expression ``f_f(y(t^f), t^f) - f_0(y(t^0), t^0)``.
77
77
78
78
It is a sub-type of [`AbstractBoundaryFunction`](@ref). The final function is stored in the
79
- `final ` field and the initial function is stored in the `initial ` field.
79
+ `final_evaluand ` field and the initial function is stored in the `initial_evaluand ` field.
80
80
"""
81
81
struct Linkage{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
82
- final :: Final{DF}
83
- initial :: Initial{DF}
82
+ final_evaluand :: DF
83
+ initial_evaluand :: DF
84
84
end
85
85
86
86
function MOI. Utilities. _to_string (
@@ -89,9 +89,11 @@ function MOI.Utilities._to_string(
89
89
linkage:: Linkage ,
90
90
)
91
91
return string (
92
- MOI. Utilities. _to_string (options, model, linkage. final),
93
- " - " ,
92
+ " Final(" ,
93
+ MOI. Utilities. _to_string (options, model, linkage. final_evaluand),
94
+ " ) - Initial(" ,
94
95
MOI. Utilities. _to_string (options, model, linkage. initial),
96
+ " )" ,
95
97
)
96
98
end
97
99
@@ -149,14 +151,14 @@ end
149
151
# # Integrals
150
152
151
153
"""
152
- Integral{DF}(dyn_fun::AbstractDynamicFunction ) where {DF<:AbstractDynamicFunction}
154
+ Integral{DF}(integrand::DF ) where {DF<:AbstractDynamicFunction}
153
155
154
156
Represents the integral ``\\ int_{t_i^o}^{t_i^f} f_d(\\ dot{y}(t_i), y(t_i), t_i, x) \\ mathrm{d}t_i``.
155
157
156
- It is a sub-type of [`AbstractBoundaryFunction`](@ref). The integrand is stored in the `dyn_fun ` field.
158
+ It is a sub-type of [`AbstractBoundaryFunction`](@ref). The integrand is stored in the `integrand ` field.
157
159
"""
158
160
struct Integral{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
159
- dyn_fun :: DF
161
+ integrand :: DF
160
162
end
161
163
162
164
function MOI. Utilities. _to_string (
@@ -166,34 +168,75 @@ function MOI.Utilities._to_string(
166
168
)
167
169
return string (
168
170
" ∫(" ,
169
- MOI. Utilities. _to_string (options, model, integral. dyn_fun ),
171
+ MOI. Utilities. _to_string (options, model, integral. integrand ),
170
172
" )d(" ,
171
173
MOI. Utilities. _to_string (options, model, phase_index (integral)),
172
174
" )" ,
173
175
)
174
176
end
175
177
176
- phase_index (integral:: Integral ) = phase_index (integral. dyn_fun)
178
+ phase_index (integral:: Integral ) = phase_index (integral. integrand)
179
+
180
+ """
181
+ MultiPhaseIntegral{DF}(
182
+ integrands::Vector{DF},
183
+ ) where {DF<:AbstractDynamicFunction}
184
+
185
+ Represents the sum of integrals
186
+ ``\\ sum_i \\ big[ \\ int_{t_i^o}^{t_i^f} f_d(\\ dot{y}(t_i), y(t_i), t_i, x) \\ mathrm{d}t_i \\ big]``.
187
+
188
+ It is a sub-type of [`AbstractBoundaryFunction`](@ref). The vector of integrands is
189
+ stored in the `integrands` field.
190
+ """
191
+ struct MultiPhaseIntegral{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
192
+ integrands:: Vector{DF}
193
+ end
194
+
195
+ function MOI. Utilities. _to_string (
196
+ options:: MOI.Utilities._PrintOptions ,
197
+ model:: MOI.ModelLike ,
198
+ multi_phase_integral:: MultiPhaseIntegral ,
199
+ )
200
+ integrands = multi_phase_integral. integrands
201
+
202
+ s = string (
203
+ " ∫(" ,
204
+ MOI. Utilities. _to_string (options, model, integrands[1 ]),
205
+ " )d(" ,
206
+ MOI. Utilities. _to_string (options, model, phase_index (integrands[1 ])),
207
+ " )" ,
208
+ )
209
+
210
+ for i in 2 : length (integrands)
211
+ s *= string (
212
+ " + ∫(" ,
213
+ MOI. Utilities. _to_string (options, model, integrands[i]),
214
+ " )d(" ,
215
+ MOI. Utilities. _to_string (options, model, phase_index (integrands[i])),
216
+ " )" ,
217
+ )
218
+ end
219
+ return s
220
+ end
177
221
178
222
"""
179
- Bolza{BF,DF }(
223
+ Bolza{BF,IF }(
180
224
bou_fun::BF,
181
- integral::Integral{DF} ,
182
- ) where {BF<:AbstractBoundaryFunction,DF<:AbstractDynamicFunction }
225
+ integral::IF ,
226
+ ) where {BF<:AbstractBoundaryFunction,IF<:Union{Integral,MultiPhaseIntegral} }
183
227
184
228
```math
185
229
f_b(y_0, y_f, t_0, t_f, x) + \\ int_{t_i^o}^{t_i^f} f_d(\\ dot{y}(t_i), y(t_i), t_i, x) \\ mathrm{d}t_i
186
230
```
187
- Represents the sum of an [`AbstractBoundaryFunction`](@ref) with the integral of
188
- an [`AbstractDynamicFunction `](@ref).
231
+ Represents the sum of an [`AbstractBoundaryFunction`](@ref) with either an [`Integral`](@ref) or a
232
+ [`MultiPhaseIntegral `](@ref).
189
233
190
234
It is a sub-type of [`AbstractBoundaryFunction`](@ref). The boundary function is stored in the `bou_fun`
191
235
field and the integral is stored in the `integral` field.
192
236
"""
193
- struct Bolza{BF<: AbstractBoundaryFunction ,DF<: AbstractDynamicFunction } < :
194
- AbstractBoundaryFunction
237
+ struct Bolza{BF<: AbstractBoundaryFunction ,IF<: Union{Integral,MultiPhaseIntegral} } <: AbstractBoundaryFunction
195
238
bou_fun:: BF
196
- integral:: Integral{DF}
239
+ integral:: IF
197
240
end
198
241
199
242
function MOI. Utilities. _to_string (
0 commit comments