Public API
This page lists exported symbols of CTSolvers.Solvers.
From CTSolvers.Solvers
CTSolvers.Solvers
CTSolvers.Solvers — Module
SolversOptimization solvers module for the Control Toolbox.
This module provides concrete solver implementations that integrate with various optimization backends (Ipopt, MadNLP, MadNCL, Knitro). All solvers implement the AbstractStrategy contract and provide a unified callable interface.
Solver Types
Solvers.Ipopt- Interior point optimizer (requires NLPModelsIpopt)Solvers.MadNLP- Matrix-free augmented Lagrangian (requires MadNLP)Solvers.MadNCL- NCL variant of MadNLP (requires MadNCL, MadNLP)Solvers.Knitro- Commercial solver (requires NLPModelsKnitro)
Architecture
- Types and logic: Defined in src/Solvers/ (this module)
- Backend interfaces: Implemented in ext/ as minimal extensions
- Strategy contract: All solvers implement AbstractStrategy
Example
using CTSolvers
using NLPModelsIpopt # Load backend extension
# Create solver with options
solver = Solvers.Ipopt(max_iter=1000, tol=1e-6)
# Solve NLP problem
using ADNLPModels
nlp = ADNLPModel(x -> sum(x.^2), zeros(10))
stats = solver(nlp, display=true)
# Or use CommonSolve API
using CommonSolve
stats = solve(nlp, solver, display=false)See also: AbstractNLPSolver, Solvers.Ipopt
AbstractNLPSolver
CTSolvers.Solvers.AbstractNLPSolver — Type
abstract type AbstractNLPSolver <: CTSolvers.Strategies.AbstractStrategyAbstract base type for optimization solvers in the Control Toolbox.
All concrete solver types must:
- Be a subtype of
AbstractNLPSolver - Implement the
AbstractStrategycontract:Strategies.id(::Type{<:MySolver})- Return unique Symbol identifierStrategies.metadata(::Type{<:MySolver})- Return StrategyMetadata with options- Have an
options::Strategies.StrategyOptionsfield
- Implement the callable interface:
(solver::MySolver)(nlp; display=Bool)- Solve the NLP problem
Solver Types
Solvers.Ipopt- Interior point optimizer (Ipopt backend)Solvers.MadNLP- Matrix-free augmented Lagrangian (MadNLP backend)Solvers.MadNCL- NCL variant of MadNLPSolvers.Knitro- Commercial solver (Knitro backend)
Example
# Create solver with options
solver = Solvers.Ipopt(max_iter=1000, tol=1e-8)
# Solve an NLP problem
nlp = ADNLPModel(x -> sum(x.^2), zeros(10))
stats = solver(nlp, display=true)See also: Solvers.Ipopt, Solvers.MadNLP, Solvers.MadNCL, Solvers.Knitro
Ipopt
CTSolvers.Solvers.Ipopt — Type
struct Ipopt{P<:CTSolvers.Strategies.CPU} <: CTSolvers.Solvers.AbstractNLPSolverInterior point optimization solver using the Ipopt backend.
Ipopt (Interior Point OPTimizer) is an open-source software package for large-scale nonlinear optimization. It implements a primal-dual interior point method with proven global convergence properties.
Parameterized Types
The solver supports parameterization for execution backend:
Ipopt{CPU}: CPU execution (default and only supported parameter)
Note: Unlike MadNLP and MadNCL, this solver only supports CPU execution. GPU execution is not available for Ipopt.
Constructors
# Default constructor (CPU)
Solvers.Ipopt(; mode::Symbol=:strict, kwargs...)
# Explicit parameter specification (only CPU supported)
Solvers.Ipopt{CPU}(; mode::Symbol=:strict, kwargs...)Fields
options::CTSolvers.Strategies.StrategyOptions: Solver configuration options containing validated option values
Parameter Behavior
CPU Parameter (Default)
The CPU parameter indicates standard CPU-based execution:
- Uses Ipopt's standard interior point algorithm
- No GPU acceleration available
- Compatible with all standard Julia environments
- Proven global convergence properties
Solver Options
Solver options are defined in the CTSolversIpopt extension. Load the extension to access option definitions and documentation:
using NLPModelsIpoptExamples
Basic Usage
# Conceptual usage pattern (requires NLPModelsIpopt extension)
using NLPModelsIpopt
# Default solver (CPU)
solver = Ipopt(max_iter=1000, tol=1e-6, print_level=3)
# Explicit CPU specification
solver_cpu = Ipopt{CPU}(max_iter=1000, tol=1e-6)
nlp = ADNLPModel(x -> sum(x.^2), zeros(10))
stats = solver(nlp, display=true)Invalid Usage
# GPU is NOT supported - will throw IncorrectArgument
solver = Ipopt{GPU}() # ❌ Error!Extension Required
This solver requires the NLPModelsIpopt package to be loaded:
using NLPModelsIpoptImplementation Notes
- Implements the
AbstractStrategycontract viaStrategies.id() - Metadata and constructor implementation provided by CTSolversIpopt extension
- Options are validated at construction time using enriched
Exceptions.IncorrectArgument - Callable interface:
(solver::Ipopt)(nlp; display=true)provided by extension
Throws
CTBase.Exceptions.IncorrectArgument: If GPU or other unsupported parameter is specifiedCTBase.Exceptions.ExtensionError: If the NLPModelsIpopt extension is not loaded
See also: CPU, AbstractNLPSolver, MadNLP, Knitro
Knitro
CTSolvers.Solvers.Knitro — Type
struct Knitro{P<:CTSolvers.Strategies.CPU} <: CTSolvers.Solvers.AbstractNLPSolverCommercial optimization solver with advanced algorithms.
Knitro is a commercial solver offering state-of-the-art algorithms for nonlinear optimization, including interior point, active set, and SQP methods. It provides excellent performance and robustness for large-scale problems.
Parameterized Types
The solver supports parameterization for execution backend:
Knitro{CPU}: CPU execution (default and only supported parameter)
Note: Unlike MadNLP and MadNCL, this solver only supports CPU execution. GPU execution is not available for Knitro.
Constructors
# Default constructor (CPU)
Solvers.Knitro(; mode::Symbol=:strict, kwargs...)
# Explicit parameter specification (only CPU supported)
Solvers.Knitro{CPU}(; mode::Symbol=:strict, kwargs...)Fields
options::CTSolvers.Strategies.StrategyOptions: Solver configuration options containing validated option values
Parameter Behavior
CPU Parameter (Default)
The CPU parameter indicates standard CPU-based execution:
- Uses Knitro's advanced optimization algorithms
- No GPU acceleration available
- Compatible with all standard Julia environments
- Requires valid Knitro license
Solver Options
Solver options are defined in the CTSolversKnitro extension. Load the extension to access option definitions and documentation:
using NLPModelsKnitroExamples
Basic Usage
# Conceptual usage pattern (requires NLPModelsKnitro extension)
using NLPModelsKnitro
# Default solver (CPU)
solver = Knitro(maxit=1000, maxtime=3600, ftol=1e-10, outlev=2)
# Explicit CPU specification
solver_cpu = Knitro{CPU}(maxit=1000, outlev=2)
nlp = ADNLPModel(x -> sum(x.^2), zeros(10))
stats = solver(nlp, display=true)Invalid Usage
# GPU is NOT supported - will throw IncorrectArgument
solver = Knitro{GPU}() # ❌ Error!Extension Required
This solver requires the NLPModelsKnitro package:
using NLPModelsKnitroNote: Knitro is a commercial solver requiring a valid license.
Implementation Notes
- Implements the
AbstractStrategycontract viaStrategies.id() - Metadata and constructor implementation provided by CTSolversKnitro extension
- Options are validated at construction time using enriched
Exceptions.IncorrectArgument - Callable interface:
(solver::Knitro)(nlp; display=true)provided by extension - Requires valid Knitro license for operation
Throws
CTBase.Exceptions.IncorrectArgument: If GPU or other unsupported parameter is specifiedCTBase.Exceptions.ExtensionError: If the NLPModelsKnitro extension is not loaded
See also: CPU, AbstractNLPSolver, Ipopt, MadNLP
MadNCL
CTSolvers.Solvers.MadNCL — Type
struct MadNCL{P<:Union{CTSolvers.Strategies.CPU, CTSolvers.Strategies.GPU}} <: CTSolvers.Solvers.AbstractNLPSolverNCL (Non-Convex Lagrangian) variant of MadNLP solver.
MadNCL extends MadNLP with specialized handling for non-convex problems using a modified Lagrangian approach, providing improved convergence for challenging nonlinear optimization problems.
Parameterized Types
The solver supports parameterization for execution backend:
MadNCL{CPU}: CPU execution (default)MadNCL{GPU}: GPU execution (requires CUDA.jl)
Fields
options::CTSolvers.Strategies.StrategyOptions: Solver configuration options containing validated option values
Solver Options
Solver options are defined in the CTSolversMadNCL extension. Load the extension to access option definitions and documentation:
using MadNCL, MadNLPExample
# Conceptual usage pattern (requires MadNCL, MadNLP extensions)
using MadNCL, MadNLP
solver = Solvers.MadNCL(max_iter=1000, tol=1e-6, print_level=MadNLP.DEBUG)
nlp = ADNLPModel(x -> sum(x.^2), zeros(10))
stats = solver(nlp, display=true)Extension Required
This solver requires the MadNCL package:
using MadNCL, MadNLPImplementation Notes
- Implements the
AbstractStrategycontract viaStrategies.id,Strategies.metadata, andStrategies.options - Options are validated at construction time using enriched
Exceptions.IncorrectArgument - Callable interface:
(solver::MadNCL{P})(nlp; display=true) - Extends MadNLP with NCL-specific optimizations
- Default backend is automatically selected based on the parameter type
- GPU linear solver: When using
MadNCL{GPU}, the linear solver automatically defaults toMadNLPGPU.CUDSSSolverinstead ofMadNLP.MumpsSolver. This ensures compatibility with GPU execution and avoids attempting to use CPU-only solvers on CUDA backends.
See also: AbstractNLPSolver, MadNLP, Ipopt, CPU, GPU
MadNLP
CTSolvers.Solvers.MadNLP — Type
struct MadNLP{P<:Union{CTSolvers.Strategies.CPU, CTSolvers.Strategies.GPU}} <: CTSolvers.Solvers.AbstractNLPSolverPure-Julia interior point solver with GPU support.
MadNLP is a modern implementation of an interior point method written entirely in Julia, with support for GPU acceleration and various linear solver backends. It provides excellent performance for large-scale optimization problems.
Parameterized Types
The solver supports parameterization for execution backend:
MadNLP{CPU}: CPU execution (default)MadNLP{GPU}: GPU execution (requires CUDA.jl)
Fields
options::CTSolvers.Strategies.StrategyOptions: Solver configuration options containing validated option values
Solver Options
max_iter::Integer: Maximum number of iterations (default: 3000, must be ≥ 0)tol::Real: Convergence tolerance (default: 1e-8, must be > 0)print_level::MadNLP.LogLevels: MadNLP log level (default: MadNLP.INFO)- MadNLP.DEBUG: Detailed debugging output
- MadNLP.INFO: Standard informational output
- MadNLP.WARN: Warning messages only
- MadNLP.ERROR: Error messages only
linear_solver::Type{<:MadNLP.AbstractLinearSolver}: Linear solver backend- Default for CPU:
MadNLP.MumpsSolver - Default for GPU:
MadNLPGPU.CUDSSSolver(requires MadNLPGPU.jl)
- Default for CPU:
backend: Execution backend (default depends on parameter: CPU backend for CPU, CUDA backend for GPU)
Example
# Conceptual usage pattern (requires MadNLP extension)
using MadNLP
solver = MadNLP(max_iter=1000, tol=1e-6, print_level=MadNLP.DEBUG)
nlp = ADNLPModel(x -> sum(x.^2), zeros(10))
stats = solver(nlp, display=true)Extension Required
This solver requires the MadNLP package:
using MadNLPImplementation Notes
- Implements the
AbstractStrategycontract viaStrategies.id,Strategies.metadata, andStrategies.options - Options are validated at construction time using enriched
Exceptions.IncorrectArgument - Callable interface:
(solver::MadNLP{P}(nlp; display=true) - Supports GPU acceleration when appropriate backends are loaded
- Default backend is automatically selected based on the parameter type
- GPU linear solver: When using
MadNLP{GPU}, the linear solver automatically defaults toMadNLPGPU.CUDSSSolverinstead ofMadNLP.MumpsSolver. This ensures compatibility with GPU execution and avoids attempting to use CPU-only solvers on CUDA backends.
See also: AbstractNLPSolver, Ipopt, Solvers.MadNCL, CPU, GPU