Skip to content

Commit 268757a

Browse files
authored
Merge pull request #18 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents 50af0af + fbfb9d2 commit 268757a

File tree

8 files changed

+58
-22
lines changed

8 files changed

+58
-22
lines changed

src/constraints.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ end
171171
constraint(ocp::Model, label::Symbol)::Tuple = ocp.constraints.dict[label]
172172

173173
(
174-
path_constraints_nl(ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP, TV1, TB, TS, TC, TV2, ConstraintsDictType}})::TP
174+
path_constraints_nl(
175+
ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP,TV1,TB,TS,TC,TV2,ConstraintsDictType}}
176+
)::TP
175177
) where {
176178
T<:TimesModel,
177179
S<:AbstractStateModel,
@@ -188,7 +190,9 @@ constraint(ocp::Model, label::Symbol)::Tuple = ocp.constraints.dict[label]
188190
} = ocp.constraints.path_nl
189191

190192
(
191-
variable_constraints_nl(ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP, TV1, TB, TS, TC, TV2, ConstraintsDictType}})::TV1
193+
variable_constraints_nl(
194+
ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP,TV1,TB,TS,TC,TV2,ConstraintsDictType}}
195+
)::TV1
192196
) where {
193197
T<:TimesModel,
194198
S<:AbstractStateModel,
@@ -205,7 +209,9 @@ constraint(ocp::Model, label::Symbol)::Tuple = ocp.constraints.dict[label]
205209
} = ocp.constraints.variable_nl
206210

207211
(
208-
boundary_constraints_nl(ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP, TV1, TB, TS, TC, TV2, ConstraintsDictType}})::TB
212+
boundary_constraints_nl(
213+
ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP,TV1,TB,TS,TC,TV2,ConstraintsDictType}}
214+
)::TB
209215
) where {
210216
T<:TimesModel,
211217
S<:AbstractStateModel,
@@ -222,7 +228,9 @@ constraint(ocp::Model, label::Symbol)::Tuple = ocp.constraints.dict[label]
222228
} = ocp.constraints.boundary_nl
223229

224230
(
225-
state_constraints_box(ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP, TV1, TB, TS, TC, TV2, ConstraintsDictType}})::TS
231+
state_constraints_box(
232+
ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP,TV1,TB,TS,TC,TV2,ConstraintsDictType}}
233+
)::TS
226234
) where {
227235
T<:TimesModel,
228236
S<:AbstractStateModel,
@@ -239,7 +247,9 @@ constraint(ocp::Model, label::Symbol)::Tuple = ocp.constraints.dict[label]
239247
} = ocp.constraints.state_box
240248

241249
(
242-
control_constraints_box(ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP, TV1, TB, TS, TC, TV2, ConstraintsDictType}})::TC
250+
control_constraints_box(
251+
ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP,TV1,TB,TS,TC,TV2,ConstraintsDictType}}
252+
)::TC
243253
) where {
244254
T<:TimesModel,
245255
S<:AbstractStateModel,
@@ -256,7 +266,9 @@ constraint(ocp::Model, label::Symbol)::Tuple = ocp.constraints.dict[label]
256266
} = ocp.constraints.control_box
257267

258268
(
259-
variable_constraints_box(ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP, TV1, TB, TS, TC, TV2, ConstraintsDictType}})::TV2
269+
variable_constraints_box(
270+
ocp::Model{T,S,C,V,D,O,ConstraintsModel{TP,TV1,TB,TS,TC,TV2,ConstraintsDictType}}
271+
)::TV2
260272
) where {
261273
T<:TimesModel,
262274
S<:AbstractStateModel,

src/control.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function control!(
8181
__is_control_set(ocp) &&
8282
throw(CTBase.UnauthorizedCall("the control has already been set."))
8383

84-
(m > 0) && (size(components_names, 1) m) &&
84+
(m > 0) &&
85+
(size(components_names, 1) m) &&
8586
throw(
8687
CTBase.IncorrectArgument(
8788
"the number of control names must be equal to the control dimension"

src/model.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
function build_constraints(constraints::ConstraintsDictType)::ConstraintsModel
2-
32
path_cons_nl_f = Vector{Function}() # nonlinear path constraints
43
path_cons_nl_dim = Vector{Int}()
54
path_cons_nl_lb = Vector{ctNumber}()
@@ -116,9 +115,8 @@ function build_constraints(constraints::ConstraintsDictType)::ConstraintsModel
116115
(state_cons_box_lb, state_cons_box_ind, state_cons_box_ub),
117116
(control_cons_box_lb, control_cons_box_ind, control_cons_box_ub),
118117
(variable_cons_box_lb, variable_cons_box_ind, variable_cons_box_ub),
119-
constraints
118+
constraints,
120119
)
121-
122120
end
123121

124122
function build_model(pre_ocp::PreModel)::Model

src/state.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ function state!(
8080
# checkings
8181
__is_state_set(ocp) && throw(CTBase.UnauthorizedCall("the state has already been set."))
8282

83-
(n > 0) && (size(components_names, 1) n) &&
83+
(n > 0) &&
84+
(size(components_names, 1) n) &&
8485
throw(
8586
CTBase.IncorrectArgument(
8687
"the number of state names must be equal to the state dimension"

src/types.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,15 @@ $(TYPEDEF)
206206
207207
$(TYPEDFIELDS)
208208
"""
209-
struct ConstraintsModel{TP<:Tuple, TV1<:Tuple, TB<:Tuple, TS<:Tuple, TC<:Tuple, TV2<:Tuple, TC_ALL<:ConstraintsDictType} <: AbstractConstraintsModel
209+
struct ConstraintsModel{
210+
TP<:Tuple,
211+
TV1<:Tuple,
212+
TB<:Tuple,
213+
TS<:Tuple,
214+
TC<:Tuple,
215+
TV2<:Tuple,
216+
TC_ALL<:ConstraintsDictType,
217+
} <: AbstractConstraintsModel
210218
path_nl::TP
211219
variable_nl::TV1
212220
boundary_nl::TB

src/variable.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function variable!(
4848
__is_variable_set(ocp) &&
4949
throw(CTBase.UnauthorizedCall("the variable has already been set."))
5050

51-
(q > 0) && (size(components_names, 1) q) &&
51+
(q > 0) &&
52+
(size(components_names, 1) q) &&
5253
throw(
5354
CTBase.IncorrectArgument(
5455
"the number of variable names must be equal to the variable dimension"

test/test_constraints.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
function test_constraints()
2-
32
= Vector{Float64}()
43

54
# From PreModel

test/test_ocp.jl

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ function test_ocp()
4545

4646
# path constraint
4747
f_path_a(r, t, x, u, v) = r .= x .+ u .+ v .+ t
48-
CTModels.__constraint!(pre_constraints, :path, n, m, q; f=f_path_a, lb=[0, 1], ub=[1, 2])
48+
CTModels.__constraint!(
49+
pre_constraints, :path, n, m, q; f=f_path_a, lb=[0, 1], ub=[1, 2]
50+
)
4951
f_path_b(r, t, x, u, v) = r .= x[1] + u[1] + v[1] + t
5052
CTModels.__constraint!(pre_constraints, :path, n, m, q; f=f_path_b, lb=[3], ub=[3])
5153

@@ -55,15 +57,19 @@ function test_ocp()
5557
pre_constraints, :boundary, n, m, q; f=f_boundary_a, lb=[0, 1], ub=[1, 2]
5658
)
5759
f_boundary_b(r, x0, xf, v) = r .= x0[1] - 1.0 + v[1] * (xf[1] - x0[1])
58-
CTModels.__constraint!(pre_constraints, :boundary, n, m, q; f=f_boundary_b, lb=[3], ub=[3])
60+
CTModels.__constraint!(
61+
pre_constraints, :boundary, n, m, q; f=f_boundary_b, lb=[3], ub=[3]
62+
)
5963

6064
# variable constraint
6165
f_variable_a(r, v) = r .= 2v
6266
CTModels.__constraint!(
6367
pre_constraints, :variable, n, m, q; f=f_variable_a, lb=[0, 1], ub=[1, 2]
6468
)
6569
f_variable_b(r, v) = r .= v[1] - 1.0
66-
CTModels.__constraint!(pre_constraints, :variable, n, m, q; f=f_variable_b, lb=[3], ub=[3])
70+
CTModels.__constraint!(
71+
pre_constraints, :variable, n, m, q; f=f_variable_b, lb=[3], ub=[3]
72+
)
6773

6874
# state box constraint
6975
CTModels.__constraint!(pre_constraints, :state, n, m, q; lb=[0, 1], ub=[1, 2])
@@ -156,11 +162,21 @@ function test_ocp()
156162
# Get all constraints and test. Be careful, the order is not guaranteed.
157163
# We will check up to permutations by sorting the results.
158164
(path_cons_nl_lb, path_cons_nl!, path_cons_nl_ub) = CTModels.path_constraints_nl(ocp)
159-
(variable_cons_nl_lb, variable_cons_nl!, variable_cons_nl_ub) = CTModels.variable_constraints_nl(ocp)
160-
(boundary_cons_nl_lb, boundary_cons_nl!, boundary_cons_nl_ub) = CTModels.boundary_constraints_nl(ocp)
161-
(state_cons_box_lb, state_cons_box_ind, state_cons_box_ub) = CTModels.state_constraints_box(ocp)
162-
(control_cons_box_lb, control_cons_box_ind, control_cons_box_ub) = CTModels.control_constraints_box(ocp)
163-
(variable_cons_box_lb, variable_cons_box_ind, variable_cons_box_ub) = CTModels.variable_constraints_box(ocp)
165+
(variable_cons_nl_lb, variable_cons_nl!, variable_cons_nl_ub) = CTModels.variable_constraints_nl(
166+
ocp
167+
)
168+
(boundary_cons_nl_lb, boundary_cons_nl!, boundary_cons_nl_ub) = CTModels.boundary_constraints_nl(
169+
ocp
170+
)
171+
(state_cons_box_lb, state_cons_box_ind, state_cons_box_ub) = CTModels.state_constraints_box(
172+
ocp
173+
)
174+
(control_cons_box_lb, control_cons_box_ind, control_cons_box_ub) = CTModels.control_constraints_box(
175+
ocp
176+
)
177+
(variable_cons_box_lb, variable_cons_box_ind, variable_cons_box_ub) = CTModels.variable_constraints_box(
178+
ocp
179+
)
164180

165181
# path constraints
166182
@test sort(path_cons_nl_lb) == [0, 1, 3]

0 commit comments

Comments
 (0)