@@ -16,16 +16,16 @@ abstract type AbstractBoundaryFunction <: MOI.AbstractScalarFunction end
1616# # Initial & Final
1717
1818"""
19- Initial{DF}(dyn_fun ::DF) where {DF<:AbstractDynamicFunction}
19+ Initial{DF}(evaluand ::DF) where {DF<:AbstractDynamicFunction}
2020
2121Represents the evaluation of an [`AbstractDynamicFunction`](@ref) at the initial
2222point of its phase.
2323
2424It is a sub-type of [`AbstractBoundaryFunction`](@ref). The dynamic function is stored
25- in the `dyn_fun ` field.
25+ in the `evaluand ` field.
2626"""
2727struct Initial{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
28- dyn_fun :: DF
28+ evaluand :: DF
2929end
3030
3131function MOI. Utilities. _to_string (
@@ -35,22 +35,22 @@ function MOI.Utilities._to_string(
3535)
3636 return string (
3737 " Initial(" ,
38- MOI. Utilities. _to_string (options, model, initial. dyn_fun ),
38+ MOI. Utilities. _to_string (options, model, initial. evaluand ),
3939 " )" ,
4040 )
4141end
4242
4343"""
44- Final{DF}(dyn_fun ::DF) where {DF<:AbstractDynamicFunction}
44+ Final{DF}(evaluand ::DF) where {DF<:AbstractDynamicFunction}
4545
4646Represents the evaluation of an [`AbstractDynamicFunction`](@ref) at the final
4747point of its phase.
4848
4949It is a sub-type of [`AbstractBoundaryFunction`](@ref). The dynamic function is stored
50- in the `dyn_fun ` field.
50+ in the `evaluand ` field.
5151"""
5252struct Final{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
53- dyn_fun :: DF
53+ evaluand :: DF
5454end
5555
5656function MOI. Utilities. _to_string (
@@ -60,7 +60,7 @@ function MOI.Utilities._to_string(
6060)
6161 return string (
6262 " Final(" ,
63- MOI. Utilities. _to_string (options, model, final. dyn_fun ),
63+ MOI. Utilities. _to_string (options, model, final. evaluand ),
6464 " )" ,
6565 )
6666end
6969
7070"""
7171 Linkage{DF}(
72- final::Final{DF} ,
73- initial::Initial{DF} ,
72+ final_evaluand::DF ,
73+ initial_evaluand::DF ,
7474 ) where {DF<:AbstractDynamicFunction}
7575
7676Represents the expression ``f_f(y(t^f), t^f) - f_0(y(t^0), t^0)``.
7777
7878It 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.
8080"""
8181struct Linkage{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
82- final :: Final{DF}
83- initial :: Initial{DF}
82+ final_evaluand :: DF
83+ initial_evaluand :: DF
8484end
8585
8686function MOI. Utilities. _to_string (
@@ -89,9 +89,11 @@ function MOI.Utilities._to_string(
8989 linkage:: Linkage ,
9090)
9191 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(" ,
9495 MOI. Utilities. _to_string (options, model, linkage. initial),
96+ " )" ,
9597 )
9698end
9799
@@ -149,14 +151,14 @@ end
149151# # Integrals
150152
151153"""
152- Integral{DF}(dyn_fun::AbstractDynamicFunction ) where {DF<:AbstractDynamicFunction}
154+ Integral{DF}(integrand::DF ) where {DF<:AbstractDynamicFunction}
153155
154156Represents 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``.
155157
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.
157159"""
158160struct Integral{DF<: AbstractDynamicFunction } <: AbstractBoundaryFunction
159- dyn_fun :: DF
161+ integrand :: DF
160162end
161163
162164function MOI. Utilities. _to_string (
@@ -166,34 +168,75 @@ function MOI.Utilities._to_string(
166168)
167169 return string (
168170 " ∫(" ,
169- MOI. Utilities. _to_string (options, model, integral. dyn_fun ),
171+ MOI. Utilities. _to_string (options, model, integral. integrand ),
170172 " )d(" ,
171173 MOI. Utilities. _to_string (options, model, phase_index (integral)),
172174 " )" ,
173175 )
174176end
175177
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
177221
178222"""
179- Bolza{BF,DF }(
223+ Bolza{BF,IF }(
180224 bou_fun::BF,
181- integral::Integral{DF} ,
182- ) where {BF<:AbstractBoundaryFunction,DF<:AbstractDynamicFunction }
225+ integral::IF ,
226+ ) where {BF<:AbstractBoundaryFunction,IF<:Union{Integral,MultiPhaseIntegral} }
183227
184228```math
185229f_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
186230```
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).
189233
190234It is a sub-type of [`AbstractBoundaryFunction`](@ref). The boundary function is stored in the `bou_fun`
191235field and the integral is stored in the `integral` field.
192236"""
193- struct Bolza{BF<: AbstractBoundaryFunction ,DF<: AbstractDynamicFunction } < :
194- AbstractBoundaryFunction
237+ struct Bolza{BF<: AbstractBoundaryFunction ,IF<: Union{Integral,MultiPhaseIntegral} } <: AbstractBoundaryFunction
195238 bou_fun:: BF
196- integral:: Integral{DF}
239+ integral:: IF
197240end
198241
199242function MOI. Utilities. _to_string (
0 commit comments