Skip to content

Commit 0cdaf5b

Browse files
committed
added attributes
1 parent e6a50fb commit 0cdaf5b

17 files changed

+314
-34
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🦖DynOptInterface
22

3-
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuDO-dev.github.io/DynOptInterface.jl/stable/)
3+
<!-- [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuDO-dev.github.io/DynOptInterface.jl/stable/) -->
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuDO-dev.github.io/DynOptInterface.jl/dev/)
55
[![Build Status](https://github.com/JuDO-dev/DynOptInterface.jl/actions/workflows/CI.yml/badge.svg?branch=dev)](https://github.com/JuDO-dev/DynOptInterface.jl/actions/workflows/CI.yml?query=branch%3Adev)
6-
[![Coverage](https://codecov.io/gh/JuDO-dev/DynOptInterface.jl/branch/dev/graph/badge.svg)](https://codecov.io/gh/JuDO-dev/DynOptInterface.jl)
6+
<!-- [![Coverage](https://codecov.io/gh/JuDO-dev/DynOptInterface.jl/branch/dev/graph/badge.svg)](https://codecov.io/gh/JuDO-dev/DynOptInterface.jl) -->

docs/make.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using DynOptInterface
1+
import DynOptInterface
22
using Documenter
33
using DocumenterInterLinks
44

5-
DocMeta.setdocmeta!(DynOptInterface, :DocTestSetup, :(using DynOptInterface); recursive=true)
5+
DocMeta.setdocmeta!(DynOptInterface, :DocTestSetup, :(import DynOptInterface as DOI); recursive=true)
66

77
const _PAGES = [
88
"Home" => "index.md",

docs/src/reference/abstractions.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,18 @@ CurrentModule = DynOptInterface
44

55
# Abstractions
66

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-
* ``a(y(t_i^0), t_i^0, x)`` [`Initial`](@ref)
19-
* ``a(y(t_i^f), t_i^f, x)`` [`Final`](@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)
7+
## Functions
238

249
```@docs
2510
AbstractDynamicFunction
2611
AbstractAlgebraicFunction
2712
AbstractDifferentialFunction
2813
AbstractBoundaryFunction
14+
```
15+
16+
## Attributes
17+
18+
```@docs
19+
AbstractDomainAttribute
20+
AbstractDynamicVariableAttribute
2921
```

docs/src/reference/algebraic_functions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ CurrentModule = DynOptInterface
44

55
# Algebraic Functions
66

7+
## Types
8+
79
```@docs
10+
LinearAlgebraicTerm
11+
LinearAlgebraicFunction
12+
SquaredAlgebraicTerm
13+
SquaredAlgebraicFunction
814
NonlinearAlgebraicFunction
915
```

docs/src/reference/domains.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,30 @@ CurrentModule = DynOptInterface
44

55
# Domains
66

7+
## Type
8+
79
```@docs
810
DomainIndex
11+
```
12+
13+
## Attributes
14+
```@docs
15+
DomainName
16+
DomainInitialPrimalStart
17+
DomainFinalPrimalStart
18+
DomainInitialPrimal
19+
DomainFinalPrimal
20+
```
21+
22+
## Functions
23+
24+
```@docs
925
supports_domain
26+
add_domain
27+
```
28+
29+
## Errors
30+
```@docs
1031
UnsupportedDomain
1132
AddDomainNotAllowed
12-
add_domain
1333
```

docs/src/reference/dynamic_variables.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,29 @@ CurrentModule = DynOptInterface
44

55
# Dynamic Variables
66

7+
## Type
8+
79
```@docs
810
DynamicVariableIndex
11+
```
12+
13+
## Attributes
14+
```@docs
15+
DynamicVariableName
16+
DynamicVariablePrimalStart
17+
DynamicVariablePrimal
18+
```
19+
20+
## Functions
21+
22+
```@docs
923
supports_dynamic_variable
24+
add_dynamic_variable
25+
```
26+
27+
## Errors
28+
29+
```@docs
1030
UnsupportedDynamicVariable
1131
AddDynamicVariableNotAllowed
12-
add_dynamic_variable
1332
```

src/abstractions.jl

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,53 @@ abstract type AbstractDynamicFunction <: MOI.AbstractScalarFunction end
88
"""
99
AbstractAlgebraicFunction <: AbstractDynamicFunction
1010
11-
Abstract supertype for algebraic functions.
11+
Abstract supertype for algebraic functions. That is, expressions that may contain
12+
``y(t)`` or ``t``, but not ``\\dot{y}(t)``.
1213
"""
1314
abstract type AbstractAlgebraicFunction <: AbstractDynamicFunction end
1415

1516
"""
1617
AbstractDifferentialFunction <: AbstractDynamicFunction
1718
18-
Abstract supertype for differential functions.
19+
Abstract supertype for differential functions. That is, expressions that may contain
20+
``\\dot{y}(t)``, ``y(t)``, or ``t``.
1921
"""
2022
abstract type AbstractDifferentialFunction <: AbstractDynamicFunction end
2123

2224
"""
2325
AbstractBoundaryFunction <: AbstractDynamicFunction
2426
25-
Abstract supertype for dynamic functions evaluated at the domain boundaries.
27+
Abstract supertype for functions evaluated at domain boundaries. That is,
28+
expressions that may contain ``y(t^0)``, ``y(t^f)``, ``t^0``, or ``t^f``.
2629
"""
27-
abstract type AbstractBoundaryFunction <: AbstractDynamicFunction end
30+
abstract type AbstractBoundaryFunction <: AbstractDynamicFunction end
31+
32+
"""
33+
AbstractDomainAttribute
34+
35+
Abstract supertype for attribute objects that can be used to set or get attributes
36+
(properties) of domains in the model.
37+
"""
38+
abstract type AbstractDomainAttribute end
39+
40+
"""
41+
AbstractDynamicVariableAttribute
42+
43+
Abstract supertype for attributs objects that can be used to set or get attributes
44+
(properties) of dynamic variables in the model.
45+
"""
46+
abstract type AbstractDynamicVariableAttribute end
47+
48+
const AnyDynamicAttribute = Union{
49+
AbstractDomainAttribute,
50+
AbstractDynamicVariableAttribute,
51+
}
52+
53+
function MOI.get(model::MOI.ModelLike, attr::AnyDynamicAttribute, args...)
54+
return throw(
55+
MOI.GetAttributeNotAllowed(
56+
attr,
57+
"$(typeof(model)) does not support getting the attribute $(attr).",
58+
)
59+
)
60+
end

src/algebraic_functions.jl

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,57 @@
1+
## Types
2+
3+
"""
4+
LinearAlgebraicTerm{T}
5+
6+
```math
7+
t_i \\mapsto c_j y_j(t_i)
8+
```
9+
"""
10+
struct LinearAlgebraicTerm{T}
11+
coefficient::T
12+
y_j::DynamicVariableIndex
13+
end
14+
15+
"""
16+
LinearAlgebraicFunction{T} <: AbstractAlgebraicFunction
17+
18+
```math
19+
t_i \\mapsto c^\\top y(t_i)
20+
```
21+
"""
22+
struct LinearAlgebraicFunction{T} <: AbstractAlgebraicFunction
23+
terms::Vector{LinearAlgebraicTerm{T}}
24+
end
25+
26+
"""
27+
SquaredAlgebraicTerm{T}
28+
29+
```math
30+
t_i \\mapsto y_j(t_i) c_{jk} y_k(t_i)
31+
```
32+
"""
33+
struct SquaredAlgebraicTerm{T}
34+
coefficient::T
35+
y_j::DynamicVariableIndex
36+
y_k::DynamicVariableIndex
37+
end
38+
39+
"""
40+
SquaredAlgebraicFunction{T}
41+
42+
```math
43+
t_i \\mapsto y(t_i)^\\top C y(t_i)
44+
```
45+
"""
46+
struct SquaredAlgebraicFunction{T}
47+
terms::Vector{SquaredAlgebraicTerm{T}}
48+
end
49+
150
"""
251
NonlinearAlgebraicFunction <: AbstractAlgebraicFunction
352
453
```math
5-
t_i \\mapsto a(y(t_i), t_i, x)
54+
t_i \\mapsto f_a(y(t_i), t_i, x)
655
```
756
Similar to [`MathOptInterface.ScalarNonlinearFunction`](@ref),
857

src/boundary_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const _NONLINEAR_BOUNDARY_TYPES = Union{
6161
NonlinearBoundaryFunction <: AbstractBoundaryFunction
6262
6363
```math
64-
b(y(t^0), y(t^f), t^0, t^f, x)
64+
f_b(y(t^0), y(t^f), t^0, t^f, x)
6565
```
6666
Similar to [`MathOptInterface.ScalarNonlinearFunction`](@extref),
6767

src/differential_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343
NonlinearDifferentialFunction <: AbstractDifferentialFunction
4444
4545
```math
46-
t_i \\mapsto r(\\dot{y}(t_i), y(t_i), t_i, x)
46+
t_i \\mapsto f_d(\\dot{y}(t_i), y(t_i), t_i, x)
4747
```
4848
Similar to `MOI.ScalarNonlinearFunction`,
4949

0 commit comments

Comments
 (0)