From 795bd122624ee6fefb4acc06aaec7cc2007029dd Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Wed, 7 Aug 2024 10:48:50 +0200 Subject: [PATCH 1/5] add default values --- src/default.jl | 51 ++++++++++++++++++++++++++++++++++++++++++++ test/test_default.jl | 12 +++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/default.jl b/src/default.jl index c52f1f99..59ad211d 100644 --- a/src/default.jl +++ b/src/default.jl @@ -162,6 +162,57 @@ function __init_interpolation() return (T, U) -> Interpolations.linear_interpolation(T, U, extrapolation_bc = Interpolations.Line()) end +""" +$(TYPEDSIGNATURES) + +Used to set the default initial guess. +The default value is `nothing`. +""" +__ocp_init() = nothing + +# ------------------------------------------------------------------------------------ +# Direct methods + +""" +$(TYPEDSIGNATURES) + +Used to set the default grid size. +The default value is `100`. +""" +__grid_size_direct() = 100 + +""" +$(TYPEDSIGNATURES) + +Used to set the default time grid. +The default value is `nothing`. +""" +__time_grid_direct() = nothing + +""" +$(TYPEDSIGNATURES) + +Used to set the default tolerance. +The default value is `1e-8`. +""" +__tolerance_direct() = 1e-8 + +""" +$(TYPEDSIGNATURES) + +Used to set the default maximum of iterations. +The default value is `1000`. +""" +__max_iterations_direct() = 1000 + +""" +$(TYPEDSIGNATURES) + +Used to set the default linear solver. +The default value is `:ma57`. +""" +__linear_solver_direct() = :ma57 + # ------------------------------------------------------------------------------------ # IPOPT diff --git a/test/test_default.jl b/test/test_default.jl index 612c0765..f8a46e12 100644 --- a/test/test_default.jl +++ b/test/test_default.jl @@ -64,6 +64,18 @@ function test_default() @test CTBase.__init_interpolation() isa Function end + @testset "Default value of the initial guess" begin + @test isnothing(CTBase.__ocp_init()) + end + + @testset "Default value for direct solver" begin + @test CTBase.__grid_size_direct() isa Integer + @test isnothing(CTBase.__time_grid_direct()) + @test CTBase.__tolerance_direct() < 1 + @test CTBase.__max_iterations_direct() isa Integer + @test CTBase.__linear_solver_direct() isa Symbol + end + @testset "Default value of the print level of ipopt for the direct method" begin @test CTBase.__print_level_ipopt() isa Integer @test CTBase.__print_level_ipopt() ≤ 12 From b6cb2d0ed106a7c85aacfef6adccfd4f6b283383 Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Wed, 7 Aug 2024 11:29:20 +0200 Subject: [PATCH 2/5] add only ocp_init --- src/default.jl | 43 ------------------------------------------- test/test_default.jl | 8 -------- 2 files changed, 51 deletions(-) diff --git a/src/default.jl b/src/default.jl index 59ad211d..0ef8377c 100644 --- a/src/default.jl +++ b/src/default.jl @@ -170,49 +170,6 @@ The default value is `nothing`. """ __ocp_init() = nothing -# ------------------------------------------------------------------------------------ -# Direct methods - -""" -$(TYPEDSIGNATURES) - -Used to set the default grid size. -The default value is `100`. -""" -__grid_size_direct() = 100 - -""" -$(TYPEDSIGNATURES) - -Used to set the default time grid. -The default value is `nothing`. -""" -__time_grid_direct() = nothing - -""" -$(TYPEDSIGNATURES) - -Used to set the default tolerance. -The default value is `1e-8`. -""" -__tolerance_direct() = 1e-8 - -""" -$(TYPEDSIGNATURES) - -Used to set the default maximum of iterations. -The default value is `1000`. -""" -__max_iterations_direct() = 1000 - -""" -$(TYPEDSIGNATURES) - -Used to set the default linear solver. -The default value is `:ma57`. -""" -__linear_solver_direct() = :ma57 - # ------------------------------------------------------------------------------------ # IPOPT diff --git a/test/test_default.jl b/test/test_default.jl index f8a46e12..98231e9a 100644 --- a/test/test_default.jl +++ b/test/test_default.jl @@ -68,14 +68,6 @@ function test_default() @test isnothing(CTBase.__ocp_init()) end - @testset "Default value for direct solver" begin - @test CTBase.__grid_size_direct() isa Integer - @test isnothing(CTBase.__time_grid_direct()) - @test CTBase.__tolerance_direct() < 1 - @test CTBase.__max_iterations_direct() isa Integer - @test CTBase.__linear_solver_direct() isa Symbol - end - @testset "Default value of the print level of ipopt for the direct method" begin @test CTBase.__print_level_ipopt() isa Integer @test CTBase.__print_level_ipopt() ≤ 12 From a5a4317ba0bb6bd812487000ed03d7f977bbd3bc Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Wed, 7 Aug 2024 11:47:37 +0200 Subject: [PATCH 3/5] renamed ipopt default values --- src/default.jl | 4 ++-- test/test_default.jl | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/default.jl b/src/default.jl index 0ef8377c..e4030246 100644 --- a/src/default.jl +++ b/src/default.jl @@ -179,7 +179,7 @@ $(TYPEDSIGNATURES) Used to set the default value of the print level of ipopt for the direct method. The default value is `5`. """ -__print_level_ipopt() = 5 +__ipopt_print_level() = 5 """ $(TYPEDSIGNATURES) @@ -187,4 +187,4 @@ $(TYPEDSIGNATURES) Used to set the default value of the μ strategy of ipopt for the direct method. The default value is `adaptive`. """ -__mu_strategy_ipopt() = "adaptive" \ No newline at end of file +__ipopt_mu_strategy() = "adaptive" \ No newline at end of file diff --git a/test/test_default.jl b/test/test_default.jl index 98231e9a..8940e098 100644 --- a/test/test_default.jl +++ b/test/test_default.jl @@ -69,13 +69,13 @@ function test_default() end @testset "Default value of the print level of ipopt for the direct method" begin - @test CTBase.__print_level_ipopt() isa Integer - @test CTBase.__print_level_ipopt() ≤ 12 - @test CTBase.__print_level_ipopt() ≥ 0 + @test CTBase.__ipopt_print_level() isa Integer + @test CTBase.__ipopt_print_level() ≤ 12 + @test CTBase.__ipopt_print_level() ≥ 0 end @testset "Default value of the mu strategy of ipopt for the direct method" begin - @test CTBase.__mu_strategy_ipopt() isa String + @test CTBase.__ipopt_mu_strategy() isa String end end From 59e4e3c7a72811097515cfcf76f13a838a458127 Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Wed, 7 Aug 2024 11:55:08 +0200 Subject: [PATCH 4/5] add default linear solvers --- src/default.jl | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/default.jl b/src/default.jl index e4030246..58e2809c 100644 --- a/src/default.jl +++ b/src/default.jl @@ -176,7 +176,7 @@ __ocp_init() = nothing """ $(TYPEDSIGNATURES) -Used to set the default value of the print level of ipopt for the direct method. +Used to set the default value of the print level of Ipopt for the direct method. The default value is `5`. """ __ipopt_print_level() = 5 @@ -184,7 +184,26 @@ __ipopt_print_level() = 5 """ $(TYPEDSIGNATURES) -Used to set the default value of the μ strategy of ipopt for the direct method. +Used to set the default value of the μ strategy of Ipopt for the direct method. The default value is `adaptive`. """ -__ipopt_mu_strategy() = "adaptive" \ No newline at end of file +__ipopt_mu_strategy() = "adaptive" + +""" +$(TYPEDSIGNATURES) + +Used to set the default value of the linear solver of Ipopt for the direct method. +The default value is `mumps`. +""" +__ipopt_linear_solver() = "mumps" + +# ------------------------------------------------------------------------------------ +# MadNLP + +""" +$(TYPEDSIGNATURES) + +Used to set the default value of the linear solver of MadNLP for the direct method. +The default value is `umfpack`. +""" +__madnlp_linear_solver() = "umfpack" From 6f2befcc6802eba565185b0db33e47eecd5dc40c Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Wed, 7 Aug 2024 12:07:12 +0200 Subject: [PATCH 5/5] removed ipopt and madnlp default values --- src/default.jl | 40 +--------------------------------------- test/test_default.jl | 10 ---------- 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/src/default.jl b/src/default.jl index 58e2809c..4293c959 100644 --- a/src/default.jl +++ b/src/default.jl @@ -168,42 +168,4 @@ $(TYPEDSIGNATURES) Used to set the default initial guess. The default value is `nothing`. """ -__ocp_init() = nothing - -# ------------------------------------------------------------------------------------ -# IPOPT - -""" -$(TYPEDSIGNATURES) - -Used to set the default value of the print level of Ipopt for the direct method. -The default value is `5`. -""" -__ipopt_print_level() = 5 - -""" -$(TYPEDSIGNATURES) - -Used to set the default value of the μ strategy of Ipopt for the direct method. -The default value is `adaptive`. -""" -__ipopt_mu_strategy() = "adaptive" - -""" -$(TYPEDSIGNATURES) - -Used to set the default value of the linear solver of Ipopt for the direct method. -The default value is `mumps`. -""" -__ipopt_linear_solver() = "mumps" - -# ------------------------------------------------------------------------------------ -# MadNLP - -""" -$(TYPEDSIGNATURES) - -Used to set the default value of the linear solver of MadNLP for the direct method. -The default value is `umfpack`. -""" -__madnlp_linear_solver() = "umfpack" +__ocp_init() = nothing \ No newline at end of file diff --git a/test/test_default.jl b/test/test_default.jl index 8940e098..3c725836 100644 --- a/test/test_default.jl +++ b/test/test_default.jl @@ -68,14 +68,4 @@ function test_default() @test isnothing(CTBase.__ocp_init()) end - @testset "Default value of the print level of ipopt for the direct method" begin - @test CTBase.__ipopt_print_level() isa Integer - @test CTBase.__ipopt_print_level() ≤ 12 - @test CTBase.__ipopt_print_level() ≥ 0 - end - - @testset "Default value of the mu strategy of ipopt for the direct method" begin - @test CTBase.__ipopt_mu_strategy() isa String - end - end