Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function generate_documentation(
nlp_oc_sol = NLPModelsIpopt.ipopt(nlp_oc; max_iter=0)

# Build OptimalControl solution
ocp_sol = build_ocp_solution(docp, nlp_oc_sol)
ocp_sol = build_OCP_solution(docp, nlp_oc_sol)

# get dimensions
n = state_dimension(ocp_oc)
Expand Down Expand Up @@ -292,7 +292,7 @@ function generate_documentation(
function print_numerical_comparisons(problem, docp, nlp_oc_sol, nlp_jp)

# get relevant data from OptimalControl model
ocp_sol = build_ocp_solution(docp, nlp_oc_sol)
ocp_sol = build_OCP_solution(docp, nlp_oc_sol)
t_oc = time_grid(ocp_sol)
x_oc = state(ocp_sol).(t_oc)
u_oc = control(ocp_sol).(t_oc)
Expand Down Expand Up @@ -376,7 +376,7 @@ function generate_documentation(

```@example main
# build an ocp solution to use the plot from OptimalControl package
ocp_sol = build_ocp_solution(docp, nlp_oc_sol)
ocp_sol = build_OCP_solution(docp, nlp_oc_sol)

# dimensions
n = state_dimension(ocp_sol)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorial-solve.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ nlp_sol.objective
To recover the state, control, and costate, we recommend building an optimal control solution and using the associated getters (you can also retrieve the number of iterations and the objective value from the OCP solution):

```@example main
ocp_sol = build_ocp_solution(docp, nlp_sol)
ocp_sol = build_OCP_solution(docp, nlp_sol)

t = time_grid(ocp_sol) # t0, ..., tN = tf
x = state(ocp_sol) # function of time
Expand Down
18 changes: 0 additions & 18 deletions src/OptimalControlProblems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ using OrderedCollections: OrderedDict
using SolverCore
import ADNLPModels: ADNLPModels, ADNLPModel

# -----------------
# SHOULD NO BE HERE ("triiiiiiiiiiiiiiit !!!" - bruit de sifflet)
function build_ocp_solution(
docp::CTDirect.DOCP, nlp_solution::SolverCore.AbstractExecutionStats
)
nlp_model_backend = if docp.nlp isa ADNLPModel
CTDirect.ADNLPBackend()
elseif docp.nlp isa ExaModel
CTDirect.ExaBackend()
else
throw(CTBase.IncorrectArgument("The NLP model is of unknown type."))
end
return CTDirect.build_OCP_solution(docp, nlp_solution; nlp_model=nlp_model_backend)
end

export build_ocp_solution
#

"""
$(TYPEDEF)

Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Ipopt = "1"
JuMP = "1"
MadNLPMumps = "0.5"
NLPModels = "0.21"
NLPModelsIpopt = "0.10"
NLPModelsIpopt = "0.11"
OptimalControl = "1"
Plots = "1"
Printf = "1"
Expand Down
Binary file modified test/figures/init/beam.pdf
Binary file not shown.
Binary file modified test/figures/init/chain.pdf
Binary file not shown.
Binary file modified test/figures/init/double_oscillator.pdf
Binary file not shown.
Binary file modified test/figures/init/ducted_fan.pdf
Binary file not shown.
Binary file modified test/figures/init/electric_vehicle.pdf
Binary file not shown.
Binary file modified test/figures/init/glider.pdf
Binary file not shown.
Binary file modified test/figures/init/insurance.pdf
Binary file not shown.
Binary file modified test/figures/init/jackson.pdf
Binary file not shown.
Binary file modified test/figures/init/robbins.pdf
Binary file not shown.
Binary file modified test/figures/init/robot.pdf
Binary file not shown.
Binary file modified test/figures/init/rocket.pdf
Binary file not shown.
Binary file modified test/figures/init/space_shuttle.pdf
Binary file not shown.
Binary file modified test/figures/init/steering.pdf
Binary file not shown.
Binary file modified test/figures/init/vanderpol.pdf
Binary file not shown.
Binary file modified test/figures/solution/beam.pdf
Binary file not shown.
Binary file modified test/figures/solution/chain.pdf
Binary file not shown.
Binary file modified test/figures/solution/double_oscillator.pdf
Binary file not shown.
Binary file modified test/figures/solution/ducted_fan.pdf
Binary file not shown.
Binary file modified test/figures/solution/electric_vehicle.pdf
Binary file not shown.
Binary file modified test/figures/solution/glider.pdf
Binary file not shown.
Binary file modified test/figures/solution/insurance.pdf
Binary file not shown.
Binary file modified test/figures/solution/jackson.pdf
Binary file not shown.
Binary file modified test/figures/solution/robbins.pdf
Binary file not shown.
Binary file modified test/figures/solution/robot.pdf
Binary file not shown.
Binary file modified test/figures/solution/rocket.pdf
Binary file not shown.
Binary file modified test/figures/solution/space_shuttle.pdf
Binary file not shown.
Binary file modified test/figures/solution/steering.pdf
Binary file not shown.
Binary file modified test/figures/solution/vanderpol.pdf
Binary file not shown.
28 changes: 16 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ const MAX_WALL_TIME = 500.0
list_of_problems = OptimalControlProblems.problems()

# Remove from the tests the following problems
# problems_to_exclude = [
# :bioreactor, # no need to remove here since already removed in OptimalControlProblems.jl
# :cart_pendulum, # no need to remove here since already removed in OptimalControlProblems.jl
# :dielectrophoretic_particle, # no need to remove here since already removed in OptimalControlProblems.jl
# :moonlander, # no need to remove here since already removed in OptimalControlProblems.jl
# ]
# list_of_problems = setdiff(list_of_problems, problems_to_exclude)
problems_to_exclude = [
# :bioreactor, # no need to remove here since already removed in OptimalControlProblems.jl
# :cart_pendulum, # no need to remove here since already removed in OptimalControlProblems.jl
# :dielectrophoretic_particle, # no need to remove here since already removed in OptimalControlProblems.jl
# :moonlander, # no need to remove here since already removed in OptimalControlProblems.jl
:ducted_fan,
:insurance,
:robot,
:space_shuttle,
]
list_of_problems = setdiff(list_of_problems, problems_to_exclude)

# list_of_problems = [
# :jackson,
Expand All @@ -55,8 +59,8 @@ const VERBOSE = true # print or not details during tests
:OptimalControl, # convergence tests for OptimalControl models
:OptimalControl_s, # convergence tests for OptimalControl models
:init, # comparison between OptimalControl and JuMP: init
# :solution, # comparison between OptimalControl and JuMP: solution
# :quick, # quick comparison: objective rel error only
:solution, # comparison between OptimalControl and JuMP: solution
:quick, # quick comparison: objective rel error only
:parameters, # tests with different parameters values, does no depend on `list_of_problems`
)
@testset "$(name)" verbose=VERBOSE begin
Expand All @@ -74,7 +78,7 @@ const VERBOSE = true # print or not details during tests
display(problems());
println()

@testset "available_problems" verbose=VERBOSE begin
@test LIST_OF_PROBLEMS_FINAL == problems()
end
# @testset "available_problems" verbose=VERBOSE begin
# @test LIST_OF_PROBLEMS_FINAL == problems()
# end
end
6 changes: 3 additions & 3 deletions test/test_quick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function test_quick()
)
nlp = nlp_model(docp)
nlp_sol = NLPModelsIpopt.ipopt(nlp; kwargs_ipopt...)
sol = build_ocp_solution(docp, nlp_sol)
sol = build_OCP_solution(docp, nlp_sol)
o_oc = objective(sol)

########## OptimalControl_s ##########
Expand All @@ -64,8 +64,8 @@ function test_quick()
nlp = nlp_model(docp)
ocp = ocp_model(docp)
nlp_sol = madnlp(nlp; kwargs_madnlp...)
sol = build_ocp_solution(docp, nlp_sol)
o_os = criterion(ocp) == :min ? objective(sol) : -objective(sol)
sol = build_OCP_solution(docp, nlp_sol)
o_os = objective(sol)

############### TEST ###############
DEBUG && println("├─ objective")
Expand Down
6 changes: 3 additions & 3 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function comparison(; max_iter, test_name)
nlp_oc = nlp_model(docp)
ocp_oc = ocp_model(docp)
nlp_sol = NLPModelsIpopt.ipopt(nlp_oc; options_ipopt...)
sol_oc = build_ocp_solution(docp, nlp_sol)
sol_oc = build_OCP_solution(docp, nlp_sol)

t_oc = time_grid(sol_oc)
x_oc = state(sol_oc).(t_oc)
Expand All @@ -324,12 +324,12 @@ function comparison(; max_iter, test_name)
nlp_os = nlp_model(docp)
ocp_os = ocp_model(docp)
nlp_sol = madnlp(nlp_os; options_madnlp...)
sol_os = build_ocp_solution(docp, nlp_sol)
sol_os = build_OCP_solution(docp, nlp_sol)

t_os = time_grid(sol_os)
x_os = state(sol_os).(t_os)
u_os = control(sol_os).(t_os)
o_os = criterion(ocp_os) == :min ? objective(sol_os) : -objective(sol_os)
o_os = objective(sol_os)
i_os = iterations(sol_os)
v_os = variable(sol_os)
nb_var_os = get_nvar(nlp_os)
Expand Down
Loading