From 7815393b3607bbe879a92968be2c36e96f9fdb20 Mon Sep 17 00:00:00 2001 From: ocots <66357348+ocots@users.noreply.github.com> Date: Sat, 11 Jul 2026 00:27:43 +0000 Subject: [PATCH] Format .jl files --- docs/api_reference.jl | 32 +- docs/make.jl | 34 +- ext/CTSolversADNLPModels.jl | 4 +- ext/CTSolversForwardDiff.jl | 6 +- ext/CTSolversIpopt.jl | 2 +- ext/CTSolversKnitro.jl | 2 +- ext/CTSolversMadNCL.jl | 2 +- ext/CTSolversMadNLP.jl | 2 +- ext/CTSolversSciMLIntegrator.jl | 318 +++++++++--------- ext/CTSolversUno.jl | 2 +- src/DOCP/contract.jl | 2 +- src/DOCP/discretized_model.jl | 4 +- src/Integrators/contract.jl | 4 +- src/Integrators/integration_result.jl | 42 ++- src/Integrators/sciml.jl | 23 +- src/Modelers/adnlp.jl | 10 +- src/Modelers/contract.jl | 8 +- src/Modelers/exa.jl | 10 +- src/Modelers/validation.jl | 10 +- src/Solvers/contract.jl | 2 +- src/Solvers/ipopt.jl | 8 +- src/Solvers/knitro.jl | 8 +- src/Solvers/madncl.jl | 8 +- src/Solvers/madnlp.jl | 8 +- src/Solvers/madnlpsuite.jl | 2 +- src/Solvers/uno.jl | 8 +- test/problems/elec.jl | 2 +- test/suite/docp/test_docp.jl | 7 +- .../test_generic_extract_solver_infos.jl | 8 +- test/suite/extensions/test_ipopt_extension.jl | 28 +- .../suite/extensions/test_madncl_extension.jl | 42 ++- .../test_madncl_extract_solver_infos.jl | 28 +- .../suite/extensions/test_madnlp_extension.jl | 36 +- .../test_madnlp_extract_solver_infos.jl | 4 +- test/suite/extensions/test_uno_extension.jl | 24 +- .../test_comprehensive_validation.jl | 2 +- test/suite/integration/test_end_to_end.jl | 7 +- .../integration/test_mode_propagation.jl | 2 +- .../test_route_to_comprehensive.jl | 8 +- .../test_strict_permissive_integration.jl | 2 +- .../integrators/test_integrator_exports.jl | 29 +- .../test_integrator_forwarddiff.jl | 4 +- .../integrators/test_integrator_metadata.jl | 8 +- .../integrators/test_integrator_solve.jl | 8 +- .../integrators/test_integrator_stubs.jl | 18 +- .../test_integrator_type_stability.jl | 5 +- test/suite/integrators/test_internal_norm.jl | 5 +- .../test_adnlp_parameter_validation.jl | 2 +- .../test_internal_defaults_coverage.jl | 2 +- test/suite/optimization/test_error_cases.jl | 20 +- test/suite/optimization/test_optimization.jl | 20 +- test/suite/optimization/test_real_problems.jl | 6 +- ...tested_test_knitro_parameter_validation.jl | 2 +- .../test_ipopt_parameter_validation.jl | 2 +- .../solvers/test_uno_parameter_validation.jl | 2 +- .../strategies/test_alias_integration.jl | 2 +- .../test_cpu_only_parameters_integration.jl | 2 +- .../strategies/test_describe_parameters.jl | 3 +- .../strategies/test_integration_parameters.jl | 4 +- 59 files changed, 496 insertions(+), 409 deletions(-) diff --git a/docs/api_reference.jl b/docs/api_reference.jl index 51b85091..ede9dd51 100644 --- a/docs/api_reference.jl +++ b/docs/api_reference.jl @@ -19,8 +19,14 @@ function generate_api_reference(src_dir::String, ext_dir::String) EXCLUDE_SYMBOLS = Symbol[:include, :eval] EXCLUDE_INTERNALS = vcat( EXCLUDE_SYMBOLS, - Symbol[:DOCTYPE_ABSTRACT_TYPE, :DOCTYPE_CONSTANT, :DOCTYPE_FUNCTION, - :DOCTYPE_MACRO, :DOCTYPE_MODULE, :DOCTYPE_STRUCT], + Symbol[ + :DOCTYPE_ABSTRACT_TYPE, + :DOCTYPE_CONSTANT, + :DOCTYPE_FUNCTION, + :DOCTYPE_MACRO, + :DOCTYPE_MODULE, + :DOCTYPE_STRUCT, + ], ) # ── Shared config: one entry per submodule ──────────────────────────────── @@ -114,17 +120,17 @@ function generate_api_reference(src_dir::String, ext_dir::String) internals_modules = Any[cfg.mod => cfg.files for cfg in modules_config] for (sym, files) in [ - (:CTSolversIpopt, ext("CTSolversIpopt.jl")), - (:CTSolversMadNLP, ext("CTSolversMadNLP.jl")), - (:CTSolversMadNCL, ext("CTSolversMadNCL.jl")), - (:CTSolversKnitro, ext("CTSolversKnitro.jl")), - (:CTSolversUno, ext("CTSolversUno.jl")), - (:CTSolversEnzyme, ext("CTSolversEnzyme.jl")), - (:CTSolversCUDA, ext("CTSolversCUDA.jl")), - (:CTSolversMadNLPGPU, ext("CTSolversMadNLPGPU.jl")), - (:CTSolversZygote, ext("CTSolversZygote.jl")), - (:CTSolversSciMLIntegrator, ext("CTSolversSciMLIntegrator.jl")), - (:CTSolversForwardDiff, ext("CTSolversForwardDiff.jl")), + (:CTSolversIpopt, ext("CTSolversIpopt.jl")), + (:CTSolversMadNLP, ext("CTSolversMadNLP.jl")), + (:CTSolversMadNCL, ext("CTSolversMadNCL.jl")), + (:CTSolversKnitro, ext("CTSolversKnitro.jl")), + (:CTSolversUno, ext("CTSolversUno.jl")), + (:CTSolversEnzyme, ext("CTSolversEnzyme.jl")), + (:CTSolversCUDA, ext("CTSolversCUDA.jl")), + (:CTSolversMadNLPGPU, ext("CTSolversMadNLPGPU.jl")), + (:CTSolversZygote, ext("CTSolversZygote.jl")), + (:CTSolversSciMLIntegrator, ext("CTSolversSciMLIntegrator.jl")), + (:CTSolversForwardDiff, ext("CTSolversForwardDiff.jl")), (:CTSolversOrdinaryDiffEqTsit5, ext("CTSolversOrdinaryDiffEqTsit5.jl")), ] extmod = Base.get_extension(CTSolvers, sym) diff --git a/docs/make.jl b/docs/make.jl index 847c92ad..d5c711d8 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -35,10 +35,22 @@ using Zygote # Make extension modules available in Main so that @docs blocks can resolve # qualified bindings like CTFlowsSciMLIntegrator.SciMLIntegrationResult. -for _ext_sym in - (:CTSolversADNLPModels, :CTSolversCUDA, :CTSolversEnzyme, :CTSolversExaModels, :CTSolversForwardDiff, - :CTSolversIpopt, :CTSolversKnitro, :CTSolversMadNCL, :CTSolversMadNLP, :CTSolversMadNLPGPU, - :CTSolversOrdinaryDiffEqTsit5, :CTSolversSciMLIntegrator, :CTSolversUno, :CTSolversZygote) +for _ext_sym in ( + :CTSolversADNLPModels, + :CTSolversCUDA, + :CTSolversEnzyme, + :CTSolversExaModels, + :CTSolversForwardDiff, + :CTSolversIpopt, + :CTSolversKnitro, + :CTSolversMadNCL, + :CTSolversMadNLP, + :CTSolversMadNLPGPU, + :CTSolversOrdinaryDiffEqTsit5, + :CTSolversSciMLIntegrator, + :CTSolversUno, + :CTSolversZygote, +) _m = Base.get_extension(CTSolvers, _ext_sym) isnothing(_m) || @eval Main const $_ext_sym = $_m end @@ -95,16 +107,16 @@ with_api_reference(src_dir, ext_dir) do api_pages ), pages=[ # index.md is the VitePress root — not listed here - "Getting Started" => "getting-started.md", - "Architecture" => "architecture.md", + "Getting Started" => "getting-started.md", + "Architecture" => "architecture.md", "Developer Guides" => [ - "Implementing a Solver" => "guides/implementing_a_solver.md", - "Implementing an Integrator" => "guides/implementing_an_integrator.md", - "Implementing a Modeler" => "guides/implementing_a_modeler.md", + "Implementing a Solver" => "guides/implementing_a_solver.md", + "Implementing an Integrator" => "guides/implementing_an_integrator.md", + "Implementing a Modeler" => "guides/implementing_a_modeler.md", "Implementing an Optimization Problem" => "guides/implementing_an_optimization_problem.md", - "Error Messages Reference" => "guides/error_messages.md", + "Error Messages Reference" => "guides/error_messages.md", ], - "API Reference" => api_pages, + "API Reference" => api_pages, ], plugins=[links], ) diff --git a/ext/CTSolversADNLPModels.jl b/ext/CTSolversADNLPModels.jl index f64d7c1c..bf3a6df6 100644 --- a/ext/CTSolversADNLPModels.jl +++ b/ext/CTSolversADNLPModels.jl @@ -213,7 +213,9 @@ function Modelers.build_adnlp_modeler( if haskey(kwargs, :adnlp_backend) @warn "adnlp_backend is deprecated, use backend instead" maxlog=1 end - opts = Strategies.build_strategy_options(Modelers.ADNLP{parameter}; mode=mode, kwargs...) + opts = Strategies.build_strategy_options( + Modelers.ADNLP{parameter}; mode=mode, kwargs... + ) return Modelers.ADNLP{parameter}(opts) end diff --git a/ext/CTSolversForwardDiff.jl b/ext/CTSolversForwardDiff.jl index 68ca8597..63ff9895 100644 --- a/ext/CTSolversForwardDiff.jl +++ b/ext/CTSolversForwardDiff.jl @@ -14,7 +14,7 @@ ForwardDiff dual numbers. module CTSolversForwardDiff import DocStringExtensions: TYPEDSIGNATURES -import ForwardDiff +using ForwardDiff: ForwardDiff using CTSolvers.Integrators: Integrators @@ -40,6 +40,8 @@ numbers, ensuring grid invariance (IND) when integrating ODEs with dual numbers. See also: [`CTSolvers.Integrators.real_norm`](@ref), [`CTSolvers.Integrators.deepvalue`](@ref). """ -Integrators.real_norm(u::ForwardDiff.Dual, t) = Integrators.real_norm(Integrators.deepvalue(u), t) +function Integrators.real_norm(u::ForwardDiff.Dual, t) + return Integrators.real_norm(Integrators.deepvalue(u), t) +end end # module CTSolversForwardDiff diff --git a/ext/CTSolversIpopt.jl b/ext/CTSolversIpopt.jl index b9f886e7..a0b32ece 100644 --- a/ext/CTSolversIpopt.jl +++ b/ext/CTSolversIpopt.jl @@ -8,7 +8,7 @@ module CTSolversIpopt import DocStringExtensions: TYPEDSIGNATURES import CTSolvers.Solvers -import CommonSolve +using CommonSolve: CommonSolve import CTBase.Strategies import CTBase.Options import CTBase.Core diff --git a/ext/CTSolversKnitro.jl b/ext/CTSolversKnitro.jl index 51475e2a..3e120ba9 100644 --- a/ext/CTSolversKnitro.jl +++ b/ext/CTSolversKnitro.jl @@ -8,7 +8,7 @@ module CTSolversKnitro import DocStringExtensions: TYPEDSIGNATURES import CTSolvers.Solvers -import CommonSolve +using CommonSolve: CommonSolve import CTBase.Strategies import CTBase.Options import CTBase.Exceptions diff --git a/ext/CTSolversMadNCL.jl b/ext/CTSolversMadNCL.jl index 641bc985..eef47f3f 100644 --- a/ext/CTSolversMadNCL.jl +++ b/ext/CTSolversMadNCL.jl @@ -8,7 +8,7 @@ module CTSolversMadNCL import DocStringExtensions: TYPEDSIGNATURES import CTSolvers.Solvers -import CommonSolve +using CommonSolve: CommonSolve import CTBase.Strategies import CTBase.Options import CTBase.Core diff --git a/ext/CTSolversMadNLP.jl b/ext/CTSolversMadNLP.jl index b98b4afc..bedd80d1 100644 --- a/ext/CTSolversMadNLP.jl +++ b/ext/CTSolversMadNLP.jl @@ -9,7 +9,7 @@ module CTSolversMadNLP import DocStringExtensions: TYPEDSIGNATURES import CTSolvers.Optimization import CTSolvers.Solvers -import CommonSolve +using CommonSolve: CommonSolve import CTBase.Strategies import CTBase.Options import CTBase.Core diff --git a/ext/CTSolversSciMLIntegrator.jl b/ext/CTSolversSciMLIntegrator.jl index debbc91a..98da1f3e 100644 --- a/ext/CTSolversSciMLIntegrator.jl +++ b/ext/CTSolversSciMLIntegrator.jl @@ -19,7 +19,7 @@ The domain glue that turns a control system/config into an `ODEProblem` (`build_ module CTSolversSciMLIntegrator import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES -import CommonSolve +using CommonSolve: CommonSolve import CTBase.Exceptions import CTBase.Strategies import CTBase.Core @@ -45,7 +45,9 @@ and `DiffEqBase.ODE_DEFAULT_NORM` to compute the norm. See also: [`CTSolvers.Integrators.deepvalue`](@ref), [`CTSolvers.Integrators.real_norm`](@ref). """ -Integrators.real_norm(u::AbstractArray, t) = DiffEqBase.ODE_DEFAULT_NORM(Integrators.deepvalue.(u), t) +function Integrators.real_norm(u::AbstractArray, t) + return DiffEqBase.ODE_DEFAULT_NORM(Integrators.deepvalue.(u), t) +end # ============================================================================= # Strategies.metadata — option definitions for SciML @@ -62,201 +64,201 @@ part of ForwardDiff dual numbers to ensure grid invariance (IND) when ForwardDif function Strategies.metadata(::Type{Integrators.SciML}) return Strategies.StrategyMetadata( Strategies.OptionDefinition(; - name = :alg, - type = SciMLBase.AbstractDEAlgorithm, - default = Integrators.__default_sciml_algorithm(Integrators.Tsit5Tag), - description = "ODE algorithm (e.g. Tsit5(), Vern6()).", - aliases = (:algorithm, :solver), + name=:alg, + type=SciMLBase.AbstractDEAlgorithm, + default=Integrators.__default_sciml_algorithm(Integrators.Tsit5Tag), + description="ODE algorithm (e.g. Tsit5(), Vern6()).", + aliases=(:algorithm, :solver), ), Strategies.OptionDefinition(; - name = :reltol, - type = Real, - default = 1e-8, - description = "Relative tolerance for the ODE solver.", - aliases = (:rtol, :rel_tol), - validator = x -> + name=:reltol, + type=Real, + default=1e-8, + description="Relative tolerance for the ODE solver.", + aliases=(:rtol, :rel_tol), + validator=x -> x > 0 || throw( Exceptions.IncorrectArgument( "Invalid reltol value"; - got = "reltol=$x", - expected = "positive real number (> 0)", - suggestion = "Provide a positive tolerance (e.g., 1e-8, 1e-10).", - context = "SciML reltol validation", + got="reltol=$x", + expected="positive real number (> 0)", + suggestion="Provide a positive tolerance (e.g., 1e-8, 1e-10).", + context="SciML reltol validation", ), ), ), Strategies.OptionDefinition(; - name = :abstol, - type = Real, - default = 1e-8, - description = "Absolute tolerance for the ODE solver.", - aliases = (:atol, :abs_tol), - validator = x -> + name=:abstol, + type=Real, + default=1e-8, + description="Absolute tolerance for the ODE solver.", + aliases=(:atol, :abs_tol), + validator=x -> x > 0 || throw( Exceptions.IncorrectArgument( "Invalid abstol value"; - got = "abstol=$x", - expected = "positive real number (> 0)", - suggestion = "Provide a positive tolerance (e.g., 1e-8, 1e-10).", - context = "SciML abstol validation", + got="abstol=$x", + expected="positive real number (> 0)", + suggestion="Provide a positive tolerance (e.g., 1e-8, 1e-10).", + context="SciML abstol validation", ), ), ), Strategies.OptionDefinition(; - name = :maxiters, - type = Integer, - default = Core.NotProvided, - description = "Maximum number of solver iterations.", + name=:maxiters, + type=Integer, + default=Core.NotProvided, + description="Maximum number of solver iterations.", aliases=(:max_iters, :max_iter, :maxiter, :max_iterations, :maxit), - validator = x -> + validator=x -> x > 0 || throw( Exceptions.IncorrectArgument( "Invalid maxiters value"; - got = "maxiters=$x", - expected = "positive integer (> 0)", - suggestion = "Provide a positive iteration count (e.g., 10^5).", - context = "SciML maxiters validation", + got="maxiters=$x", + expected="positive integer (> 0)", + suggestion="Provide a positive iteration count (e.g., 10^5).", + context="SciML maxiters validation", ), ), ), Strategies.OptionDefinition(; - name = :dt, - type = Real, - default = Core.NotProvided, - description = "Fixed step size (used when adaptive=false).", - aliases = (:dt0, :timestep), - validator = x -> + name=:dt, + type=Real, + default=Core.NotProvided, + description="Fixed step size (used when adaptive=false).", + aliases=(:dt0, :timestep), + validator=x -> x > 0 || throw( Exceptions.IncorrectArgument( "Invalid dt value"; - got = "dt=$x", - expected = "positive real number (> 0)", - suggestion = "Provide a positive step size (e.g., 0.01).", - context = "SciML dt validation", + got="dt=$x", + expected="positive real number (> 0)", + suggestion="Provide a positive step size (e.g., 0.01).", + context="SciML dt validation", ), ), ), Strategies.OptionDefinition(; - name = :adaptive, - type = Bool, - default = Core.NotProvided, - description = "Whether to use adaptive step-size control.", - aliases = (:adaptive_step, :adaptive_stepping), + name=:adaptive, + type=Bool, + default=Core.NotProvided, + description="Whether to use adaptive step-size control.", + aliases=(:adaptive_step, :adaptive_stepping), ), Strategies.OptionDefinition(; - name = :save_everystep, - type = Union{Bool, Symbol}, - default = :auto, - description = "Save the solution at every solver step. Set `true`/`false` to force, or `:auto` to resolve to `false` for point integration and `true` for trajectory integration.", + name=:save_everystep, + type=Union{Bool,Symbol}, + default=:auto, + description="Save the solution at every solver step. Set `true`/`false` to force, or `:auto` to resolve to `false` for point integration and `true` for trajectory integration.", ), Strategies.OptionDefinition(; - name = :saveat, - type = Union{Real, AbstractVector}, - default = Core.NotProvided, - description = "Times at which to save the solution (Vector or range).", - aliases = (:save_at, :save_times), + name=:saveat, + type=Union{Real,AbstractVector}, + default=Core.NotProvided, + description="Times at which to save the solution (Vector or range).", + aliases=(:save_at, :save_times), ), Strategies.OptionDefinition(; - name = :dense, - type = Union{Bool, Symbol}, - default = :auto, - description = "Dense output. Set `true`/`false` to force, or `:auto` to resolve to `false` for point integration and `true` for trajectory integration.", + name=:dense, + type=Union{Bool,Symbol}, + default=:auto, + description="Dense output. Set `true`/`false` to force, or `:auto` to resolve to `false` for point integration and `true` for trajectory integration.", ), Strategies.OptionDefinition(; - name = :save_idxs, - type = AbstractVector{<:Integer}, - default = Core.NotProvided, - description = "Indices of components to save (Vector of integers).", - aliases = (:saveindices, :save_indices), + name=:save_idxs, + type=AbstractVector{<:Integer}, + default=Core.NotProvided, + description="Indices of components to save (Vector of integers).", + aliases=(:saveindices, :save_indices), ), Strategies.OptionDefinition(; - name = :tstops, - type = AbstractVector{<:Real}, - default = Core.NotProvided, - description = "Extra times the solver must step to (for discontinuities).", - aliases = (:t_stops, :stop_times), + name=:tstops, + type=AbstractVector{<:Real}, + default=Core.NotProvided, + description="Extra times the solver must step to (for discontinuities).", + aliases=(:t_stops, :stop_times), ), Strategies.OptionDefinition(; - name = :d_discontinuities, - type = AbstractVector{<:Real}, - default = Core.NotProvided, - description = "Locations of discontinuities in low-order derivatives.", + name=:d_discontinuities, + type=AbstractVector{<:Real}, + default=Core.NotProvided, + description="Locations of discontinuities in low-order derivatives.", ), Strategies.OptionDefinition(; - name = :dtmax, - type = Real, - default = Core.NotProvided, - description = "Maximum step size for adaptive timestepping.", - aliases = (:max_dt, :dt_max), - validator = x -> + name=:dtmax, + type=Real, + default=Core.NotProvided, + description="Maximum step size for adaptive timestepping.", + aliases=(:max_dt, :dt_max), + validator=x -> x > 0 || throw( Exceptions.IncorrectArgument( "Invalid dtmax value"; - got = "dtmax=$x", - expected = "positive real number (> 0)", - suggestion = "Provide a positive maximum step size (e.g., 0.1).", - context = "SciML dtmax validation", + got="dtmax=$x", + expected="positive real number (> 0)", + suggestion="Provide a positive maximum step size (e.g., 0.1).", + context="SciML dtmax validation", ), ), ), Strategies.OptionDefinition(; - name = :dtmin, - type = Real, - default = Core.NotProvided, - description = "Minimum step size for adaptive timestepping.", - aliases = (:min_dt, :dt_min), - validator = x -> + name=:dtmin, + type=Real, + default=Core.NotProvided, + description="Minimum step size for adaptive timestepping.", + aliases=(:min_dt, :dt_min), + validator=x -> x > 0 || throw( Exceptions.IncorrectArgument( "Invalid dtmin value"; - got = "dtmin=$x", - expected = "positive real number (> 0)", - suggestion = "Provide a positive minimum step size (e.g., 1e-6).", - context = "SciML dtmin validation", + got="dtmin=$x", + expected="positive real number (> 0)", + suggestion="Provide a positive minimum step size (e.g., 1e-6).", + context="SciML dtmin validation", ), ), ), Strategies.OptionDefinition(; - name = :force_dtmin, - type = Bool, - default = Core.NotProvided, - description = "Whether to continue forcing minimum dt usage.", + name=:force_dtmin, + type=Bool, + default=Core.NotProvided, + description="Whether to continue forcing minimum dt usage.", ), Strategies.OptionDefinition(; - name = :callback, - type = Any, - default = Core.NotProvided, - description = "Callback function for event handling.", - aliases = (:callbacks, :cb), + name=:callback, + type=Any, + default=Core.NotProvided, + description="Callback function for event handling.", + aliases=(:callbacks, :cb), ), Strategies.OptionDefinition(; - name = :progress, - type = Bool, - default = Core.NotProvided, - description = "Whether to show progress bar.", - aliases = (:verbose,), + name=:progress, + type=Bool, + default=Core.NotProvided, + description="Whether to show progress bar.", + aliases=(:verbose,), ), Strategies.OptionDefinition(; - name = :save_start, - type = Union{Bool, Symbol}, - default = :auto, - description = "Save initial condition in solution. Set `true`/`false` to force, or `:auto` to resolve to `false` for point integration and `true` for trajectory integration.", + name=:save_start, + type=Union{Bool,Symbol}, + default=:auto, + description="Save initial condition in solution. Set `true`/`false` to force, or `:auto` to resolve to `false` for point integration and `true` for trajectory integration.", ), Strategies.OptionDefinition(; - name = :save_end, - type = Bool, - default = Core.NotProvided, - description = "Whether to force saving the final timepoint.", + name=:save_end, + type=Bool, + default=Core.NotProvided, + description="Whether to force saving the final timepoint.", ), Strategies.OptionDefinition(; - name = :internalnorm, - type = Function, - default = Integrators.real_norm, - description = "Internal norm for adaptive step-size control. " * - "Defaults to `real_norm`, which extracts the primal (Float64) " * - "part of ForwardDiff dual numbers to ensure grid invariance (IND) " * - "when ForwardDiff is loaded. Set to `DiffEqBase.ODE_DEFAULT_NORM` to use the SciML default.", - aliases = (:internal_norm, :norm), + name=:internalnorm, + type=Function, + default=Integrators.real_norm, + description="Internal norm for adaptive step-size control. " * + "Defaults to `real_norm`, which extracts the primal (Float64) " * + "part of ForwardDiff dual numbers to ensure grid invariance (IND) " * + "when ForwardDiff is loaded. Set to `DiffEqBase.ODE_DEFAULT_NORM` to use the SciML default.", + aliases=(:internal_norm, :norm), ), ) end @@ -307,9 +309,9 @@ cached dictionaries `options_point` (`:auto` → `false`) and `options_trajector See also: [`CTSolvers.Integrators.SciML`](@ref). """ function Integrators.build_sciml_integrator( - ::Type{Integrators.SciMLTag}; mode::Symbol = :strict, kwargs..., + ::Type{Integrators.SciMLTag}; mode::Symbol=:strict, kwargs... ) - opts = Strategies.build_strategy_options(Integrators.SciML; mode = mode, kwargs...) + opts = Strategies.build_strategy_options(Integrators.SciML; mode=mode, kwargs...) raw = Strategies.options_dict(opts) # Check if algorithm is missing and raise PreconditionError @@ -318,11 +320,11 @@ function Integrators.build_sciml_integrator( throw( Exceptions.PreconditionError( "No ODE algorithm specified and OrdinaryDiffEqTsit5 is not loaded"; - reason = "alg is missing", - suggestion = "Load OrdinaryDiffEqTsit5: using OrdinaryDiffEqTsit5\n" * - "Or specify an algorithm explicitly: SciML(alg=Vern6())\n" * - "Note: when specifying an algorithm, also load its package (e.g., using OrdinaryDiffEqVerner for Vern6)", - context = "SciML integrator construction", + reason="alg is missing", + suggestion="Load OrdinaryDiffEqTsit5: using OrdinaryDiffEqTsit5\n" * + "Or specify an algorithm explicitly: SciML(alg=Vern6())\n" * + "Note: when specifying an algorithm, also load its package (e.g., using OrdinaryDiffEqVerner for Vern6)", + context="SciML integrator construction", ), ) end @@ -339,7 +341,7 @@ function Integrators.build_sciml_integrator( get(options_trajectory, key, :auto) === :auto && (options_trajectory[key] = true) end - return Integrators.SciML{typeof(opts), typeof(options_point), typeof(options_trajectory)}( + return Integrators.SciML{typeof(opts),typeof(options_point),typeof(options_trajectory)}( opts, options_point, options_trajectory ) end @@ -359,7 +361,8 @@ interface. # Fields - `ode_sol::S`: The raw SciML ODE solution. """ -struct SciMLIntegrationResult{S<:SciMLBase.AbstractODESolution} <: Integrators.AbstractIntegrationResult +struct SciMLIntegrationResult{S<:SciMLBase.AbstractODESolution} <: + Integrators.AbstractIntegrationResult ode_sol::S end @@ -398,12 +401,14 @@ function Integrators.merge(segments::AbstractVector{<:SciMLIntegrationResult}) ode_sols = [r.ode_sol for r in segments] if isempty(ode_sols) - throw(Exceptions.IncorrectArgument( - "Cannot merge empty sequence of segments"; - got = "0 segments", - expected = "at least 1 segment", - context = "SciML merge", - )) + throw( + Exceptions.IncorrectArgument( + "Cannot merge empty sequence of segments"; + got="0 segments", + expected="at least 1 segment", + context="SciML merge", + ), + ) end if length(ode_sols) == 1 @@ -421,9 +426,12 @@ function Integrators.merge(segments::AbstractVector{<:SciMLIntegrationResult}) sol1 = ode_sols[1] merged_sol = DiffEqBase.build_solution( - sol1.prob, sol1.alg, t_merged, u_merged; - retcode = SciMLBase.ReturnCode.Success, - dense = false, + sol1.prob, + sol1.alg, + t_merged, + u_merged; + retcode=SciMLBase.ReturnCode.Success, + dense=false, ) return SciMLIntegrationResult(merged_sol) @@ -443,12 +451,14 @@ Check the return code of a SciML ODE solution and throw `SolverFailure` if integ """ function _check_retcode(sol, unsafe) if !unsafe && !SciMLBase.successful_retcode(sol.retcode) - throw(Exceptions.SolverFailure( - "ODE integration failed"; - retcode = string(sol.retcode), - suggestion = "Try tightening tolerances (reltol, abstol) or changing the solver algorithm.", - context = "SciML solve", - )) + throw( + Exceptions.SolverFailure( + "ODE integration failed"; + retcode=string(sol.retcode), + suggestion="Try tightening tolerances (reltol, abstol) or changing the solver algorithm.", + context="SciML solve", + ), + ) end end @@ -470,8 +480,8 @@ Returns a [`SciMLIntegrationResult`](@ref) wrapping the raw `ODESolution`. function CommonSolve.solve( prob::SciMLBase.AbstractODEProblem, integ::Integrators.SciML; - options = Integrators.options_trajectory(integ), - unsafe = Integrators.__unsafe(), + options=Integrators.options_trajectory(integ), + unsafe=Integrators.__unsafe(), ) ode_sol = SciMLBase.solve(prob; options...) _check_retcode(ode_sol, unsafe) diff --git a/ext/CTSolversUno.jl b/ext/CTSolversUno.jl index dc792b7d..fc30eff1 100644 --- a/ext/CTSolversUno.jl +++ b/ext/CTSolversUno.jl @@ -8,7 +8,7 @@ module CTSolversUno import DocStringExtensions: TYPEDSIGNATURES import CTSolvers.Solvers -import CommonSolve +using CommonSolve: CommonSolve import CTBase.Strategies import CTBase.Options import CTBase.Core diff --git a/src/DOCP/contract.jl b/src/DOCP/contract.jl index 313e33ca..94a7a905 100644 --- a/src/DOCP/contract.jl +++ b/src/DOCP/contract.jl @@ -23,7 +23,7 @@ concrete type, e.g. `CTSolvers.discretize(ocp, ::Collocation)` in CTDirect. See also: `build_model`, `build_solution`. """ function discretize(ocp::CTModels.AbstractModel, discretizer::AbstractDiscretizer) - throw( + return throw( Exceptions.NotImplemented( "discretize not implemented"; required_method="CTSolvers.discretize(ocp, ::$(typeof(discretizer)))", diff --git a/src/DOCP/discretized_model.jl b/src/DOCP/discretized_model.jl index 82fbedca..b48827d4 100644 --- a/src/DOCP/discretized_model.jl +++ b/src/DOCP/discretized_model.jl @@ -28,9 +28,7 @@ multiple dispatch on `(DiscretizedModel, modeler)` through the `build_model` / See also: `ocp_model`, `discretize`, `build_model`, `build_solution`. """ struct DiscretizedModel{ - TO<:CTModels.AbstractModel, - TD<:AbstractDiscretizer, - TC<:Core.AbstractCache, + TO<:CTModels.AbstractModel,TD<:AbstractDiscretizer,TC<:Core.AbstractCache } <: AbstractOptimizationProblem ocp::TO discretizer::TD diff --git a/src/Integrators/contract.jl b/src/Integrators/contract.jl index 8cc2b5bd..7f998e8a 100644 --- a/src/Integrators/contract.jl +++ b/src/Integrators/contract.jl @@ -43,7 +43,7 @@ in the `CTSolversSciMLIntegrator` extension. This generic stub throws `NotImplem See also: [`CTSolvers.Integrators.AbstractIntegrator`](@ref). """ function CommonSolve.solve(prob, integ::AbstractIntegrator; kwargs...) - throw( + return throw( Exceptions.NotImplemented( "Solve not implemented for this integrator"; required_method="CommonSolve.solve(prob, integ::$(typeof(integ)); options, unsafe)", @@ -75,7 +75,7 @@ implement this method for their specific result types, typically in a backend ex See also: [`CTSolvers.Integrators.AbstractIntegrator`](@ref), [`CTSolvers.Integrators.AbstractIntegrationResult`](@ref). """ function merge(segments::AbstractVector{T}) where {T<:AbstractIntegrationResult} - throw( + return throw( Exceptions.NotImplemented( "merge not implemented for this integration result"; required_method="merge(segments::Vector{<:$(T)})", diff --git a/src/Integrators/integration_result.jl b/src/Integrators/integration_result.jl index ddd9e58e..7b61248d 100644 --- a/src/Integrators/integration_result.jl +++ b/src/Integrators/integration_result.jl @@ -32,12 +32,14 @@ Return the final state vector from the integration result. See also: [`CTSolvers.Integrators.AbstractIntegrationResult`](@ref), [`CTSolvers.Integrators.times`](@ref), [`CTSolvers.Integrators.evaluate_at`](@ref). """ function final_state(r::AbstractIntegrationResult) - throw(Exceptions.NotImplemented( - "final_state not implemented"; - required_method = "final_state(r::$(typeof(r)))", - suggestion = "Implement final_state(r) for your integration result type.", - context = "AbstractIntegrationResult - final_state implementation", - )) + return throw( + Exceptions.NotImplemented( + "final_state not implemented"; + required_method="final_state(r::$(typeof(r)))", + suggestion="Implement final_state(r) for your integration result type.", + context="AbstractIntegrationResult - final_state implementation", + ), + ) end """ @@ -54,12 +56,14 @@ Return the vector of time points from the integration result. See also: [`CTSolvers.Integrators.AbstractIntegrationResult`](@ref), [`CTSolvers.Integrators.final_state`](@ref), [`CTSolvers.Integrators.evaluate_at`](@ref). """ function times(r::AbstractIntegrationResult) - throw(Exceptions.NotImplemented( - "times not implemented"; - required_method = "times(r::$(typeof(r)))", - suggestion = "Implement times(r) for your integration result type.", - context = "AbstractIntegrationResult - times implementation", - )) + return throw( + Exceptions.NotImplemented( + "times not implemented"; + required_method="times(r::$(typeof(r)))", + suggestion="Implement times(r) for your integration result type.", + context="AbstractIntegrationResult - times implementation", + ), + ) end """ @@ -77,10 +81,12 @@ Evaluate the integration result at a specific time `t`. See also: [`CTSolvers.Integrators.AbstractIntegrationResult`](@ref), [`CTSolvers.Integrators.final_state`](@ref), [`CTSolvers.Integrators.times`](@ref). """ function evaluate_at(r::AbstractIntegrationResult, t::Real) - throw(Exceptions.NotImplemented( - "evaluate_at not implemented"; - required_method = "evaluate_at(r::$(typeof(r)), t::Real)", - suggestion = "Implement evaluate_at(r, t) for your integration result type.", - context = "AbstractIntegrationResult - evaluate_at implementation", - )) + return throw( + Exceptions.NotImplemented( + "evaluate_at not implemented"; + required_method="evaluate_at(r::$(typeof(r)), t::Real)", + suggestion="Implement evaluate_at(r, t) for your integration result type.", + context="AbstractIntegrationResult - evaluate_at implementation", + ), + ) end diff --git a/src/Integrators/sciml.jl b/src/Integrators/sciml.jl index fa9645ab..c087647a 100644 --- a/src/Integrators/sciml.jl +++ b/src/Integrators/sciml.jl @@ -53,7 +53,8 @@ To activate the extension, load any of: $(TYPEDFIELDS) """ -struct SciML{O<:Strategies.StrategyOptions, OP<:Dict{Symbol, Any}, OT<:Dict{Symbol, Any}} <: AbstractSciMLIntegrator +struct SciML{O<:Strategies.StrategyOptions,OP<:Dict{Symbol,Any},OT<:Dict{Symbol,Any}} <: + AbstractSciMLIntegrator "Validated option bundle." options::O "Pre-computed options for point (final-state) integration." @@ -79,9 +80,9 @@ $(TYPEDSIGNATURES) Return the description for the SciML integrator. """ function Strategies.description(::Type{<:SciML}) - "SciML ODE integrator.\n" * - "See: https://docs.sciml.ai/DiffEqDocs\n" * - "Solver options: https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/" + return "SciML ODE integrator.\n" * + "See: https://docs.sciml.ai/DiffEqDocs\n" * + "Solver options: https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/" end # ============================================================================ @@ -125,8 +126,8 @@ is overridden by the `CTSolversSciMLIntegrator` package extension. See also: [`CTSolvers.Integrators.SciML`](@ref), [`CTSolvers.Integrators.build_sciml_integrator`](@ref). """ -function SciML(; mode::Symbol = :strict, kwargs...) - return build_sciml_integrator(SciMLTag; mode = mode, kwargs...) +function SciML(; mode::Symbol=:strict, kwargs...) + return build_sciml_integrator(SciMLTag; mode=mode, kwargs...) end """ @@ -137,12 +138,12 @@ Stub builder for `SciML`. The real implementation is provided by is loaded. """ function build_sciml_integrator(::Type{<:Core.AbstractTag}; kwargs...) - throw( + return throw( Exceptions.ExtensionError( :OrdinaryDiffEqTsit5; - message = "to construct a SciML integrator", - feature = "ODE integration via SciML", - context = "Load OrdinaryDiffEqTsit5, OrdinaryDiffEq, or DifferentialEquations to activate the CTSolversSciMLIntegrator extension.", + message="to construct a SciML integrator", + feature="ODE integration via SciML", + context="Load OrdinaryDiffEqTsit5, OrdinaryDiffEq, or DifferentialEquations to activate the CTSolversSciMLIntegrator extension.", ), ) end @@ -159,7 +160,7 @@ not loaded. The real metadata implementation is provided by the extension. See also: [`CTSolvers.Integrators.SciML`](@ref), [`CTBase.Strategies.StrategyMetadata`](@extref). """ function Strategies.metadata(::Type{<:AbstractSciMLIntegrator}) - throw( + return throw( Exceptions.ExtensionError( :OrdinaryDiffEqTsit5; message="to access SciML options metadata", diff --git a/src/Modelers/adnlp.jl b/src/Modelers/adnlp.jl index 812bbce9..53464234 100644 --- a/src/Modelers/adnlp.jl +++ b/src/Modelers/adnlp.jl @@ -39,7 +39,7 @@ See also: [`CTSolvers.Modelers.get_adnlp_available_backends`](@ref), [`CTSolvers.Modelers.ADNLPTag`](@ref) """ function __get_adnlp_available_backends(::Type{<:Core.AbstractTag}) - throw( + return throw( Exceptions.ExtensionError( :ADNLPModels; message="to list available ADNLP backends", @@ -227,8 +227,8 @@ $(TYPEDSIGNATURES) Return the description for the ADNLP modeler. """ function Strategies.description(::Type{<:Modelers.ADNLP}) - "NLP modeler using ADNLPModels with automatic differentiation.\n" * - "See: https://jso.dev/ADNLPModels.jl" + return "NLP modeler using ADNLPModels with automatic differentiation.\n" * + "See: https://jso.dev/ADNLPModels.jl" end """ @@ -259,7 +259,7 @@ Stub — real implementation provided by the CTSolversADNLPModels extension. See also: `Modelers.ADNLP`, `Strategies.StrategyMetadata` """ function Strategies.metadata(::Type{<:Modelers.ADNLP{P}}) where {P<:CPU} - throw( + return throw( Exceptions.ExtensionError( :ADNLPModels; message="to access ADNLP{$P} options metadata", @@ -320,7 +320,7 @@ See also: `Modelers.ADNLP`, `Strategies.metadata` function build_adnlp_modeler( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :ADNLPModels; message="to create ADNLP, access options, and build NLP models", diff --git a/src/Modelers/contract.jl b/src/Modelers/contract.jl index 34f66a61..02ed2a1d 100644 --- a/src/Modelers/contract.jl +++ b/src/Modelers/contract.jl @@ -39,9 +39,11 @@ generic stub throws [`CTBase.Exceptions.NotImplemented`](@extref). See also: [`CTSolvers.Optimization.build_solution`](@ref), [`CTSolvers.Optimization.BuiltModel`](@ref). """ function Optimization.build_model( - prob::Optimization.AbstractOptimizationProblem, initial_guess, modeler::AbstractNLPModeler + prob::Optimization.AbstractOptimizationProblem, + initial_guess, + modeler::AbstractNLPModeler, ) - throw( + return throw( Exceptions.NotImplemented( "Model building not implemented"; required_method="Optimization.build_model(prob::$(typeof(prob)), initial_guess, modeler::$(typeof(modeler)))", @@ -85,7 +87,7 @@ See also: [`CTSolvers.Optimization.build_model`](@ref), [`CTSolvers.Optimization function Optimization.build_solution( built::Optimization.BuiltModel, model_solution, modeler::AbstractNLPModeler ) - throw( + return throw( Exceptions.NotImplemented( "Solution building not implemented"; required_method="Optimization.build_solution(built::BuiltModel{$(typeof(built.problem))}, model_solution, modeler::$(typeof(modeler)))", diff --git a/src/Modelers/exa.jl b/src/Modelers/exa.jl index 717c5e88..aef5b772 100644 --- a/src/Modelers/exa.jl +++ b/src/Modelers/exa.jl @@ -72,7 +72,7 @@ and returns an appropriate CUDA backend. - Uses CUDA.CUDABackend() for GPU execution """ function __get_cuda_backend(::Type{<:GPU}) - throw( + return throw( Exceptions.ExtensionError( :CUDA; message="to use GPU backend with Exa modeler", @@ -237,8 +237,8 @@ $(TYPEDSIGNATURES) Return the description for the Exa modeler. """ function Strategies.description(::Type{<:Modelers.Exa}) - "NLP modeler using ExaModels, supporting CPU and GPU execution.\n" * - "See: https://exanauts.github.io/ExaModels.jl" + return "NLP modeler using ExaModels, supporting CPU and GPU execution.\n" * + "See: https://exanauts.github.io/ExaModels.jl" end """ @@ -269,7 +269,7 @@ Stub — real implementation provided by the CTSolversExaModels extension. See also: `Modelers.Exa`, `Strategies.StrategyMetadata` """ function Strategies.metadata(::Type{<:Modelers.Exa{P}}) where {P<:Union{CPU,GPU}} - throw( + return throw( Exceptions.ExtensionError( :ExaModels; message="to access Exa{$P} options metadata", @@ -340,7 +340,7 @@ See also: `Modelers.Exa`, `Strategies.metadata` function build_exa_modeler( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :ExaModels; message="to create Exa, access options, and build NLP models", diff --git a/src/Modelers/validation.jl b/src/Modelers/validation.jl index fcf77861..274b84f9 100644 --- a/src/Modelers/validation.jl +++ b/src/Modelers/validation.jl @@ -27,7 +27,7 @@ See also: `validate_adnlp_backend(::Core.AbstractTag, ::Val{:default})`, `get_va """ function validate_adnlp_backend(tag::Core.AbstractTag, backend::Val) # This is the generic fallback - should never be reached - throw( + return throw( Exceptions.IncorrectArgument( "Invalid ADNLPModels backend"; got="backend=$(backend)", @@ -85,7 +85,7 @@ Validate Enzyme backend using tag dispatch. See also: `validate_adnlp_backend(::Core.AbstractTag, ::Val{:zygote})`, `get_validate_adnlp_backend` """ function validate_adnlp_backend(tag::Core.AbstractTag, ::Val{:enzyme}) - throw( + return throw( Exceptions.ExtensionError( :Enzyme; message="to use Enzyme backend with ADNLP modeler", @@ -115,7 +115,7 @@ Validate Zygote backend using tag dispatch. See also: `validate_adnlp_backend(::Core.AbstractTag, ::Val{:enzyme})`, `get_validate_adnlp_backend` """ function validate_adnlp_backend(tag::Core.AbstractTag, ::Val{:zygote}) - throw( + return throw( Exceptions.ExtensionError( :Zygote; message="to use Zygote backend with ADNLP modeler", @@ -182,7 +182,7 @@ Fallback method for invalid base types in ExaModels validation. See also: `validate_exa_base_type(::Type{<:AbstractFloat})` """ function validate_exa_base_type(T) - throw( + return throw( Exceptions.IncorrectArgument( "Invalid base type for Modelers.Exa"; got="base_type=$T", @@ -351,7 +351,7 @@ function validate_backend_override(backend) isa(backend, Type) && __is_adbackend_type(backend) && return backend # Accept an ADBackend instance (e.g., ForwardDiffADGradient()) __is_adbackend_instance(backend) && return backend - throw( + return throw( Exceptions.IncorrectArgument( "Backend override must be nothing, a Type{<:ADBackend}, or an ADBackend instance"; got=string(typeof(backend)), diff --git a/src/Solvers/contract.jl b/src/Solvers/contract.jl index 680fe128..f19f7218 100644 --- a/src/Solvers/contract.jl +++ b/src/Solvers/contract.jl @@ -40,7 +40,7 @@ the `CTSolversIpopt` extension. This generic stub throws `NotImplemented`. See also: `AbstractNLPSolver`. """ function CommonSolve.solve(nlp, solver::AbstractNLPSolver; display::Bool=__display()) - throw( + return throw( Exceptions.NotImplemented( "Solve not implemented for this solver"; required_method="CommonSolve.solve(nlp, solver::$(typeof(solver)); display)", diff --git a/src/Solvers/ipopt.jl b/src/Solvers/ipopt.jl index 16613172..16d57028 100644 --- a/src/Solvers/ipopt.jl +++ b/src/Solvers/ipopt.jl @@ -128,8 +128,8 @@ $(TYPEDSIGNATURES) Return the description for the Ipopt solver. """ function Strategies.description(::Type{<:Solvers.Ipopt}) - "Interior-point NLP solver (COIN-OR Ipopt).\n" * - "See: https://coin-or.github.io/Ipopt/OPTIONS.html" + return "Interior-point NLP solver (COIN-OR Ipopt).\n" * + "See: https://coin-or.github.io/Ipopt/OPTIONS.html" end """ @@ -229,7 +229,7 @@ See also: `Ipopt`, `Strategies.metadata` function build_ipopt_solver( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :NLPModelsIpopt; message="to create Ipopt, access options, and solve problems", @@ -254,7 +254,7 @@ See also: `Ipopt`, `Strategies.StrategyMetadata` """ function Strategies.metadata(::Type{<:Solvers.Ipopt{P}}) where {P<:CPU} # Extension is missing - throw( + return throw( Exceptions.ExtensionError( :NLPModelsIpopt; message="to access Ipopt{$P} options metadata", diff --git a/src/Solvers/knitro.jl b/src/Solvers/knitro.jl index ea8716a8..a7a75dda 100644 --- a/src/Solvers/knitro.jl +++ b/src/Solvers/knitro.jl @@ -131,8 +131,8 @@ $(TYPEDSIGNATURES) Return the description for the Knitro solver. """ function Strategies.description(::Type{<:Solvers.Knitro}) - "Commercial NLP solver by Artelys (requires license).\n" * - "See: https://www.artelys.com/app/docs/knitro/3_referenceManual/userOptions.html" + return "Commercial NLP solver by Artelys (requires license).\n" * + "See: https://www.artelys.com/app/docs/knitro/3_referenceManual/userOptions.html" end """ @@ -232,7 +232,7 @@ See also: `Knitro`, `Strategies.metadata` function build_knitro_solver( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :NLPModelsKnitro; message="to create Knitro, access options, and solve problems", @@ -257,7 +257,7 @@ See also: `Knitro`, `Strategies.StrategyMetadata` """ function Strategies.metadata(::Type{<:Solvers.Knitro{P}}) where {P<:CPU} # Extension is missing - throw( + return throw( Exceptions.ExtensionError( :NLPModelsKnitro; message="to access Knitro{$P} options metadata", diff --git a/src/Solvers/madncl.jl b/src/Solvers/madncl.jl index 397bd731..40553c31 100644 --- a/src/Solvers/madncl.jl +++ b/src/Solvers/madncl.jl @@ -90,8 +90,8 @@ $(TYPEDSIGNATURES) Return the description for the MadNCL solver. """ function Strategies.description(::Type{<:Solvers.MadNCL}) - "Augmented Lagrangian NLP solver built on MadNLP.\n" * - "See: https://github.com/MadNLP/MadNCL.jl" + return "Augmented Lagrangian NLP solver built on MadNLP.\n" * + "See: https://github.com/MadNLP/MadNCL.jl" end """ @@ -189,7 +189,7 @@ See also: `MadNCL`, `Strategies.metadata` function build_madncl_solver( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :MadNCL, :MadNLP; @@ -216,7 +216,7 @@ See also: `MadNCL`, `Strategies.StrategyMetadata` function Strategies.metadata( ::Type{<:Solvers.MadNCL{P}} ) where {P<:AbstractStrategyParameter} - throw( + return throw( Exceptions.ExtensionError( :MadNCL, :MadNLP; diff --git a/src/Solvers/madnlp.jl b/src/Solvers/madnlp.jl index c71f33e4..6af2d0da 100644 --- a/src/Solvers/madnlp.jl +++ b/src/Solvers/madnlp.jl @@ -96,8 +96,8 @@ $(TYPEDSIGNATURES) Return the description for the MadNLP solver. """ function Strategies.description(::Type{<:Solvers.MadNLP}) - "Interior-point NLP solver with sparse linear algebra and GPU support.\n" * - "See: https://madsuite.org/MadNLP.jl/stable/options/" + return "Interior-point NLP solver with sparse linear algebra and GPU support.\n" * + "See: https://madsuite.org/MadNLP.jl/stable/options/" end """ @@ -195,7 +195,7 @@ See also: `MadNLP`, `Strategies.metadata` function build_madnlp_solver( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :MadNLP; message="to create MadNLP, access options, and solve problems", @@ -221,7 +221,7 @@ See also: `MadNLP`, `Strategies.StrategyMetadata` function Strategies.metadata( ::Type{<:Solvers.MadNLP{P}} ) where {P<:AbstractStrategyParameter} - throw( + return throw( Exceptions.ExtensionError( :MadNLP; message="to access MadNLP{$P} options metadata", diff --git a/src/Solvers/madnlpsuite.jl b/src/Solvers/madnlpsuite.jl index 00c5ac2e..3487ce6f 100644 --- a/src/Solvers/madnlpsuite.jl +++ b/src/Solvers/madnlpsuite.jl @@ -25,7 +25,7 @@ Return the default linear solver for the given parameter type. - GPU implementation provided by CTSolversMadNLPGPU extension """ function __madnlp_suite_default_linear_solver(::Type{<:GPU}) - throw( + return throw( Exceptions.ExtensionError( :MadNLPGPU; message="to use GPU linear solver with MadNLP/MadNCL", diff --git a/src/Solvers/uno.jl b/src/Solvers/uno.jl index 4e648e18..2cda0653 100644 --- a/src/Solvers/uno.jl +++ b/src/Solvers/uno.jl @@ -157,8 +157,8 @@ $(TYPEDSIGNATURES) Return the description for the Uno solver. """ function Strategies.description(::Type{<:Solvers.Uno}) - "Unified modular NLP solver combining interior-point, SQP, trust-region and filter strategies.\n" * - "See: https://unosolver.readthedocs.io/en/latest/" + return "Unified modular NLP solver combining interior-point, SQP, trust-region and filter strategies.\n" * + "See: https://unosolver.readthedocs.io/en/latest/" end """ @@ -258,7 +258,7 @@ See also: `Uno`, `Strategies.metadata` function build_uno_solver( ::Type{<:Core.AbstractTag}, parameter::Type{<:AbstractStrategyParameter}; kwargs... ) - throw( + return throw( Exceptions.ExtensionError( :UnoSolver; message="to create Uno, access options, and solve problems", @@ -283,7 +283,7 @@ See also: `Uno`, `Strategies.StrategyMetadata` """ function Strategies.metadata(::Type{<:Solvers.Uno{P}}) where {P<:CPU} # Extension is missing - throw( + return throw( Exceptions.ExtensionError( :UnoSolver; message="to access Uno{$P} options metadata", diff --git a/test/problems/elec.jl b/test/problems/elec.jl index 65abab75..1f9c760d 100644 --- a/test/problems/elec.jl +++ b/test/problems/elec.jl @@ -2,7 +2,7 @@ using Random function elec_objective(x, y, z, i, j) - 1.0 / sqrt((x[i] - x[j])^2 + (y[i] - y[j])^2 + (z[i] - z[j])^2) + return 1.0 / sqrt((x[i] - x[j])^2 + (y[i] - y[j])^2 + (z[i] - z[j])^2) end elec_constraint(x, y, z, i) = x[i]^2 + y[i]^2 + z[i]^2 - 1.0 function elec_objective(x, y, z) diff --git a/test/suite/docp/test_docp.jl b/test/suite/docp/test_docp.jl index 80ceb329..5da0df55 100644 --- a/test/suite/docp/test_docp.jl +++ b/test/suite/docp/test_docp.jl @@ -6,7 +6,7 @@ using CTSolvers: CTSolvers import CTSolvers.DOCP import CTSolvers.Optimization import CTSolvers.Modelers -import CTBase +using CTBase: CTBase using NLPModels: NLPModels using SolverCore: SolverCore using ADNLPModels: ADNLPModels @@ -87,8 +87,9 @@ function Optimization.build_solution( end # Helper: build a DiscretizedModel around the fake OCP / discretizer / cache. -fake_docp(name::String="test_ocp") = - DOCP.DiscretizedModel(FakeOCP(name), FakeDiscretizer(), FakeCache()) +function fake_docp(name::String="test_ocp") + return DOCP.DiscretizedModel(FakeOCP(name), FakeDiscretizer(), FakeCache()) +end # ============================================================================ # TEST FUNCTION diff --git a/test/suite/extensions/test_generic_extract_solver_infos.jl b/test/suite/extensions/test_generic_extract_solver_infos.jl index 7e3d82cb..1b5d495d 100644 --- a/test/suite/extensions/test_generic_extract_solver_infos.jl +++ b/test/suite/extensions/test_generic_extract_solver_infos.jl @@ -102,9 +102,7 @@ function test_generic_extract_solver_infos() # Test successful status: :acceptable stats_acceptable = create_mock_stats(1.5, 5, 1e-6, :acceptable) - _, _, _, _, stat2, success2 = Solvers.extract_solver_infos( - stats_acceptable - ) + _, _, _, _, stat2, success2 = Solvers.extract_solver_infos(stats_acceptable) Test.@test success2 == true Test.@test stat2 == :acceptable @@ -118,9 +116,7 @@ function test_generic_extract_solver_infos() # Test unsuccessful status: :infeasible stats_infeasible = create_mock_stats(1.5, 50, 1e-1, :infeasible) - _, _, _, _, stat4, success4 = Solvers.extract_solver_infos( - stats_infeasible - ) + _, _, _, _, stat4, success4 = Solvers.extract_solver_infos(stats_infeasible) Test.@test success4 == false Test.@test stat4 == :infeasible diff --git a/test/suite/extensions/test_ipopt_extension.jl b/test/suite/extensions/test_ipopt_extension.jl index 8894a178..6ba85272 100644 --- a/test/suite/extensions/test_ipopt_extension.jl +++ b/test/suite/extensions/test_ipopt_extension.jl @@ -144,7 +144,9 @@ function test_ipopt_extension() ros = TestProblems.Rosenbrock() # Build NLP model from problem - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Create solver with appropriate options @@ -170,7 +172,9 @@ function test_ipopt_extension() elec = TestProblems.Elec() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(elec.init) solver = Solvers.Ipopt(max_iter=1000, tol=1e-6, print_level=0) @@ -185,7 +189,9 @@ function test_ipopt_extension() max_prob = TestProblems.Max1MinusX2() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(max_prob.init) solver = Solvers.Ipopt(max_iter=1000, tol=1e-6, print_level=0) @@ -232,7 +238,8 @@ function test_ipopt_extension() # Build NLP models nlp1 = Optimization.build_model(ros.prob, ros.init, Modelers.ADNLP()).nlp - nlp2 = Optimization.build_model(max_prob.prob, max_prob.init, Modelers.ADNLP()).nlp + nlp2 = + Optimization.build_model(max_prob.prob, max_prob.init, Modelers.ADNLP()).nlp stats1 = CommonSolve.solve(nlp1, solver; display=false) stats2 = CommonSolve.solve(nlp2, solver; display=false) @@ -327,9 +334,8 @@ function test_ipopt_extension() max_prob = TestProblems.Max1MinusX2() for (modeler, modeler_name) in zip(modelers, modelers_names) Test.@testset "$(modeler_name)" verbose=VERBOSE showtiming=SHOWTIMING begin - nlp = Optimization.build_model( - max_prob.prob, max_prob.init, modeler - ).nlp + nlp = + Optimization.build_model(max_prob.prob, max_prob.init, modeler).nlp sol = CTSolversIpopt.solve_with_ipopt(nlp; ipopt_options...) Test.@test sol.status == :first_order Test.@test length(sol.solution) == 1 @@ -484,7 +490,9 @@ function test_ipopt_extension() Test.@testset "Pass-through Verification" begin ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Test derivative_test="first-order" @@ -514,7 +522,9 @@ function test_ipopt_extension() Test.@testset "Exhaustive Options Validation" begin ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Define all options with valid values to check for typos in names diff --git a/test/suite/extensions/test_madncl_extension.jl b/test/suite/extensions/test_madncl_extension.jl index 795f97c0..a0441a26 100644 --- a/test/suite/extensions/test_madncl_extension.jl +++ b/test/suite/extensions/test_madncl_extension.jl @@ -70,12 +70,10 @@ function test_madncl_extension() Test.@test :jacobian_constant in keys(meta) Test.@test Options.default(meta[:bound_push]) isa Core.NotProvidedType Test.@test Options.default(meta[:bound_fac]) isa Core.NotProvidedType - Test.@test Options.default(meta[:constr_mult_init_max]) isa - Core.NotProvidedType + Test.@test Options.default(meta[:constr_mult_init_max]) isa Core.NotProvidedType Test.@test Options.default(meta[:fixed_variable_treatment]) isa Core.NotProvidedType - Test.@test Options.default(meta[:equality_treatment]) isa - Core.NotProvidedType + Test.@test Options.default(meta[:equality_treatment]) isa Core.NotProvidedType Test.@test :kkt_system in keys(meta) Test.@test :hessian_approximation in keys(meta) Test.@test :mu_init in keys(meta) @@ -210,7 +208,9 @@ function test_madncl_extension() Test.@testset "MadNLP Option Pass-through" begin # Create a simple dummy problem ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # checking that it runs without error with these options @@ -230,7 +230,9 @@ function test_madncl_extension() # MadNCL requires problems with constraints # Using Elec problem which has constraints elec = TestProblems.Elec() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(elec.init) # Test with display=false sets print_level=MadNLP.ERROR @@ -250,7 +252,9 @@ function test_madncl_extension() ros = TestProblems.Rosenbrock() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) solver = Solvers.MadNCL(max_iter=1000, tol=1e-6, print_level=MadNLP.ERROR) @@ -266,7 +270,9 @@ function test_madncl_extension() elec = TestProblems.Elec() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(elec.init) solver = Solvers.MadNCL(max_iter=3000, tol=1e-6, print_level=MadNLP.ERROR) @@ -282,7 +288,9 @@ function test_madncl_extension() max_prob = TestProblems.Max1MinusX2() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(max_prob.init) solver = Solvers.MadNCL(max_iter=1000, tol=1e-6, print_level=MadNLP.ERROR) @@ -350,10 +358,14 @@ function test_madncl_extension() max_prob = TestProblems.Max1MinusX2() # Build NLP models - adnlp_builder1 = (init; kwargs...) -> Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp + adnlp_builder1 = + (init; kwargs...) -> + Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp nlp1 = adnlp_builder1(elec.init) - adnlp_builder2 = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder2 = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp2 = adnlp_builder2(max_prob.init) stats1 = CommonSolve.solve(nlp1, solver; display=false) @@ -431,7 +443,8 @@ function test_madncl_extension() for (linear_solver, linear_solver_name) in zip(linear_solvers, linear_solver_names) Test.@testset "$(modeler_name), $(linear_solver_name)" verbose=VERBOSE showtiming=SHOWTIMING begin - nlp = Optimization.build_model(elec.prob, elec.init, modeler).nlp + nlp = + Optimization.build_model(elec.prob, elec.init, modeler).nlp sol = CTSolversMadNCL.solve_with_madncl( nlp; linear_solver=linear_solver, madncl_options... ) @@ -525,9 +538,8 @@ function test_madncl_extension() Test.@testset "Max1MinusX2 - GPU" begin max_prob = TestProblems.Max1MinusX2() - nlp = Optimization.build_model( - max_prob.prob, max_prob.init, gpu_modeler - ).nlp + nlp = + Optimization.build_model(max_prob.prob, max_prob.init, gpu_modeler).nlp sol = CTSolversMadNCL.solve_with_madncl(nlp; madncl_options...) Test.@test sol.status == MadNLP.SOLVE_SUCCEEDED Test.@test length(sol.solution) == 1 diff --git a/test/suite/extensions/test_madncl_extract_solver_infos.jl b/test/suite/extensions/test_madncl_extract_solver_infos.jl index af964c26..a8fd1d42 100644 --- a/test/suite/extensions/test_madncl_extract_solver_infos.jl +++ b/test/suite/extensions/test_madncl_extract_solver_infos.jl @@ -37,7 +37,9 @@ function test_madncl_extract_solver_infos() ros = TestProblems.Rosenbrock() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Configure MadNCL options @@ -72,7 +74,9 @@ function test_madncl_extract_solver_infos() max_prob = TestProblems.Max1MinusX2() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(max_prob.init) # Verify it's a maximization problem @@ -125,7 +129,9 @@ function test_madncl_extract_solver_infos() # Unit test to verify that MadNCL does NOT flip the sign # (unlike MadNLP which has this bug) ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Configure MadNCL options @@ -155,7 +161,9 @@ function test_madncl_extract_solver_infos() Test.@testset "build_solution contract verification" begin # Test that extract_solver_infos returns types compatible with build_solution ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Configure MadNCL options @@ -187,7 +195,9 @@ function test_madncl_extract_solver_infos() # Test with maximization problem for contract compliance max_prob = TestProblems.Max1MinusX2() - adnlp_builder_max = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder_max = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp_max = adnlp_builder_max(max_prob.init) # Configure MadNCL options @@ -222,7 +232,9 @@ function test_madncl_extract_solver_infos() # Test with minimization (Rosenbrock) ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Configure MadNCL options @@ -258,7 +270,9 @@ function test_madncl_extract_solver_infos() # Test with maximization problem (Max1MinusX2) max_prob = TestProblems.Max1MinusX2() - adnlp_builder_max = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder_max = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp_max = adnlp_builder_max(max_prob.init) # Configure MadNCL options diff --git a/test/suite/extensions/test_madnlp_extension.jl b/test/suite/extensions/test_madnlp_extension.jl index 9b089ca2..b9bff34c 100644 --- a/test/suite/extensions/test_madnlp_extension.jl +++ b/test/suite/extensions/test_madnlp_extension.jl @@ -137,12 +137,10 @@ function test_madnlp_extension() # Test initialization defaults Test.@test Options.default(meta[:bound_push]) isa Core.NotProvidedType Test.@test Options.default(meta[:bound_fac]) isa Core.NotProvidedType - Test.@test Options.default(meta[:constr_mult_init_max]) isa - Core.NotProvidedType + Test.@test Options.default(meta[:constr_mult_init_max]) isa Core.NotProvidedType Test.@test Options.default(meta[:fixed_variable_treatment]) isa Core.NotProvidedType - Test.@test Options.default(meta[:equality_treatment]) isa - Core.NotProvidedType + Test.@test Options.default(meta[:equality_treatment]) isa Core.NotProvidedType end # ==================================================================== @@ -152,7 +150,7 @@ function test_madnlp_extension() Test.@testset "Contract validation" begin Test.@test Strategies.id(Solvers.MadNLP) isa Symbol Test.@test Strategies.metadata(Solvers.MadNLP) isa Strategies.StrategyMetadata - solver = Solvers.MadNLP(print_level = MadNLP.ERROR) + solver = Solvers.MadNLP(print_level=MadNLP.ERROR) Test.@test Strategies.options(solver) isa Strategies.StrategyOptions end @@ -222,7 +220,9 @@ function test_madnlp_extension() ros = TestProblems.Rosenbrock() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) solver = Solvers.MadNLP( @@ -245,7 +245,9 @@ function test_madnlp_extension() elec = TestProblems.Elec() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(elec.init) solver = Solvers.MadNLP(max_iter=1000, tol=1e-6, print_level=MadNLP.ERROR) @@ -261,7 +263,9 @@ function test_madnlp_extension() max_prob = TestProblems.Max1MinusX2() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(max_prob.init) solver = Solvers.MadNLP(max_iter=1000, tol=1e-6, print_level=MadNLP.ERROR) @@ -506,10 +510,14 @@ function test_madnlp_extension() max_prob = TestProblems.Max1MinusX2() # Build NLP models - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp1 = adnlp_builder(ros.init) - adnlp_builder2 = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder2 = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp2 = adnlp_builder2(max_prob.init) stats1 = CommonSolve.solve(nlp1, solver; display=false) @@ -614,7 +622,8 @@ function test_madnlp_extension() for (linear_solver, linear_solver_name) in zip(linear_solvers, linear_solver_names) Test.@testset "$(modeler_name), $(linear_solver_name)" verbose=VERBOSE showtiming=SHOWTIMING begin - nlp = Optimization.build_model(elec.prob, elec.init, modeler).nlp + nlp = + Optimization.build_model(elec.prob, elec.init, modeler).nlp sol = CTSolversMadNLP.solve_with_madnlp( nlp; linear_solver=linear_solver, madnlp_options... ) @@ -680,9 +689,8 @@ function test_madnlp_extension() Test.@testset "Max1MinusX2 - GPU" begin max_prob = TestProblems.Max1MinusX2() - nlp = Optimization.build_model( - max_prob.prob, max_prob.init, gpu_modeler - ).nlp + nlp = + Optimization.build_model(max_prob.prob, max_prob.init, gpu_modeler).nlp sol = CTSolversMadNLP.solve_with_madnlp(nlp; madnlp_options...) Test.@test sol.status == MadNLP.SOLVE_SUCCEEDED Test.@test length(sol.solution) == 1 diff --git a/test/suite/extensions/test_madnlp_extract_solver_infos.jl b/test/suite/extensions/test_madnlp_extract_solver_infos.jl index c97fef58..7e60e33a 100644 --- a/test/suite/extensions/test_madnlp_extract_solver_infos.jl +++ b/test/suite/extensions/test_madnlp_extract_solver_infos.jl @@ -232,9 +232,7 @@ function test_madnlp_extract_solver_infos() stats_max = MadNLP.solve!(solver_max) # Extract solver infos - objective_extracted, _, _, _, _, _ = Solvers.extract_solver_infos( - stats_max - ) + objective_extracted, _, _, _, _, _ = Solvers.extract_solver_infos(stats_max) # The extracted objective should be the true maximization objective (≈ 1.0) Test.@test objective_extracted ≈ 1.0 atol=1e-6 diff --git a/test/suite/extensions/test_uno_extension.jl b/test/suite/extensions/test_uno_extension.jl index 4625be39..e0f9fa83 100644 --- a/test/suite/extensions/test_uno_extension.jl +++ b/test/suite/extensions/test_uno_extension.jl @@ -197,7 +197,9 @@ function test_uno_extension() ros = TestProblems.Rosenbrock() # Build NLP model from problem - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Create solver with appropriate options @@ -222,7 +224,9 @@ function test_uno_extension() elec = TestProblems.Elec() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(elec.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(elec.init) solver = Solvers.Uno( @@ -239,7 +243,9 @@ function test_uno_extension() max_prob = TestProblems.Max1MinusX2() # Build NLP model - adnlp_builder = (init; kwargs...) -> Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(max_prob.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(max_prob.init) solver = Solvers.Uno( @@ -290,7 +296,8 @@ function test_uno_extension() # Build NLP models nlp1 = Optimization.build_model(ros.prob, ros.init, Modelers.ADNLP()).nlp - nlp2 = Optimization.build_model(max_prob.prob, max_prob.init, Modelers.ADNLP()).nlp + nlp2 = + Optimization.build_model(max_prob.prob, max_prob.init, Modelers.ADNLP()).nlp stats1 = CommonSolve.solve(nlp1, solver; display=false) stats2 = CommonSolve.solve(nlp2, solver; display=false) @@ -390,9 +397,8 @@ function test_uno_extension() max_prob = TestProblems.Max1MinusX2() for (modeler, modeler_name) in zip(modelers, modelers_names) Test.@testset "$(modeler_name)" verbose=VERBOSE showtiming=SHOWTIMING begin - nlp = Optimization.build_model( - max_prob.prob, max_prob.init, modeler - ).nlp + nlp = + Optimization.build_model(max_prob.prob, max_prob.init, modeler).nlp sol = CTSolversUno.solve_with_uno(nlp; uno_options...) # solve_with_uno now returns GenericExecutionStats Test.@test sol.status in (:first_order, :acceptable) @@ -524,7 +530,9 @@ function test_uno_extension() Test.@testset "Exhaustive Options Validation" begin ros = TestProblems.Rosenbrock() - adnlp_builder = (init; kwargs...) -> Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp + adnlp_builder = + (init; kwargs...) -> + Optimization.build_model(ros.prob, init, Modelers.ADNLP()).nlp nlp = adnlp_builder(ros.init) # Define all options with valid values to check for typos in names diff --git a/test/suite/integration/test_comprehensive_validation.jl b/test/suite/integration/test_comprehensive_validation.jl index 4066a4dd..fc198bdf 100644 --- a/test/suite/integration/test_comprehensive_validation.jl +++ b/test/suite/integration/test_comprehensive_validation.jl @@ -859,5 +859,5 @@ end # module # Redefine in outer scope for TestRunner function test_comprehensive_validation() - TestComprehensiveValidation.test_comprehensive_validation() + return TestComprehensiveValidation.test_comprehensive_validation() end diff --git a/test/suite/integration/test_end_to_end.jl b/test/suite/integration/test_end_to_end.jl index 6d643714..5038a291 100644 --- a/test/suite/integration/test_end_to_end.jl +++ b/test/suite/integration/test_end_to_end.jl @@ -70,9 +70,7 @@ function test_end_to_end() result = MadNLP.solve!(solver) # Step 10: Extract solver info - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - result - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(result) Test.@test obj isa Float64 Test.@test iter isa Int @@ -189,7 +187,8 @@ function test_end_to_end() # Test with different backends (all valid ADNLPModels backends) for backend in [:optimized, :generic, :default] modeler_backend = Modelers.ADNLP(backend=backend, show_time=false) - nlp_backend = Optimization.build_model(prob, ros.init, modeler_backend).nlp + nlp_backend = + Optimization.build_model(prob, ros.init, modeler_backend).nlp Test.@test nlp_backend isa ADNLPModels.ADNLPModel obj = NLPModels.obj(nlp_backend, ros.init) diff --git a/test/suite/integration/test_mode_propagation.jl b/test/suite/integration/test_mode_propagation.jl index 92d67100..0bd848e6 100644 --- a/test/suite/integration/test_mode_propagation.jl +++ b/test/suite/integration/test_mode_propagation.jl @@ -45,7 +45,7 @@ end function FakeStrategy(; mode::Symbol=:strict, kwargs...) # Redirect warnings to avoid polluting test output opts = redirect_stderr(devnull) do - Strategies.build_strategy_options(FakeStrategy; mode=mode, kwargs...) + return Strategies.build_strategy_options(FakeStrategy; mode=mode, kwargs...) end return FakeStrategy(opts) end diff --git a/test/suite/integration/test_route_to_comprehensive.jl b/test/suite/integration/test_route_to_comprehensive.jl index bcf8ae09..85a36987 100644 --- a/test/suite/integration/test_route_to_comprehensive.jl +++ b/test/suite/integration/test_route_to_comprehensive.jl @@ -115,7 +115,7 @@ end # Define metadata with option conflicts function Strategies.metadata(::Type{RouteCollocation}) - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:grid_size, type=Int, default=100, description="Grid size" ), @@ -123,7 +123,7 @@ function Strategies.metadata(::Type{RouteCollocation}) end function Strategies.metadata(::Type{RouteADNLP}) - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:backend, type=Symbol, default=:dense, description="Modeler backend" ), @@ -134,7 +134,7 @@ function Strategies.metadata(::Type{RouteADNLP}) end function Strategies.metadata(::Type{RouteIpopt}) - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:backend, type=Symbol, default=:cpu, description="Solver backend" ), @@ -148,7 +148,7 @@ function Strategies.metadata(::Type{RouteIpopt}) end function Strategies.metadata(::Type{RouteMadNLP}) - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:backend, type=Symbol, default=:cpu, description="Solver backend" ), diff --git a/test/suite/integration/test_strict_permissive_integration.jl b/test/suite/integration/test_strict_permissive_integration.jl index d2da6d5e..59ec5e98 100644 --- a/test/suite/integration/test_strict_permissive_integration.jl +++ b/test/suite/integration/test_strict_permissive_integration.jl @@ -514,5 +514,5 @@ end # module # Export test function to outer scope function test_strict_permissive_integration() - TestStrictPermissiveIntegration.test_strict_permissive_integration() + return TestStrictPermissiveIntegration.test_strict_permissive_integration() end diff --git a/test/suite/integrators/test_integrator_exports.jl b/test/suite/integrators/test_integrator_exports.jl index 3df49901..ac101e72 100644 --- a/test/suite/integrators/test_integrator_exports.jl +++ b/test/suite/integrators/test_integrator_exports.jl @@ -24,11 +24,8 @@ function test_integrator_exports() # ==================================================================== Test.@testset "Exported abstract types" begin - for sym in ( - :AbstractIntegrator, - :AbstractSciMLIntegrator, - :AbstractIntegrationResult, - ) + for sym in + (:AbstractIntegrator, :AbstractSciMLIntegrator, :AbstractIntegrationResult) Test.@testset "$sym" begin Test.@test sym in names(Integrators) Test.@test isdefined(Integrators, sym) @@ -76,12 +73,7 @@ function test_integrator_exports() # ==================================================================== Test.@testset "Internal symbols (not exported)" begin - for sym in ( - :__unsafe, - :__default_sciml_algorithm, - :deepvalue, - :real_norm, - ) + for sym in (:__unsafe, :__default_sciml_algorithm, :deepvalue, :real_norm) Test.@testset "$sym" begin Test.@test isdefined(Integrators, sym) Test.@test !(sym in names(Integrators)) @@ -95,10 +87,17 @@ function test_integrator_exports() Test.@testset "No top-level re-exports from CTSolvers" begin for sym in ( - :SciML, :SciMLTag, :Tsit5Tag, - :AbstractIntegrator, :AbstractIntegrationResult, - :final_state, :times, :evaluate_at, - :build_integrator, :options_point, :options_trajectory, + :SciML, + :SciMLTag, + :Tsit5Tag, + :AbstractIntegrator, + :AbstractIntegrationResult, + :final_state, + :times, + :evaluate_at, + :build_integrator, + :options_point, + :options_trajectory, ) Test.@test !(sym in names(CTSolvers)) end diff --git a/test/suite/integrators/test_integrator_forwarddiff.jl b/test/suite/integrators/test_integrator_forwarddiff.jl index bb857f49..d776d891 100644 --- a/test/suite/integrators/test_integrator_forwarddiff.jl +++ b/test/suite/integrators/test_integrator_forwarddiff.jl @@ -1,9 +1,9 @@ module TestIntegratorForwardDiff using Test: Test -import ForwardDiff +using ForwardDiff: ForwardDiff import CTSolvers.Integrators -import CommonSolve +using CommonSolve: CommonSolve using OrdinaryDiffEqTsit5: OrdinaryDiffEqTsit5, Tsit5 using SciMLBase: SciMLBase, ODEProblem using DiffEqBase: DiffEqBase diff --git a/test/suite/integrators/test_integrator_metadata.jl b/test/suite/integrators/test_integrator_metadata.jl index 22c399bb..168ab136 100644 --- a/test/suite/integrators/test_integrator_metadata.jl +++ b/test/suite/integrators/test_integrator_metadata.jl @@ -66,16 +66,18 @@ function test_integrator_metadata() Test.@testset "option validation" begin # strict mode (default): invalid value rejected at construction - Test.@test_throws Exceptions.IncorrectArgument Integrators.SciML(; alg=Tsit5(), reltol=-1.0) + Test.@test_throws Exceptions.IncorrectArgument Integrators.SciML(; + alg=Tsit5(), reltol=-1.0 + ) # strict mode: unknown option also rejected Test.@test_throws Exceptions.IncorrectArgument Integrators.SciML(; - alg=Tsit5(), unknown_option=42, + alg=Tsit5(), unknown_option=42 ) # permissive mode: unknown options accepted (with warning), value validation still applies Test.@test_logs (:warn, r"") match_mode=:any Integrators.SciML(; - alg=Tsit5(), unknown_option=42, mode=:permissive, + alg=Tsit5(), unknown_option=42, mode=:permissive ) end end diff --git a/test/suite/integrators/test_integrator_solve.jl b/test/suite/integrators/test_integrator_solve.jl index aa6ac479..d435f452 100644 --- a/test/suite/integrators/test_integrator_solve.jl +++ b/test/suite/integrators/test_integrator_solve.jl @@ -3,7 +3,7 @@ module TestIntegratorSolve using Test: Test import CTBase.Exceptions import CTSolvers.Integrators -import CommonSolve +using CommonSolve: CommonSolve using OrdinaryDiffEqTsit5: OrdinaryDiffEqTsit5, Tsit5 using SciMLBase: SciMLBase, ODEProblem using DiffEqBase: DiffEqBase @@ -21,7 +21,6 @@ against the known analytic solution u' = -u, u(0) = 1 ⇒ u(1) = exp(-1). """ function test_integrator_solve() Test.@testset "Integrator Solve (end-to-end)" verbose=VERBOSE showtiming=SHOWTIMING begin - integ = Integrators.SciML(; alg=Tsit5()) prob = ODEProblem((u, p, t) -> -u, [1.0], (0.0, 1.0)) @@ -88,11 +87,12 @@ function test_integrator_solve() # maxiters=1 forces an unsuccessful retcode bad = ODEProblem((u, p, t) -> -u, [1.0], (0.0, 1.0)) Test.@test_throws Exceptions.SolverFailure CommonSolve.solve( - bad, integ; options=Dict{Symbol,Any}(:alg => Tsit5(), :maxiters => 1), + bad, integ; options=Dict{Symbol,Any}(:alg => Tsit5(), :maxiters => 1) ) # unsafe=true bypasses the check r = CommonSolve.solve( - bad, integ; + bad, + integ; options=Dict{Symbol,Any}(:alg => Tsit5(), :maxiters => 1), unsafe=true, ) diff --git a/test/suite/integrators/test_integrator_stubs.jl b/test/suite/integrators/test_integrator_stubs.jl index 77635fa6..f5470fc4 100644 --- a/test/suite/integrators/test_integrator_stubs.jl +++ b/test/suite/integrators/test_integrator_stubs.jl @@ -4,7 +4,7 @@ using Test: Test import CTBase.Core import CTBase.Exceptions import CTSolvers.Integrators -import CommonSolve +using CommonSolve: CommonSolve const VERBOSE = isdefined(Main, :TestData) ? Main.TestData.VERBOSE : true const SHOWTIMING = isdefined(Main, :TestData) ? Main.TestData.SHOWTIMING : true @@ -33,7 +33,9 @@ function test_integrator_stubs() # ==================================================================== Test.@testset "build_sciml_integrator stub" begin - Test.@test_throws Exceptions.ExtensionError Integrators.build_sciml_integrator(DummyTag) + Test.@test_throws Exceptions.ExtensionError Integrators.build_sciml_integrator( + DummyTag + ) err = nothing try @@ -60,7 +62,9 @@ function test_integrator_stubs() # ==================================================================== Test.@testset "solve generic stub" begin - Test.@test_throws Exceptions.NotImplemented CommonSolve.solve(nothing, FakeIntegrator()) + Test.@test_throws Exceptions.NotImplemented CommonSolve.solve( + nothing, FakeIntegrator() + ) end # ==================================================================== @@ -76,9 +80,13 @@ function test_integrator_stubs() # ==================================================================== Test.@testset "result accessor stubs" begin - Test.@test_throws Exceptions.NotImplemented Integrators.final_state(FakeResult()) + Test.@test_throws Exceptions.NotImplemented Integrators.final_state( + FakeResult() + ) Test.@test_throws Exceptions.NotImplemented Integrators.times(FakeResult()) - Test.@test_throws Exceptions.NotImplemented Integrators.evaluate_at(FakeResult(), 0.0) + Test.@test_throws Exceptions.NotImplemented Integrators.evaluate_at( + FakeResult(), 0.0 + ) end end end diff --git a/test/suite/integrators/test_integrator_type_stability.jl b/test/suite/integrators/test_integrator_type_stability.jl index a5f042b6..4724d551 100644 --- a/test/suite/integrators/test_integrator_type_stability.jl +++ b/test/suite/integrators/test_integrator_type_stability.jl @@ -6,7 +6,7 @@ import CTBase.Strategies using OrdinaryDiffEqTsit5: OrdinaryDiffEqTsit5, Tsit5 using SciMLBase: SciMLBase, ODEProblem using DiffEqBase: DiffEqBase -import CommonSolve +using CommonSolve: CommonSolve const VERBOSE = isdefined(Main, :TestData) ? Main.TestData.VERBOSE : true const SHOWTIMING = isdefined(Main, :TestData) ? Main.TestData.SHOWTIMING : true @@ -44,7 +44,8 @@ function test_type_stability() Test.@test_nowarn Test.@inferred Integrators.options_point(integ) Test.@test_nowarn Test.@inferred Integrators.options_trajectory(integ) Test.@test Test.@inferred(Integrators.options_point(integ)) isa Dict{Symbol,Any} - Test.@test Test.@inferred(Integrators.options_trajectory(integ)) isa Dict{Symbol,Any} + Test.@test Test.@inferred(Integrators.options_trajectory(integ)) isa + Dict{Symbol,Any} end # ==================================================================== diff --git a/test/suite/integrators/test_internal_norm.jl b/test/suite/integrators/test_internal_norm.jl index 0237b95e..43c90970 100644 --- a/test/suite/integrators/test_internal_norm.jl +++ b/test/suite/integrators/test_internal_norm.jl @@ -2,7 +2,7 @@ module TestInternalNorm using Test: Test import CTSolvers.Integrators -import ForwardDiff +using ForwardDiff: ForwardDiff using DiffEqBase: DiffEqBase # activates the array real_norm overload const VERBOSE = isdefined(Main, :TestData) ? Main.TestData.VERBOSE : true @@ -50,7 +50,8 @@ function test_internal_norm() Test.@testset "array grid invariance" begin u_real = [1.0, 2.0, 3.0] u_dual = ForwardDiff.Dual{:T}.(u_real, ones(3)) - Test.@test Integrators.real_norm(u_real, 0.0) ≈ Integrators.real_norm(u_dual, 0.0) + Test.@test Integrators.real_norm(u_real, 0.0) ≈ + Integrators.real_norm(u_dual, 0.0) end end end diff --git a/test/suite/modelers/test_adnlp_parameter_validation.jl b/test/suite/modelers/test_adnlp_parameter_validation.jl index 3ecfc917..b9714ae9 100644 --- a/test/suite/modelers/test_adnlp_parameter_validation.jl +++ b/test/suite/modelers/test_adnlp_parameter_validation.jl @@ -203,5 +203,5 @@ end end # module function test_adnlp_parameter_validation() - TestADNLPParameterValidation.test_adnlp_parameter_validation() + return TestADNLPParameterValidation.test_adnlp_parameter_validation() end diff --git a/test/suite/modelers/test_internal_defaults_coverage.jl b/test/suite/modelers/test_internal_defaults_coverage.jl index 6cfc94de..6ba18617 100644 --- a/test/suite/modelers/test_internal_defaults_coverage.jl +++ b/test/suite/modelers/test_internal_defaults_coverage.jl @@ -46,5 +46,5 @@ end end # module function test_internal_defaults_coverage() - TestInternalDefaultsCoverage.test_internal_defaults_coverage() + return TestInternalDefaultsCoverage.test_internal_defaults_coverage() end diff --git a/test/suite/optimization/test_error_cases.jl b/test/suite/optimization/test_error_cases.jl index f991f270..b2447a75 100644 --- a/test/suite/optimization/test_error_cases.jl +++ b/test/suite/optimization/test_error_cases.jl @@ -60,7 +60,9 @@ function Optimization.build_model(prob::SquaresProblem, initial_guess, ::Modeler return Optimization.BuiltModel(prob, nlp, Optimization.NoCache()) end -function Optimization.build_model(prob::SquaresProblem, initial_guess, modeler::Modelers.Exa) +function Optimization.build_model( + prob::SquaresProblem, initial_guess, modeler::Modelers.Exa +) T = modeler[:base_type] x = T.(initial_guess) m = ExaModels.ExaCore(T; concrete=Val(true)) @@ -207,36 +209,28 @@ function test_error_cases() Test.@testset "Solver Info Edge Cases" begin Test.@testset "Zero iterations" begin stats = create_edge_case_stats(0.0, 0, 0.0, :first_order) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test iter == 0 Test.@test success == true end Test.@testset "Very large objective" begin stats = create_edge_case_stats(1e100, 10, 1e-6, :first_order) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test obj ≈ 1e100 Test.@test success == true end Test.@testset "Very small constraint violation" begin stats = create_edge_case_stats(1.0, 10, 1e-15, :first_order) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test viol ≈ 1e-15 Test.@test success == true end Test.@testset "Unknown status" begin stats = create_edge_case_stats(1.0, 10, 1e-6, :unknown_status) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test status == :unknown_status Test.@test success == false # Not :first_order or :acceptable end diff --git a/test/suite/optimization/test_optimization.jl b/test/suite/optimization/test_optimization.jl index 7bf144cb..9aa74154 100644 --- a/test/suite/optimization/test_optimization.jl +++ b/test/suite/optimization/test_optimization.jl @@ -137,7 +137,9 @@ function test_optimization() ) built = Optimization.BuiltModel(prob, nothing, Optimization.NoCache()) Test.@test_throws Exceptions.NotImplemented Optimization.build_solution( - built, create_mock_execution_stats(1.0, 1, 1e-6, :first_order), FakeModeler(:adnlp) + built, + create_mock_execution_stats(1.0, 1, 1e-6, :first_order), + FakeModeler(:adnlp), ) end @@ -189,9 +191,7 @@ function test_optimization() Test.@testset "Solver Info Extraction" begin Test.@testset "extract_solver_infos - first_order status" begin stats = create_mock_execution_stats(1.23, 15, 1.0e-6, :first_order) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test obj ≈ 1.23 Test.@test iter == 15 Test.@test viol ≈ 1.0e-6 @@ -203,9 +203,7 @@ function test_optimization() Test.@testset "extract_solver_infos - acceptable status" begin stats = create_mock_execution_stats(2.34, 20, 1.0e-5, :acceptable) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test obj ≈ 2.34 Test.@test status == :acceptable Test.@test success == true @@ -213,9 +211,7 @@ function test_optimization() Test.@testset "extract_solver_infos - failure status" begin stats = create_mock_execution_stats(3.45, 5, 1.0e-3, :max_iter) - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test obj ≈ 3.45 Test.@test status == :max_iter Test.@test success == false @@ -241,9 +237,7 @@ function test_optimization() Test.@test sol.obj ≈ 5.0 Test.@test sol.status == :first_order - obj, iter, viol, msg, status, success = Solvers.extract_solver_infos( - stats - ) + obj, iter, viol, msg, status, success = Solvers.extract_solver_infos(stats) Test.@test obj ≈ 5.0 Test.@test success == true end diff --git a/test/suite/optimization/test_real_problems.jl b/test/suite/optimization/test_real_problems.jl index e0869e35..ee743bef 100644 --- a/test/suite/optimization/test_real_problems.jl +++ b/test/suite/optimization/test_real_problems.jl @@ -53,7 +53,8 @@ function test_real_problems() Test.@test obj_val ≈ TestProblems.rosenbrock_objective(Float64.(ros.init)) cons_val = NLPModels.cons(nlp64, nlp64.meta.x0) - Test.@test cons_val[1] ≈ TestProblems.rosenbrock_constraint(Float64.(ros.init)) + Test.@test cons_val[1] ≈ + TestProblems.rosenbrock_constraint(Float64.(ros.init)) end Test.@testset "build_model (Exa, Float32) with Rosenbrock" begin @@ -69,7 +70,8 @@ function test_real_problems() Test.@test obj_val ≈ TestProblems.rosenbrock_objective(Float32.(ros.init)) cons_val = NLPModels.cons(nlp32, nlp32.meta.x0) - Test.@test cons_val[1] ≈ TestProblems.rosenbrock_constraint(Float32.(ros.init)) + Test.@test cons_val[1] ≈ + TestProblems.rosenbrock_constraint(Float32.(ros.init)) end end diff --git a/test/suite/solvers/__not_tested_test_knitro_parameter_validation.jl b/test/suite/solvers/__not_tested_test_knitro_parameter_validation.jl index a0e81b2a..5c6d6a7f 100644 --- a/test/suite/solvers/__not_tested_test_knitro_parameter_validation.jl +++ b/test/suite/solvers/__not_tested_test_knitro_parameter_validation.jl @@ -168,5 +168,5 @@ end end # module function test_knitro_parameter_validation() - TestKnitroParameterValidation.test_knitro_parameter_validation() + return TestKnitroParameterValidation.test_knitro_parameter_validation() end diff --git a/test/suite/solvers/test_ipopt_parameter_validation.jl b/test/suite/solvers/test_ipopt_parameter_validation.jl index 1b7294e8..09d21b3c 100644 --- a/test/suite/solvers/test_ipopt_parameter_validation.jl +++ b/test/suite/solvers/test_ipopt_parameter_validation.jl @@ -85,5 +85,5 @@ end end # module function test_ipopt_parameter_validation() - TestIpoptParameterValidation.test_ipopt_parameter_validation() + return TestIpoptParameterValidation.test_ipopt_parameter_validation() end diff --git a/test/suite/solvers/test_uno_parameter_validation.jl b/test/suite/solvers/test_uno_parameter_validation.jl index 2d52cdea..20ec54cd 100644 --- a/test/suite/solvers/test_uno_parameter_validation.jl +++ b/test/suite/solvers/test_uno_parameter_validation.jl @@ -83,5 +83,5 @@ end end # module function test_uno_parameter_validation() - TestUnoParameterValidation.test_uno_parameter_validation() + return TestUnoParameterValidation.test_uno_parameter_validation() end diff --git a/test/suite/strategies/test_alias_integration.jl b/test/suite/strategies/test_alias_integration.jl index a189f925..81972673 100644 --- a/test/suite/strategies/test_alias_integration.jl +++ b/test/suite/strategies/test_alias_integration.jl @@ -40,7 +40,7 @@ end Strategies.id(::Type{MockStrategyWithAliases}) = :mock_with_aliases function Strategies.metadata(::Type{MockStrategyWithAliases}) - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:max_iter, type=Int, diff --git a/test/suite/strategies/test_cpu_only_parameters_integration.jl b/test/suite/strategies/test_cpu_only_parameters_integration.jl index fff084d3..b8cf3782 100644 --- a/test/suite/strategies/test_cpu_only_parameters_integration.jl +++ b/test/suite/strategies/test_cpu_only_parameters_integration.jl @@ -222,5 +222,5 @@ end end # module function test_cpu_only_parameters_integration() - TestCPUOnlyParametersIntegration.test_cpu_only_parameters_integration() + return TestCPUOnlyParametersIntegration.test_cpu_only_parameters_integration() end diff --git a/test/suite/strategies/test_describe_parameters.jl b/test/suite/strategies/test_describe_parameters.jl index b830bdae..0b52b98e 100644 --- a/test/suite/strategies/test_describe_parameters.jl +++ b/test/suite/strategies/test_describe_parameters.jl @@ -138,7 +138,8 @@ function test_describe_parameters() Test.@testset "Unknown symbol error" begin # Create a registry registry = Strategies.create_registry( - CTSolvers.Modelers.AbstractNLPModeler => ((CTSolvers.Modelers.ADNLP, [Strategies.CPU]),) + CTSolvers.Modelers.AbstractNLPModeler => + ((CTSolvers.Modelers.ADNLP, [Strategies.CPU]),), ) # Test unknown ID throws IncorrectArgument diff --git a/test/suite/strategies/test_integration_parameters.jl b/test/suite/strategies/test_integration_parameters.jl index 1c7806af..e0aba87d 100644 --- a/test/suite/strategies/test_integration_parameters.jl +++ b/test/suite/strategies/test_integration_parameters.jl @@ -29,13 +29,13 @@ Strategies.id(::Type{<:IntegrationStratB}) = :integrationstratb # Simple metadata function Strategies.metadata(::Type{T}) where {T<:IntegrationStratA} - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:opt1, type=Int, default=10, description="Option 1") ) end function Strategies.metadata(::Type{T}) where {T<:IntegrationStratB} - Strategies.StrategyMetadata( + return Strategies.StrategyMetadata( Options.OptionDefinition(; name=:opt1, type=Int, default=20, description="Option 1" ),