Skip to content

Commit 175c94a

Browse files
authored
Merge pull request #143 from control-toolbox/141-dev-change-to-concrete-type
Replace ctNumber by concrete type
2 parents 1d75646 + 325ee33 commit 175c94a

2 files changed

Lines changed: 42 additions & 10 deletions

File tree

src/model.jl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,34 @@ model = build_constraints(constraints)
4949
```
5050
"""
5151
function build_constraints(constraints::ConstraintsDictType)::ConstraintsModel
52+
53+
LocalNumber = Float64
54+
5255
path_cons_nl_f = Vector{Function}() # nonlinear path constraints
5356
path_cons_nl_dim = Vector{Int}()
54-
path_cons_nl_lb = Vector{ctNumber}()
55-
path_cons_nl_ub = Vector{ctNumber}()
57+
path_cons_nl_lb = Vector{LocalNumber}()
58+
path_cons_nl_ub = Vector{LocalNumber}()
5659
path_cons_nl_labels = Vector{Symbol}()
5760

5861
boundary_cons_nl_f = Vector{Function}() # nonlinear boundary constraints
5962
boundary_cons_nl_dim = Vector{Int}()
60-
boundary_cons_nl_lb = Vector{ctNumber}()
61-
boundary_cons_nl_ub = Vector{ctNumber}()
63+
boundary_cons_nl_lb = Vector{LocalNumber}()
64+
boundary_cons_nl_ub = Vector{LocalNumber}()
6265
boundary_cons_nl_labels = Vector{Symbol}()
6366

6467
state_cons_box_ind = Vector{Int}() # state range
65-
state_cons_box_lb = Vector{ctNumber}()
66-
state_cons_box_ub = Vector{ctNumber}()
68+
state_cons_box_lb = Vector{LocalNumber}()
69+
state_cons_box_ub = Vector{LocalNumber}()
6770
state_cons_box_labels = Vector{Symbol}()
6871

6972
control_cons_box_ind = Vector{Int}() # control range
70-
control_cons_box_lb = Vector{ctNumber}()
71-
control_cons_box_ub = Vector{ctNumber}()
73+
control_cons_box_lb = Vector{LocalNumber}()
74+
control_cons_box_ub = Vector{LocalNumber}()
7275
control_cons_box_labels = Vector{Symbol}()
7376

7477
variable_cons_box_ind = Vector{Int}() # variable range
75-
variable_cons_box_lb = Vector{ctNumber}()
76-
variable_cons_box_ub = Vector{ctNumber}()
78+
variable_cons_box_lb = Vector{LocalNumber}()
79+
variable_cons_box_ub = Vector{LocalNumber}()
7780
variable_cons_box_labels = Vector{Symbol}()
7881

7982
for (label, c) in constraints

test/extras/dynamics.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using CTModels
2+
3+
partial_dyn_1!(r, t, x, u, v) = (@views r[1] .= x[1] + 2u[2])
4+
partial_dyn_2!(r, t, x, u, v) = (@views r[1] .= 2x[3])
5+
partial_dyn_3!(r, t, x, u, v) = (@views r[1] .= x[1] + u[2])
6+
7+
x = [1, 2, 3]
8+
u = [-1, 2]
9+
10+
parts = [
11+
(1:1, partial_dyn_1!),
12+
(2:2, partial_dyn_2!),
13+
(3:3, partial_dyn_3!),
14+
]
15+
16+
dyn! = CTModels.__build_dynamics_from_parts(parts)
17+
18+
r = zeros(3)
19+
dyn!(r, 0, x, u, nothing)
20+
21+
r - [x[1] + 2u[2], 2x[3], x[1] + u[2]]
22+
23+
###
24+
25+
r[1:1] .= 0
26+
27+
28+
x = [1, 2, 3]
29+
x[1] = 10

0 commit comments

Comments
 (0)