Skip to content

Commit 1d75646

Browse files
authored
Merge pull request #145 from control-toolbox/144-dev-ordinalrange
Replace unit range by range
2 parents d404af2 + cc1ff1e commit 1d75646

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/dynamics.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ subset of state indices specified by the range `rg`.
4747
4848
# Arguments
4949
- `ocp::PreModel`: The optimal control problem being defined.
50-
- `rg::AbstractUnitRange{<:Integer}`: Range of state indices to which `f` applies.
50+
- `rg::AbstractRange{<:Int}`: Range of state indices to which `f` applies.
5151
- `f::Function`: A function describing the dynamics over the specified state indices.
5252
5353
# Preconditions
@@ -72,7 +72,7 @@ julia> dynamics!(ocp, 1:2, (out, t, x, u, v) -> out .= x[1:2] .+ u[1:2])
7272
julia> dynamics!(ocp, 3:3, (out, t, x, u, v) -> out .= x[3] * v[1])
7373
```
7474
"""
75-
function dynamics!(ocp::PreModel, rg::AbstractUnitRange{<:Integer}, f::Function)::Nothing
75+
function dynamics!(ocp::PreModel, rg::AbstractRange{<:Int}, f::Function)::Nothing
7676
@ensure __is_state_set(ocp) CTBase.UnauthorizedCall(
7777
"the state must be set before the dynamics."
7878
)
@@ -168,7 +168,7 @@ Build a combined dynamics function from multiple parts.
168168
This function constructs an in-place dynamics function `dyn!` by composing several sub-functions, each responsible for updating a specific segment of the output vector.
169169
170170
# Arguments
171-
- `parts::Vector{<:Tuple{<:AbstractUnitRange{<:Integer}, <:Function}}`:
171+
- `parts::Vector{<:Tuple{<:AbstractRange{<:Int}, <:Function}}`:
172172
A vector of tuples, where each tuple contains:
173173
- A range specifying the indices in the output vector `val` that the corresponding function updates.
174174
- A function `f` with the signature `(output_segment, t, x, u, v)`, which updates the slice of `val` indicated by the range.
@@ -196,7 +196,7 @@ julia> println(val) # prints [1.5, 2.5, 6.0]
196196
```
197197
"""
198198
function __build_dynamics_from_parts(
199-
parts::Vector{<:Tuple{<:AbstractUnitRange{<:Integer},<:Function}}
199+
parts::Vector{<:Tuple{<:AbstractRange{<:Int},<:Function}}
200200
)::Function
201201
function dyn!(val, t, x, u, v)
202202
for (rg, f!) in parts

src/types.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ $(TYPEDFIELDS)
345345
control::Union{AbstractControlModel,Nothing} = nothing
346346
variable::AbstractVariableModel = EmptyVariableModel()
347347
dynamics::Union{
348-
Function,Vector{<:Tuple{<:AbstractUnitRange{<:Integer},<:Function}},Nothing
348+
Function,Vector{<:Tuple{<:AbstractRange{<:Int},<:Function}},Nothing
349349
} = nothing
350350
objective::Union{AbstractObjectiveModel,Nothing} = nothing
351351
constraints::ConstraintsDictType = ConstraintsDictType()
@@ -431,7 +431,7 @@ function __is_dynamics_complete(ocp::PreModel)::Bool
431431
return false
432432
elseif ocp.dynamics isa Function
433433
return true
434-
else # ocp.dynamics isa Vector{<:Tuple{<:AbstractUnitRange{<:Integer},<:Function}}
434+
else # ocp.dynamics isa Vector{<:Tuple{<:AbstractRange{<:Int},<:Function}}
435435
@ensure(__is_state_set(ocp), CTBase.UnauthorizedCall("the state must be set."))
436436
n = state_dimension(ocp)
437437
covered = falses(n)

0 commit comments

Comments
 (0)