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
Binary file added test/figures/init/balanced_field.pdf
Binary file not shown.
Binary file modified test/figures/init/beam.pdf
Binary file not shown.
Binary file added test/figures/init/brachistochrone.pdf
Binary file not shown.
Binary file added test/figures/init/bryson_denham.pdf
Binary file not shown.
Binary file modified test/figures/init/chain.pdf
Binary file not shown.
Binary file modified test/figures/init/dielectrophoretic_particle.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 added test/figures/init/mountain_car.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 added test/figures/solution/balanced_field.pdf
Binary file not shown.
Binary file modified test/figures/solution/beam.pdf
Binary file not shown.
Binary file added test/figures/solution/brachistochrone.pdf
Binary file not shown.
Binary file added test/figures/solution/bryson_denham.pdf
Binary file not shown.
Binary file modified test/figures/solution/chain.pdf
Binary file not shown.
Binary file modified test/figures/solution/dielectrophoretic_particle.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 added test/figures/solution/mountain_car.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.
126 changes: 65 additions & 61 deletions test/test_JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,82 @@
function test_JuMP()
for f in LIST_OF_PROBLEMS
@testset "$(f)" verbose=VERBOSE begin
grid_size = metadata(f)[:grid_size]
try
grid_size = metadata(f)[:grid_size]

# do we keep or remove the problem from the list
keep_problem = true
# do we keep or remove the problem from the list
keep_problem = true

#
DEBUG && println("\n", "┌─ ", string(f), " (JuMP)")
DEBUG && println("│")
#
DEBUG && println("\n", "┌─ ", string(f), " (JuMP)")
DEBUG && println("│")

# Set up the model
nlp = OptimalControlProblems.eval(f)(JuMPBackend(); grid_size=grid_size)
set_optimizer(nlp, Ipopt.Optimizer)
set_silent(nlp)
set_optimizer_attribute(nlp, "tol", TOL)
set_optimizer_attribute(nlp, "max_iter", MAX_ITER)
set_optimizer_attribute(nlp, "mu_strategy", MU_STRATEGY)
set_optimizer_attribute(nlp, "linear_solver", "mumps")
set_optimizer_attribute(nlp, "max_wall_time", MAX_WALL_TIME)
set_optimizer_attribute(nlp, "sb", SB)
# Set up the model
nlp = OptimalControlProblems.eval(f)(JuMPBackend(); grid_size=grid_size)
set_optimizer(nlp, Ipopt.Optimizer)
set_silent(nlp)
set_optimizer_attribute(nlp, "tol", TOL)
set_optimizer_attribute(nlp, "max_iter", MAX_ITER)
set_optimizer_attribute(nlp, "mu_strategy", MU_STRATEGY)
set_optimizer_attribute(nlp, "linear_solver", "mumps")
set_optimizer_attribute(nlp, "max_wall_time", MAX_WALL_TIME)
set_optimizer_attribute(nlp, "sb", SB)

# check existence of required metadata
nlp_keys = keys(object_dictionary(nlp))
@test :time_grid ∈ nlp_keys
@test :state_components ∈ nlp_keys
@test :costate_components ∈ nlp_keys
@test :control_components ∈ nlp_keys
@test :variable_components ∈ nlp_keys
# check existence of required metadata
nlp_keys = keys(object_dictionary(nlp))
@test :time_grid ∈ nlp_keys
@test :state_components ∈ nlp_keys
@test :costate_components ∈ nlp_keys
@test :control_components ∈ nlp_keys
@test :variable_components ∈ nlp_keys

# check if the keys from the components names exists
components = [
:state_components,
:costate_components,
:control_components,
:variable_components,
]
for c in components
if !(isnothing(nlp[c]))
for e in nlp[c]
@test Symbol(e) ∈ nlp_keys
# check if the keys from the components names exists
components = [
:state_components,
:costate_components,
:control_components,
:variable_components,
]
for c in components
if !(isnothing(nlp[c]))
for e in nlp[c]
@test Symbol(e) ∈ nlp_keys
end
end
end
end

# Solve the model
print(" First solve: ");
@time optimize!(nlp)
print(" Second solve: ");
@time optimize!(nlp)
# Solve the model
print(" First solve: ");
@time optimize!(nlp)
print(" Second solve: ");
@time optimize!(nlp)

# Infos
DEBUG && println("│")
DEBUG && print(
"│ termination_status: ",
termination_status(nlp),
", objective: ",
objective_value(nlp),
", iterations: ",
barrier_iterations(nlp),
)
# Infos
DEBUG && println("│")
DEBUG && print(
"│ termination_status: ",
termination_status(nlp),
", objective: ",
objective_value(nlp),
", iterations: ",
barrier_iterations(nlp),
)

# Test
res = @my_test_broken termination_status(nlp) == MOI.LOCALLY_SOLVED
keep_problem = keep_problem && res
DEBUG && res && println(", \033[1;32mPass\033[0m")
DEBUG && !res && println(", \033[1;31mFail\033[0m")
DEBUG && println("│")
DEBUG && println("└─")
# Test
res = @my_test_broken termination_status(nlp) == MOI.LOCALLY_SOLVED
keep_problem = keep_problem && res
DEBUG && res && println(", \033[1;32mPass\033[0m")
DEBUG && !res && println(", \033[1;31mFail\033[0m")
DEBUG && println("│")
DEBUG && println("└─")

# do we keep or remove the problem from the list
if !keep_problem
global LIST_OF_PROBLEMS_FINAL
LIST_OF_PROBLEMS_FINAL = setdiff(LIST_OF_PROBLEMS_FINAL, [f])
# do we keep or remove the problem from the list
if !keep_problem
global LIST_OF_PROBLEMS_FINAL
LIST_OF_PROBLEMS_FINAL = setdiff(LIST_OF_PROBLEMS_FINAL, [f])
end
catch e
handle_solver_error(e, f)
end
end
end
Expand Down
92 changes: 48 additions & 44 deletions test/test_OptimalControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,54 @@ function test_OptimalControl()

for f in LIST_OF_PROBLEMS
@testset "$(f)" verbose=VERBOSE begin
grid_size = metadata(f)[:grid_size]

# do we keep or remove the problem from the list
keep_problem = true

#
DEBUG && println("\n", "┌─ ", string(f), " (OptimalControl)")
DEBUG && println("│")

# Set up the model
docp = OptimalControlProblems.eval(f)(
OptimalControlBackend(); grid_size=grid_size
)
nlp = nlp_model(docp)

# Solve the model
print(" First solve: ");
@time sol = NLPModelsIpopt.ipopt(nlp; options_ipopt...)
print(" Second solve: ");
@time sol = NLPModelsIpopt.ipopt(nlp; options_ipopt...)

# Infos
DEBUG && println("│")
DEBUG && print(
"│ sol.status: ",
sol.status,
", objective: ",
sol.objective,
", iterations: ",
sol.iter,
)

# Test
res = @my_test_broken (sol.status == :first_order || sol.status == :acceptable)
keep_problem = keep_problem && res
DEBUG && res && println(", \033[1;32mPass\033[0m")
DEBUG && !res && println(", \033[1;31mFail\033[0m")
DEBUG && println("│")
DEBUG && println("└─")

# do we keep or remove the problem from the list
if !keep_problem
global LIST_OF_PROBLEMS_FINAL
LIST_OF_PROBLEMS_FINAL = setdiff(LIST_OF_PROBLEMS_FINAL, [f])
try
grid_size = metadata(f)[:grid_size]

# do we keep or remove the problem from the list
keep_problem = true

#
DEBUG && println("\n", "┌─ ", string(f), " (OptimalControl)")
DEBUG && println("│")

# Set up the model
docp = OptimalControlProblems.eval(f)(
OptimalControlBackend(); grid_size=grid_size
)
nlp = nlp_model(docp)

# Solve the model
print(" First solve: ");
@time sol = NLPModelsIpopt.ipopt(nlp; options_ipopt...)
print(" Second solve: ");
@time sol = NLPModelsIpopt.ipopt(nlp; options_ipopt...)

# Infos
DEBUG && println("│")
DEBUG && print(
"│ sol.status: ",
sol.status,
", objective: ",
sol.objective,
", iterations: ",
sol.iter,
)

# Test
res = @my_test_broken (sol.status == :first_order || sol.status == :acceptable)
keep_problem = keep_problem && res
DEBUG && res && println(", \033[1;32mPass\033[0m")
DEBUG && !res && println(", \033[1;31mFail\033[0m")
DEBUG && println("│")
DEBUG && println("└─")

# do we keep or remove the problem from the list
if !keep_problem
global LIST_OF_PROBLEMS_FINAL
LIST_OF_PROBLEMS_FINAL = setdiff(LIST_OF_PROBLEMS_FINAL, [f])
end
catch e
handle_solver_error(e, f)
end
end
end
Expand Down
92 changes: 48 additions & 44 deletions test/test_OptimalControl_s.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,54 @@ function test_OptimalControl_s()

for f in LIST_OF_PROBLEMS
@testset "$(f)" verbose=VERBOSE begin
grid_size = metadata(f)[:grid_size]

# do we keep or remove the problem from the list
keep_problem = true

#
DEBUG && println("\n", "┌─ ", string(f), " (OptimalControl_s)")
DEBUG && println("│")

# Set up the model
docp = OptimalControlProblems.eval(Symbol(f, :_s))(
OptimalControlBackend(), :madnlp, :exa; grid_size=grid_size
)
nlp = nlp_model(docp)

# Solve the model
print(" First solve: ");
@time sol = madnlp(nlp; options_madnlp...)
print(" Second solve: ");
@time sol = madnlp(nlp; options_madnlp...)

# Infos
DEBUG && println("│")
DEBUG && print(
"│ sol.status: ",
sol.status,
", objective: ",
sol.objective,
", iterations: ",
sol.iter,
)

# Test
res = @my_test_broken (sol.status == MadNLP.SOLVE_SUCCEEDED) #:first_order || sol.status == :acceptable)
keep_problem = keep_problem && res
DEBUG && res && println(", \033[1;32mPass\033[0m")
DEBUG && !res && println(", \033[1;31mFail\033[0m")
DEBUG && println("│")
DEBUG && println("└─")

# do we keep or remove the problem from the list
if !keep_problem
global LIST_OF_PROBLEMS_FINAL
LIST_OF_PROBLEMS_FINAL = setdiff(LIST_OF_PROBLEMS_FINAL, [f])
try
grid_size = metadata(f)[:grid_size]

# do we keep or remove the problem from the list
keep_problem = true

#
DEBUG && println("\n", "┌─ ", string(f), " (OptimalControl_s)")
DEBUG && println("│")

# Set up the model
docp = OptimalControlProblems.eval(Symbol(f, :_s))(
OptimalControlBackend(), :madnlp, :exa; grid_size=grid_size
)
nlp = nlp_model(docp)

# Solve the model
print(" First solve: ");
@time sol = madnlp(nlp; options_madnlp...)
print(" Second solve: ");
@time sol = madnlp(nlp; options_madnlp...)

# Infos
DEBUG && println("│")
DEBUG && print(
"│ sol.status: ",
sol.status,
", objective: ",
sol.objective,
", iterations: ",
sol.iter,
)

# Test
res = @my_test_broken (sol.status == MadNLP.SOLVE_SUCCEEDED) #:first_order || sol.status == :acceptable)
keep_problem = keep_problem && res
DEBUG && res && println(", \033[1;32mPass\033[0m")
DEBUG && !res && println(", \033[1;31mFail\033[0m")
DEBUG && println("│")
DEBUG && println("└─")

# do we keep or remove the problem from the list
if !keep_problem
global LIST_OF_PROBLEMS_FINAL
LIST_OF_PROBLEMS_FINAL = setdiff(LIST_OF_PROBLEMS_FINAL, [f])
end
catch e
handle_solver_error(e, f)
end
end
end
Expand Down
Loading
Loading