Skip to content

Commit b6b567a

Browse files
authored
Merge pull request #512 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents c1a3b2d + 790d741 commit b6b567a

File tree

9 files changed

+36
-39
lines changed

9 files changed

+36
-39
lines changed

ext/CTDirectExtADNLP.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ Build the NLP model for the DOCP (ADNLPModels version)
1515
* `adnlp_backend`: backend for ADNLPModels ([`:optimized`], `:manual`, `:default`)
1616
"""
1717
function CTDirect.build_nlp!(
18-
docp::CTDirect.DOCP{
19-
<:CTDirect.Discretization,
20-
<:CTModels.Model,
21-
<:CTDirect.ADNLPBackend,
22-
},
18+
docp::CTDirect.DOCP{<:CTDirect.Discretization,<:CTModels.Model,<:CTDirect.ADNLPBackend},
2319
x0;
2420
adnlp_backend=CTDirect.__adnlp_backend(),
2521
show_time=false, #+default

ext/CTDirectExtExa.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ Build the NLP model for the DOCP (ExaModels version)
1717
* `exa_backend`: backend for ExaModels ([`nothing`])
1818
"""
1919
function CTDirect.build_nlp!(
20-
docp::CTDirect.DOCP{
21-
<:CTDirect.Discretization,
22-
<:CTModels.Model,
23-
<:CTDirect.ExaBackend,
24-
},
20+
docp::CTDirect.DOCP{<:CTDirect.Discretization,<:CTModels.Model,<:CTDirect.ExaBackend},
2521
x0;
2622
grid_size=CTDirect.__grid_size(),
2723
disc_method=CTDirect.__disc_method(),
@@ -76,7 +72,9 @@ Retrieve the time grid from the given DOCP solution.
7672
7773
- `::Vector{Float64}`: The time grid.
7874
"""
79-
function CTDirect.get_time_grid_exa(nlp_solution::SolverCore.AbstractExecutionStats, docp::CTDirect.DOCP)
75+
function CTDirect.get_time_grid_exa(
76+
nlp_solution::SolverCore.AbstractExecutionStats, docp::CTDirect.DOCP
77+
)
8078
grid = zeros(docp.time.steps+1)
8179
ocp = docp.ocp
8280

ext/CTDirectExtMadNLP.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ function CTDirect.solve_docp(
5050
return nlp_solution
5151
end
5252

53-
function CTDirect.SolverInfos(nlp_solution::MadNLP.MadNLPExecutionStats, nlp::NLPModels.AbstractNLPModel)
53+
function CTDirect.SolverInfos(
54+
nlp_solution::MadNLP.MadNLPExecutionStats, nlp::NLPModels.AbstractNLPModel
55+
)
5456
minimize = NLPModels.get_minimize(nlp)
5557
objective = minimize ? nlp_solution.objective : -nlp_solution.objective # sign depends on minimization for MadNLP
5658
iterations = nlp_solution.iter

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
"""

src/docp.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ julia> DOCP(ocp, nlp_model_backend)
294294
DOCP{...}(...)
295295
```
296296
"""
297-
mutable struct DOCP{D<:CTDirect.Discretization,O<:CTModels.Model,N<:CTDirect.AbstractNLPModelBackend}
297+
mutable struct DOCP{
298+
D<:CTDirect.Discretization,O<:CTModels.Model,N<:CTDirect.AbstractNLPModelBackend
299+
}
298300

299301
# discretization scheme
300302
discretization::D

src/solution.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ function build_OCP_solution(docp::DOCP, nlp_solution::SolverCore.AbstractExecuti
6161
nlp_model_backend = docp.nlp_model_backend
6262

6363
# retrieve data from NLP solver
64-
objective, iterations, constraints_violation, message, status, successful = SolverInfos(nlp_solution, nlp)
64+
objective, iterations, constraints_violation, message, status, successful = SolverInfos(
65+
nlp_solution, nlp
66+
)
6567

6668
# arrays (explicit conversion for GPU case)
6769
solution = Array(nlp_solution.solution)
@@ -161,7 +163,9 @@ julia> SolverInfos(nlp_solution)
161163
(1.23, 15, 1.0e-6, "Ipopt/generic", :first_order, true)
162164
```
163165
"""
164-
function SolverInfos(nlp_solution::SolverCore.AbstractExecutionStats, ::NLPModels.AbstractNLPModel)
166+
function SolverInfos(
167+
nlp_solution::SolverCore.AbstractExecutionStats, ::NLPModels.AbstractNLPModel
168+
)
165169
objective = nlp_solution.objective
166170
iterations = nlp_solution.iter
167171
constraints_violation = nlp_solution.primal_feas
@@ -398,7 +402,9 @@ julia> P, path_dual, bound_dual = parse_DOCP_solution_dual(docp, duals; nlp_mode
398402
([...] , [...], [...])
399403
```
400404
"""
401-
function parse_DOCP_solution_dual(docp, multipliers; nlp_model_backend=ADNLPBackend(), nlp_solution)
405+
function parse_DOCP_solution_dual(
406+
docp, multipliers; nlp_model_backend=ADNLPBackend(), nlp_solution
407+
)
402408

403409
# costate
404410
N = docp.time.steps

src/solve.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ ERROR: ExtensionError(...)
8080
```
8181
"""
8282
function build_nlp!(
83-
docp::CTDirect.DOCP{
84-
<:CTDirect.Discretization,
85-
<:CTModels.Model,
86-
T,
87-
}, x0; kwargs...
83+
docp::CTDirect.DOCP{<:CTDirect.Discretization,<:CTModels.Model,T}, x0; kwargs...
8884
) where {T<:AbstractNLPModelBackend}
8985
throw(CTBase.ExtensionError(WEAKDEPS[T]...))
9086
end
@@ -391,13 +387,7 @@ function direct_transcription(
391387
x0 = DOCP_initial_guess(docp, docp_init)
392388

393389
# build nlp
394-
build_nlp!(
395-
docp,
396-
x0;
397-
grid_size=grid_size,
398-
disc_method=disc_method,
399-
kwargs...,
400-
)
390+
build_nlp!(docp, x0; grid_size=grid_size, disc_method=disc_method, kwargs...)
401391

402392
return docp
403393
end

test/runtests.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ using CTBase
66
using CTParser: CTParser, @def
77
using CTModels:
88
CTModels, objective, state, control, variable, costate, time_grid, iterations, criterion
9-
using CTDirect: CTDirect, solve, direct_transcription, set_initial_guess, build_OCP_solution, nlp_model, ocp_model
9+
using CTDirect:
10+
CTDirect,
11+
solve,
12+
direct_transcription,
13+
set_initial_guess,
14+
build_OCP_solution,
15+
nlp_model,
16+
ocp_model
1017

1118
# activate NLP modelers
1219
using ADNLPModels

test/tmp/test_madnlp.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ senses = [:min, :max]
4747
solver_types = [:madnlp, :ipopt]
4848
problem_types = [:exa, :adnlp]
4949

50-
results = DataFrame(
51-
sense = String[],
52-
solver = String[],
53-
problem_type = String[],
54-
objective_value = Float64[],
50+
results = DataFrame(;
51+
sense=String[], solver=String[], problem_type=String[], objective_value=Float64[]
5552
)
5653

5754
for sense in senses
@@ -62,10 +59,10 @@ for sense in senses
6259
push!(
6360
results,
6461
(
65-
sense = String(sense),
66-
solver = String(solver_type),
67-
problem_type = String(problem_type),
68-
objective_value = objective_value,
62+
sense=String(sense),
63+
solver=String(solver_type),
64+
problem_type=String(problem_type),
65+
objective_value=objective_value,
6966
),
7067
)
7168
end

0 commit comments

Comments
 (0)