Skip to content

Commit

Permalink
added index types
Browse files Browse the repository at this point in the history
  • Loading branch information
e-duar-do committed May 7, 2024
1 parent 7f2b091 commit c5bc60a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const _PAGES = [
"Home" => "index.md",
"API Reference" => [
"reference/domains.md",
"reference/algebraic.md",
"reference/differentiable.md",
],
]

Expand Down
9 changes: 9 additions & 0 deletions docs/src/reference/algebraic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```@meta
CurrentModule = DynOptInterface
```

# Algebraic Variables

```@docs
AlgebraicIndex
```
9 changes: 9 additions & 0 deletions docs/src/reference/differentiable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```@meta
CurrentModule = DynOptInterface
```

# Differentiable Variables

```@docs
DifferentiableIndex
```
6 changes: 0 additions & 6 deletions docs/src/reference/domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@ CurrentModule = DynOptInterface
# Domains

```@docs
AbstractDomain
DomainIndex
supports_domain
UnsupportedDomain
AddDomainNotAllowed
add_domain
Interval
```
3 changes: 2 additions & 1 deletion src/DynOptInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module DynOptInterface

import MathOptInterface as MOI

include("domains.jl")
include("indices.jl")


end
16 changes: 16 additions & 0 deletions src/functions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ScalarNonlinearDOFunction(head::Sumbol, args::Vector{Any})
A scalar-valued nonlinear DO function `head(args...)`. Each argument must be one of the following:
* A constant value of type `T<:Real`
* An `MOI.VariableIndex`
* An `MOI.ScalarNonlinearFunction`
* A [`DomainIndex`](@ref)
* An [`AlgebraicIndex`](@ref)
* A [`DifferentiableIndex`](@ref)
"""
struct ScalarNonlinearDOFunction
head::Symbol
args::Vector{Any}
end
28 changes: 28 additions & 0 deletions src/indices.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
DomainIndex
A type-safe wrapper for `Int64` for use in referencing domains.
"""
struct DomainIndex
value::Int64
end

"""
AlgebraicIndex
A type-safe wrapper for `Int64` for use in referencing algebraic variables.
"""
struct AlgebraicIndex
value::Int64
domain::DomainIndex
end

"""
DifferentiableIndex
A type-safe wrapper for `Int64` for use in referencing differentiable variables.
"""
struct DifferentiableIndex
value::Int64
domain::DomainIndex
end

0 comments on commit c5bc60a

Please sign in to comment.