Skip to content

Commit 668d09e

Browse files
authored
Merge pull request #467 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents f63aa41 + a5b8b76 commit 668d09e

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

ext/CTDirectExtExa.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,26 @@ function CTDirect.build_nlp!(
3636
# set initial guess (NB. do not broadcast, apparently fails on GPU arrays)
3737
# NB unused final control in examodel / euler, hence the different x0 sizes
3838
build_exa = CTModels.get_build_examodel(docp.ocp)
39-
40-
ocp = docp.ocp
39+
40+
ocp = docp.ocp
4141
n = CTModels.state_dimension(ocp)
4242
m = CTModels.control_dimension(ocp)
4343
q = CTModels.variable_dimension(ocp)
4444
state = hcat([x0[(1 + i * (n + m)):(1 + i * (n + m) + n - 1)] for i in 0:grid_size]...) # grid_size + 1 states
45-
control = hcat([x0[(n + 1 + i * (n + m)):(n + 1 + i * (n + m) + m - 1)] for i in 0:(grid_size - 1)]...) # grid_size controls...
45+
control = hcat(
46+
[
47+
x0[(n + 1 + i * (n + m)):(n + 1 + i * (n + m) + m - 1)] for
48+
i in 0:(grid_size - 1)
49+
]...,
50+
) # grid_size controls...
4651
control = [control control[:, end]] # ... todo: pass indeed to grid_size only for euler(_b), trapeze and midpoint
47-
variable = x0[end - q + 1:end]
48-
docp.nlp, docp.exa_getter = build_exa(; grid_size=grid_size, backend=exa_backend, scheme=disc_method, init=(variable, state, control))
52+
variable = x0[(end - q + 1):end]
53+
docp.nlp, docp.exa_getter = build_exa(;
54+
grid_size=grid_size,
55+
backend=exa_backend,
56+
scheme=disc_method,
57+
init=(variable, state, control),
58+
)
4959
# remark: docp.nlp.meta.x0[1:docp.dim_NLP_variables] = -vcat(state..., control..., variable) # also work, and supersedes previous init via ExaModels start (itself overridden by init in solve)
5060
return nothing
5161
end

src/disc/common.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#= Common parts for the discretization =#
32

43
"""

test/problems/beam.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ function beam2()
3232
end
3333

3434
return ((ocp=beam2, obj=8.898598, name="beam2", init=nothing))
35-
end
35+
end

test/problems/double_integrator.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function double_integrator_mintf2()
3636
return ((ocp=ocp, obj=2.0, name="double_integrator_tf2", init=nothing))
3737
end
3838

39-
4039
# min energy with fixed tf
4140
function double_integrator_minenergy(T=2)
4241
@def ocp begin

test/suite/test_exa.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if !isdefined(Main, :goddard2)
1212
include("../problems/goddard.jl")
1313
end
1414

15-
1615
# test_exa for all backends (CPU + GPU)
1716
function test_exa(exa_backend, display)
1817

@@ -52,7 +51,7 @@ function test_exa(exa_backend, display)
5251
disc_method=:trapeze,
5352
exa_backend=exa_backend,
5453
display=display,
55-
grid_size=1000
54+
grid_size=1000,
5655
)
5756
@test sol.objective prob.obj rtol = 1e-2
5857
end
@@ -70,7 +69,7 @@ function test_exa(exa_backend, display)
7069
exa_backend=exa_backend,
7170
grid_size=4,
7271
display=display,
73-
init=(state=[xi1, xi2], control=ui,),
72+
init=(state=[xi1, xi2], control=ui),
7473
max_iter=0,
7574
)
7675
@test control(sol)(0.5) == ui
@@ -96,7 +95,6 @@ function test_exa(exa_backend, display)
9695
docp = direct_transcription(prob.ocp, :madnlp, :exa; display=display, grid_size=100)
9796
@test docp.dim_NLP_variables == 303
9897
end
99-
10098
end
10199

102100
# CPU tests
@@ -111,4 +109,4 @@ if CUDA.functional()
111109
test_exa(CUDABackend(), display) # GPU tests
112110
else
113111
println("********** CUDA not available, skipping GPU tests")
114-
end
112+
end

test/suite/test_initial_guess.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ end
7171
@test isapprox(control(sol).(T), (t -> u_const).(T), rtol=1e-2)
7272
end
7373
@testset verbose = true showtiming = true ":constant_xu" begin
74-
sol = solve(prob2.ocp, display=false, init=(state=x_const, control=u_const), max_iter=maxiter)
74+
sol = solve(
75+
prob2.ocp, display=false, init=(state=x_const, control=u_const), max_iter=maxiter
76+
)
7577
T = time_grid(sol)
7678
@test isapprox(state(sol).(T), (t -> x_const).(T), rtol=1e-2)
7779
@test isapprox(control(sol).(T), (t -> u_const).(T), rtol=1e-2)
@@ -123,7 +125,9 @@ end
123125
@test isapprox(control(sol).(T), u_func.(T), rtol=1e-2)
124126
end
125127
@testset verbose = true showtiming = true ":functional_xu" begin
126-
sol = solve(prob2.ocp, display=false, init=(state=x_func, control=u_func), max_iter=maxiter)
128+
sol = solve(
129+
prob2.ocp, display=false, init=(state=x_func, control=u_func), max_iter=maxiter
130+
)
127131
T = time_grid(sol)
128132
@test isapprox(state(sol).(T), x_func.(T), rtol=1e-2)
129133
@test isapprox(control(sol).(T), u_func.(T), rtol=1e-2)

0 commit comments

Comments
 (0)