diff --git a/ext/MadNLPSolverExt/solver.jl b/ext/MadNLPSolverExt/solver.jl index 514d29a..ca60e53 100644 --- a/ext/MadNLPSolverExt/solver.jl +++ b/ext/MadNLPSolverExt/solver.jl @@ -208,7 +208,12 @@ function DirectTrajOpt.set_options!(optimizer::AbstractOptimizer, options::MadNL if name in ignored_options continue end - # TODO: allow internal defaults, i.e. do not set the internal options dict unless the user actually specified the associated opt + # `nothing` means "use MadNLP's own default" — don't overwrite the optimizer's + # internal dict in that case. Applies to the pass-through fields + # (linear_solver, array_type, kkt_system, cudss_ordering). + if value === nothing + continue + end if name == :print_level optimizer.options[name] = MadNLP.LogLevels(value) elseif name == :hessian_approximation diff --git a/src/solvers/madnlp_solver/options.jl b/src/solvers/madnlp_solver/options.jl index 9a6fb73..6d3a382 100644 --- a/src/solvers/madnlp_solver/options.jl +++ b/src/solvers/madnlp_solver/options.jl @@ -7,6 +7,13 @@ export MadNLPOptions print_level::Int = 3 # (MadNLP.TRACE::MadNLP.LogLevels = 1, ..., MadNLP.ERROR::MadNLP.LogLevels = 6) hessian_approximation::String = "exact" # (exact = MadNLP.ExactHessian, compact_lbfgs = MadNLP.CompactLBFGS) # no other QN methods supported in conjunction with MadNLP.SparseCallback + # Pass-throughs consumed by MadNLP's MOI layer (not by MadNLP itself); + # leave as `nothing` to use MadNLP defaults. Only forwarded when non-nothing. + linear_solver::Any = nothing # e.g. MadNLPGPU.CUDSSSolver, MadNLP.LapackCPUSolver + array_type::Any = nothing # e.g. CUDA.CuArray for GPU + kkt_system::Any = nothing # e.g. MadNLP.SparseUnreducedKKTSystem + cudss_ordering::Any = nothing # e.g. MadNLPGPU.AMD_ORDERING + # # Only supported by DirectTrajOpt._solve, as an optional kwarg override of `hessian_approximation`; # # `hessian_approximation = eval_hessian ? "exact" : "compact_lbfgs"` # eval_hessian::Bool = true