-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
201 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" | ||
DynOptInterface = "6c38235a-427b-4736-80fa-cf75909744ec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,95 @@ | ||
""" | ||
DomainInitial <: AbstractBoundaryFunction | ||
Initial{AF<:AbstractAlgebraicFunction} <: AbstractBoundaryFunction | ||
```math | ||
t_i^0 | ||
a(y(t_i^0), t_i^0, x) | ||
``` | ||
Represents the initial point of a [`DomainIndex`](@ref). | ||
Represents the evaluation of an [`AbstractAlgebraicFunction`](@ref) at the initial | ||
point of its domain. Common cases are: | ||
* ``t_i^0`` `Initial{DomainIndex}` | ||
* ``y_j(t_i^0)`` `Initial{DynamicVariableIndex}` | ||
""" | ||
struct DomainInitial <: AbstractBoundaryFunction | ||
index::DomainIndex | ||
struct Initial{AF<:AbstractAlgebraicFunction} <: AbstractBoundaryFunction | ||
evaluand::AF | ||
end | ||
|
||
""" | ||
DomainFinal <: AbstractBoundaryFunction | ||
```math | ||
t_i^f | ||
``` | ||
Represents the final point of a [`DomainIndex`](@ref). | ||
""" | ||
struct DomainFinal <: AbstractBoundaryFunction | ||
index::DomainIndex | ||
function MOI.Utilities._to_string(options::MOI.Utilities._PrintOptions, model::MOI.ModelLike, | ||
initial::Initial, | ||
) | ||
return string( | ||
"Initial(", | ||
MOI.Utilities._to_string(options, model, initial.evaluand), | ||
")", | ||
) | ||
end | ||
|
||
""" | ||
DynamicVariableInitial <: AbstractBoundaryFunction | ||
Final{AF<:AbstractAlgebraicFunction} <: AbstractBoundaryFunction | ||
```math | ||
y_j(t_i^0) | ||
``` | ||
Represents a [`DynamicVariableIndex`](@ref) evaluated at the initial point of its [`DomainIndex`](@ref) | ||
a(y(t_i^f), t_i^f, x) | ||
``` | ||
Represents the evaluation of an [`AbstractAlgebraicFunction`](@ref) at the final | ||
point of its domain. Common cases are: | ||
* ``t_i^f`` `Final{DomainIndex}` | ||
* ``y_j(t_i^f)`` `Final{DynamicVariableIndex}` | ||
""" | ||
struct DynamicVariableInitial <: AbstractBoundaryFunction | ||
variable_index::DynamicVariableIndex | ||
struct Final{AF<:AbstractAlgebraicFunction} <: AbstractBoundaryFunction | ||
evaluand::AF | ||
end | ||
|
||
""" | ||
DynamicVariableFinal <: AbstractBoundaryFunction | ||
```math | ||
y_j(t_i^f) | ||
``` | ||
Represents a [`DynamicVariableIndex`](@ref) evaluated at the final point of its [`DomainIndex`](@ref) | ||
""" | ||
struct DynamicVariableFinal <: AbstractBoundaryFunction | ||
variable_index::DynamicVariableIndex | ||
function MOI.Utilities._to_string(options::MOI.Utilities._PrintOptions, model::MOI.ModelLike, | ||
final::Final, | ||
) | ||
return string( | ||
"Final(", | ||
MOI.Utilities._to_string(options, model, final.evaluand), | ||
")", | ||
) | ||
end | ||
|
||
const _NONLINEAR_BOUNDARY_TYPES = Union{ | ||
Real, | ||
MOI.VariableIndex, | ||
Initial{DomainIndex}, | ||
Final{DomainIndex}, | ||
Initial{DynamicVariableIndex}, | ||
Final{DynamicVariableIndex}, | ||
} | ||
|
||
""" | ||
NonlinearBoundaryFunction <: AbstractBoundaryFunction | ||
```math | ||
b(y_j(t^0), y_j(t^f), t^0, t^f, x) | ||
b(y(t^0), y(t^f), t^0, t^f, x) | ||
``` | ||
Similar to [`MathOptInterface.ScalarNonlinearFunction`](@extref), | ||
Each node in `args` can be one of the following: | ||
* A constant value of type `T<:Real` | ||
* A [`MathOptInterface.VariableIndex`](@extref) | ||
* A [`DomainInitial`](@ref) | ||
* A [`DomainFinal`](@ref) | ||
* A [`DynamicVariableInitial`](@ref) | ||
* A [`DynamicVariableFinal`](@ref) | ||
* An `Initial{DomainIndex}` | ||
* A `Final{DomainIndex}` | ||
* An `Initial{DynamicVariableIndex}` | ||
* A `Final{DynamicVariableIndex}` | ||
* Another [`NonlinearBoundaryFunction`](@ref) | ||
""" | ||
struct NonlinearBoundaryFunction <: AbstractBoundaryFunction | ||
head::Symbol | ||
args::Vector{Any} | ||
# Inner constructor to enforce rules | ||
|
||
function NonlinearBoundaryFunction(head::Symbol, args::AbstractVector) | ||
for arg in args | ||
if !(arg isa _NONLINEAR_BOUNDARY_TYPES) | ||
error("Unsupported object: $arg") | ||
end | ||
end | ||
return new(head, convert(Vector{Any}, args), t_i) | ||
end | ||
end | ||
|
||
function MOI.Utilities._to_string(options::MOI.Utilities._PrintOptions, model::MOI.ModelLike, | ||
nbf::NonlinearBoundaryFunction, | ||
) | ||
return _nonlinear_to_string(options, model, nbf) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.