Skip to content

Commit 0be8c04

Browse files
committed
refined interface
1 parent 24daeef commit 0be8c04

16 files changed

+332
-151
lines changed

docs/make.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using DynOptInterface
22
using Documenter
3+
using DocumenterInterLinks
34

45
DocMeta.setdocmeta!(DynOptInterface, :DocTestSetup, :(using DynOptInterface); recursive=true)
56

67
const _PAGES = [
78
"Home" => "index.md",
89
"API Reference" => [
10+
"reference/abstractions.md",
11+
"reference/domains.md",
912
"reference/dynamic_variables.md",
1013
"reference/algebraic_functions.md",
1114
"reference/differential_functions.md",
@@ -14,6 +17,10 @@ const _PAGES = [
1417
],
1518
]
1619

20+
links = InterLinks(
21+
"MathOptInterface" => "https://jump.dev/MathOptInterface.jl/stable/objects.inv"
22+
)
23+
1724
makedocs(;
1825
modules=[DynOptInterface],
1926
authors="Eduardo M. G. Vila <72969764+e-duar-do@users.noreply.github.com> and contributors",
@@ -24,6 +31,7 @@ makedocs(;
2431
assets=String[],
2532
),
2633
pages=_PAGES,
34+
plugins=[links],
2735
)
2836

2937
deploydocs(;

docs/src/reference/abstractions.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
```@meta
2+
CurrentModule = DynOptInterface
3+
```
4+
5+
# Abstractions
6+
7+
The following are sub-types of [`AbstractDynamicFunction`](@ref):
8+
9+
* [`AbstractAlgebraicFunction`](@ref)
10+
* ``t_i`` [`DomainIndex`](@ref)
11+
* ``t_i \mapsto y_j(t_i)`` [`DynamicVariableIndex`](@ref)
12+
* ``t_i \mapsto a(y(t_i), t_i, x)`` [`NonlinearAlgebraicFunction`](@ref)
13+
* [`AbstractDifferentialFunction`](@ref)
14+
* ``t_i \mapsto \dot{y}_j(t_i)`` [`DynamicVariableDerivative`](@ref)
15+
* ``t_i \mapsto \dot{y}_j(t_i) - a(y(t_i), t_i, x)`` [`ExplicitDifferentialFunction`](@ref)
16+
* ``t_i \mapsto r(\dot{y}(t_i), y(t_i), t_i, x)`` [`NonlinearDifferentialFunction`](@ref)
17+
* [`AbstractBoundaryFunction`](@ref)
18+
* ``t_i^0, t_i^f`` [`DomainInitial`](@ref), [`DomainFinal`](@ref)
19+
* ``y_j(t_i^0), y_j(t_i^f)`` [`DynamicVariableInitial`](@ref), [`DynamicVariableFinal`](@ref)
20+
* ``b(y(t^0), y(t^f), t^0, t^f, x)`` [`NonlinearBoundaryFunction`](@ref)
21+
* ``\int_{t_i^0}^{t_i^f} a(y(t_i), t_i, x) \mathrm{d}t_i`` [`IntegralFunction`](@ref)
22+
* ``b(y(t_i^0), y(t_i^f), t_i^0, t_i^f, x) + \int_{t_i^0}^{t_i^f} a(y(t_i), t_i, x) \mathrm{d}t_i`` [`BolzaFunction`](@ref)
23+
24+
```@docs
25+
AbstractDynamicFunction
26+
AbstractAlgebraicFunction
27+
AbstractDifferentialFunction
28+
AbstractBoundaryFunction
29+
```

docs/src/reference/boundary_functions.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ CurrentModule = DynOptInterface
55
# Boundary Functions
66

77
```@docs
8-
AbstractBoundaryFunction
98
DomainInitial
109
DomainFinal
11-
DifferentialVariableInitial
12-
DifferentialVariableFinal
10+
DynamicVariableInitial
11+
DynamicVariableFinal
1312
NonlinearBoundaryFunction
14-
NonlinearLinkageFunction
1513
```

docs/src/reference/differential_functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CurrentModule = DynOptInterface
55
# Differential Functions
66

77
```@docs
8-
DifferentialVariableDerivative
8+
DynamicVariableDerivative
99
ExplicitDifferentialFunction
1010
NonlinearDifferentialFunction
1111
```

docs/src/reference/domains.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
```@meta
2+
CurrentModule = DynOptInterface
3+
```
4+
5+
# Domains
6+
7+
```@docs
8+
DomainIndex
9+
supports_domain
10+
UnsupportedDomain
11+
AddDomainNotAllowed
12+
add_domain
13+
```

docs/src/reference/dynamic_variables.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ CurrentModule = DynOptInterface
55
# Dynamic Variables
66

77
```@docs
8-
AbstractDynamicFunction
9-
AbstractAlgebraicFunction
10-
DomainIndex
11-
AlgebraicVariableIndex
12-
DifferentialVariableIndex
8+
DynamicVariableIndex
9+
supports_dynamic_variable
10+
UnsupportedDynamicVariable
11+
AddDynamicVariableNotAllowed
12+
add_dynamic_variable
1313
```

src/DynOptInterface.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ module DynOptInterface
22

33
import MathOptInterface as MOI
44

5+
include("abstractions.jl")
6+
include("domains.jl")
57
include("dynamic_variables.jl")
68
include("algebraic_functions.jl")
79
include("differential_functions.jl")
810
include("boundary_functions.jl")
911
include("integral_functions.jl")
12+
include("print.jl")
1013

1114

1215
end

src/abstractions.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
AbstractDynamicFunction <: MOI.AbstractScalarFunction
3+
4+
Abstract supertype for dynamic functions.
5+
"""
6+
abstract type AbstractDynamicFunction <: MOI.AbstractScalarFunction end
7+
8+
"""
9+
AbstractAlgebraicFunction <: AbstractDynamicFunction
10+
11+
Abstract supertype for algebraic functions.
12+
"""
13+
abstract type AbstractAlgebraicFunction <: AbstractDynamicFunction end
14+
15+
"""
16+
AbstractDifferentialFunction <: AbstractDynamicFunction
17+
18+
Abstract supertype for differential functions.
19+
"""
20+
abstract type AbstractDifferentialFunction <: AbstractDynamicFunction end
21+
22+
"""
23+
AbstractBoundaryFunction <: AbstractDynamicFunction
24+
25+
Abstract supertype for dynamic functions evaluated at the domain boundaries.
26+
"""
27+
abstract type AbstractBoundaryFunction <: AbstractDynamicFunction end

src/algebraic_functions.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22
NonlinearAlgebraicFunction <: AbstractAlgebraicFunction
33
44
```math
5-
f(y(\\cdot), u(\\cdot), t, x)
5+
t_i \\mapsto a(y(t_i), t_i, x)
66
```
7-
Supports:
8-
* [`DifferentialVariableIndex`](@ref)
9-
* [`AlgebraicVariableIndex`](@ref)
10-
* [`DomainIndex`](@ref)
11-
* [`NonlinearAlgebraicFunction`](@ref)
12-
* `MOI.ScalarNonlinearFunction`
7+
Similar to [`MathOptInterface.ScalarNonlinearFunction`](@ref),
8+
9+
Each node in `args` can be one of the following:
10+
* A constant value of type `T<:Real`
11+
* A [`MathOptInterface.VariableIndex`](@extref)
12+
* A [`DomainIndex`](@ref)
13+
* A [`DynamicVariableIndex`](@ref)
14+
* Another [`NonlinearAlgebraicFunction`](@ref)
1315
"""
1416
struct NonlinearAlgebraicFunction <: AbstractAlgebraicFunction
17+
domain::DomainIndex
1518
head::Symbol
1619
args::Vector{Any}
20+
21+
#=function NonlinearAlgebraicFunction(head::Symbol, args::AbstractVector)
22+
23+
# Check that all dynamic functions share the same domain index
24+
25+
return new(head, convert(Vector{Any}, args))
26+
end=#
1727
end

src/boundary_functions.jl

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
"""
2-
AbstractBoundaryFunction <: AbstractDynamicFunction
3-
4-
Abstract supertype for dynamic functions evaluated at the domain boundaries.
5-
"""
6-
abstract type AbstractBoundaryFunction <: AbstractDynamicFunction end
7-
81
"""
92
DomainInitial <: AbstractBoundaryFunction
103
4+
```math
5+
t_i^0
6+
```
117
Represents the initial point of a [`DomainIndex`](@ref).
128
"""
139
struct DomainInitial <: AbstractBoundaryFunction
@@ -17,55 +13,58 @@ end
1713
"""
1814
DomainFinal <: AbstractBoundaryFunction
1915
16+
```math
17+
t_i^f
18+
```
2019
Represents the final point of a [`DomainIndex`](@ref).
2120
"""
2221
struct DomainFinal <: AbstractBoundaryFunction
2322
index::DomainIndex
2423
end
2524

2625
"""
27-
DifferentialVariableInitial <: AbstractBoundaryFunction
26+
DynamicVariableInitial <: AbstractBoundaryFunction
2827
29-
Represents a [`DifferentialVariableIndex`](@ref) evaluated at the initial point of its [`DomainIndex`](@ref)
28+
```math
29+
y_j(t_i^0)
30+
```
31+
Represents a [`DynamicVariableIndex`](@ref) evaluated at the initial point of its [`DomainIndex`](@ref)
3032
"""
31-
struct DifferentialVariableInitial <: AbstractBoundaryFunction
32-
index::DifferentialVariableIndex
33+
struct DynamicVariableInitial <: AbstractBoundaryFunction
34+
variable_index::DynamicVariableIndex
3335
end
3436

3537
"""
36-
DifferentialVariableFinal <: AbstractBoundaryFunction
38+
DynamicVariableFinal <: AbstractBoundaryFunction
3739
38-
Represents a [`DifferentialVariableIndex`](@ref) evaluated at the final point of its [`DomainIndex`](@ref)
40+
```math
41+
y_j(t_i^f)
42+
```
43+
Represents a [`DynamicVariableIndex`](@ref) evaluated at the final point of its [`DomainIndex`](@ref)
3944
"""
40-
struct DifferentialVariableFinal <: AbstractBoundaryFunction
41-
index::DifferentialVariableIndex
45+
struct DynamicVariableFinal <: AbstractBoundaryFunction
46+
variable_index::DynamicVariableIndex
4247
end
4348

4449
"""
4550
NonlinearBoundaryFunction <: AbstractBoundaryFunction
51+
52+
```math
53+
b(y_j(t^0), y_j(t^f), t^0, t^f, x)
54+
```
55+
Similar to [`MathOptInterface.ScalarNonlinearFunction`](@extref),
4656
47-
Represents a general
48-
Supports:
49-
* [`DifferentialVariableInitial`](@ref)
50-
* [`DifferentialVariableFinal`](@ref)
51-
* [`DomainInitial`](@ref)
52-
* [`DomainFinal`](@ref)
53-
* [`NonlinearBoundaryFunction`](@ref)
54-
* `MOI.ScalarNonlinearFunction`
57+
Each node in `args` can be one of the following:
58+
* A constant value of type `T<:Real`
59+
* A [`MathOptInterface.VariableIndex`](@extref)
60+
* A [`DomainInitial`](@ref)
61+
* A [`DomainFinal`](@ref)
62+
* A [`DynamicVariableInitial`](@ref)
63+
* A [`DynamicVariableFinal`](@ref)
64+
* Another [`NonlinearBoundaryFunction`](@ref)
5565
"""
5666
struct NonlinearBoundaryFunction <: AbstractBoundaryFunction
5767
head::Symbol
5868
args::Vector{Any}
5969
# Inner constructor to enforce rules
60-
end
61-
62-
"""
63-
NonlinearLinkageFunction
64-
65-
Similar to [`NonlinearBoundaryFunction`](@ref) but with different domains allowed.
66-
"""
67-
struct NonlinearLinkageFunction <: AbstractDynamicFunction
68-
head::Symbol
69-
args::Vector{Any}
70-
# Inner constructor to enforce rules
7170
end

0 commit comments

Comments
 (0)