How coin-or/ipopt works
Purpose and Build Surface
Ipopt is a C++ library and optional solver executable for large-scale, twice-differentiable constrained nonlinear optimization, implementing a primal-dual interior-point/filter line-search method. Autotools is the primary build boundary: configure.ac, Makefile.am, and src/Makefile.am configure and assemble libraries, headers, and optional applications across Unix/macOS/Windows.
Public APIs and Entry Points
Client code defines a nonlinear program through the TNLP callback contract and runs it through IpoptApplication; adapters translate standard C/C++ representations into the algorithm’s internal NLP form.
• src/Interfaces/IpTNLP.hpp
• src/Interfaces/IpIpoptApplication.hpp
• src/Interfaces/IpTNLPAdapter.cpp
Language bindings expose the same solver core to C, Fortran, and Java:
• src/Interfaces/IpStdCInterface.h
• src/Interfaces/IpStdFInterface.c
• src/Interfaces/Ipopt.java
Runnable examples demonstrate C++, C, Fortran, and Java entry paths, e.g. examples/Cpp_example/cpp_example.cpp and examples/hs071_c/hs071_c.c.
Solve Orchestration and State
IpoptApplication initializes options and registered strategies, then constructs and invokes the main iteration engine. The algorithm owns per-solve state, computed quantities, iterate vectors, timing, and iteration output; it returns status and statistics through the interface layer.
• src/Algorithm/IpIpoptAlg.cpp
• src/Algorithm/IpIpoptData.hpp
• src/Algorithm/IpIpoptCalculatedQuantities.hpp
Control flow is roughly: user callbacks → adapter/reduction and scaling → initialize or warm start → repeated primal-dual iterations → convergence/restoration decision → final callback-facing status/statistics.
Interior-Point Iteration Stages
The algorithm builder selects pluggable strategies from options. Each iteration computes feasibility/optimality measures, updates barrier parameters, forms a KKT system, computes a search direction, and accepts a step using filter or penalty line-search logic. Failure to progress can enter a restoration-phase NLP.
• src/Algorithm/IpAlgBuilder.cpp
• src/Algorithm/IpPDSearchDirCalc.cpp
• src/Algorithm/IpFilterLSAcceptor.cpp
• src/Algorithm/IpRestoRestoPhase.cpp
Initialization supports ordinary and warm-start paths, while Hessians can be exact or limited-memory quasi-Newton:
• src/Algorithm/IpDefaultIterateInitializer.cpp
• src/Algorithm/IpWarmStartIterateInitializer.cpp
• src/Algorithm/IpLimMemQuasiNewtonUpdater.cpp
Numerical Representations and KKT Boundary
LinAlg provides the abstract vector/matrix hierarchy and dense, sparse-triplet, compound, and symmetric matrix forms used internally. Algorithm code should depend on these abstractions rather than a concrete third-party solver format.
• src/LinAlg/IpVector.hpp
• src/LinAlg/IpMatrix.hpp
• src/LinAlg/TMatrices/IpSymTMatrix.cpp
The KKT solve is an explicit extension boundary: the augmented-system solver delegates sparse symmetric factorization/solve to a selected backend through common solver interfaces.
• src/Algorithm/IpGenAugSystemSolver.cpp
• src/Algorithm/LinearSolvers/IpSparseSymLinearSolverInterface.hpp
• src/Algorithm/LinearSolvers/IpGenKKTSolverInterface.hpp
External Numerical Dependencies
A BLAS/LAPACK implementation is required for core dense operations:
• src/LinAlg/IpBlas.cpp
• src/LinAlg/IpLapack.cpp
At least one sparse linear solver is required at build/runtime configuration. Built-in integration interfaces cover HSL MA27/57/77/86/97, MUMPS, Pardiso/MKL Pardiso, SPRAL, and WSMP; availability is compile-time dependency-driven.
• src/Algorithm/LinearSolvers/IpMumpsSolverInterface.cpp
• src/Algorithm/LinearSolvers/IpPardisoSolverInterface.cpp
• src/Algorithm/LinearSolvers/IpSpralSolverInterface.cpp
Optional Modeling and Sensitivity Frontends
The AMPL executable converts AMPL Solver Library models into TNLP instances, separating ASL-dependent code from the core library.
• src/Apps/AmplSolver/ampl_ipopt.cpp
• src/Apps/AmplSolver/AmplTNLP.cpp
The R package (ipoptr) bridges R callbacks and sparse data to C++ NLP and logging adapters:
• contrib/RInterface/R/ipoptr.R
• contrib/RInterface/src/IpoptRNLP.cpp
sIPOPT is a separate contributed sensitivity-analysis layer built around its own application/algorithm extensions and optional AMPL integration:
• contrib/sIPOPT/src/SensApplication.cpp
• contrib/sIPOPT/src/SensAlgorithm.cpp
• contrib/sIPOPT/AmplSolver/SensAmplTNLP.cpp
Main entry points: IpIpoptAlg.cpp Iteration engine · IpIpoptApplication.hpp IpoptApplication · IpAlgBuilder.cpp Strategy builder · IpTNLPAdapter.cpp TNLP adapter
Components 20
Build
Autotools selects optional components and numerical dependencies.
- Autotools build · Configures libraries, headers, applications, and dependency-backed solvers.
configure.ac
Public APIs
- TNLP callbacks · Client nonlinear-program callback contract.
src/Interfaces/IpTNLP.hpp - IpoptApplication · Initializes a solve and returns status and statistics.
src/Interfaces/IpIpoptApplication.hpp - TNLP adapter · Converts callback representations to the internal NLP form.
src/Interfaces/IpTNLPAdapter.cpp - C, Fortran, Java bindings · Alternative entry points to the solver core.
src/Interfaces/IpStdCInterface.h
Interior-Point Core
- Iteration engine · Owns the primal-dual solve loop, status, timing, and output.
src/Algorithm/IpIpoptAlg.cpp - Solve state · Iterates and calculated quantities maintained per solve.
src/Algorithm/IpIpoptData.hpp - Strategy builder · Selects pluggable algorithm strategies from options.
src/Algorithm/IpAlgBuilder.cpp - Initialize / warm start · Provides ordinary and warm-start initialization paths.
src/Algorithm/IpDefaultIterateInitializer.cpp - Barrier and line search · Updates barrier state and accepts filter or penalty steps.
src/Algorithm/IpFilterLSAcceptor.cpp - Search direction · Computes the direction from the assembled KKT system.
src/Algorithm/IpPDSearchDirCalc.cpp - Restoration phase · Solves a restoration NLP when progress fails.
src/Algorithm/IpRestoRestoPhase.cpp
Numerical Backend
- Linear algebra abstractions · Abstract and concrete dense, sparse, compound, and symmetric representations.
src/LinAlg/IpVector.hpp - Augmented KKT solver · Delegates sparse symmetric factorization through solver interfaces.
src/Algorithm/IpGenAugSystemSolver.cpp - Sparse solver interface · Common sparse symmetric linear-solver extension boundary.
src/Algorithm/LinearSolvers/IpSparseSymLinearSolverInterface.hpp - BLAS / LAPACK · Provides core dense numerical operations.
src/LinAlg/IpBlas.cpp - Sparse solver backends · Compile-time integrations include MUMPS, Pardiso, SPRAL, HSL, and WSMP.
src/Algorithm/LinearSolvers/IpMumpsSolverInterface.cpp
Optional Frontends
- AMPL solver executable · Converts ASL models into TNLP instances.
src/Apps/AmplSolver/ampl_ipopt.cpp - ipoptr R interface · Bridges R callbacks and sparse data to C++ NLP adapters.
contrib/RInterface/R/ipoptr.R - sIPOPT sensitivity layer · Separate contributed application and algorithm extensions.
contrib/sIPOPT/src/SensApplication.cpp
Connections 25
- Autotools build → IpoptApplication: builds
- Autotools build → Sparse solver backends: enables
- TNLP callbacks → TNLP adapter: callbacks
- IpoptApplication → TNLP adapter: adapts model
- IpoptApplication → Strategy builder: configures
- IpoptApplication → Iteration engine: invokes
- C, Fortran, Java bindings → IpoptApplication: calls
- TNLP adapter → Iteration engine: internal NLP
- Strategy builder → Initialize / warm start: selects
- Strategy builder → Barrier and line search: selects
- Strategy builder → Search direction: selects
- Iteration engine → Solve state: maintains
- Iteration engine → Initialize / warm start: starts with
- Iteration engine → Barrier and line search: iterates with
- Iteration engine → Search direction: computes
- Iteration engine → Restoration phase: on failure
- Search direction → Augmented KKT solver: solves KKT
- Linear algebra abstractions → Iteration engine: iterate representations
- Linear algebra abstractions → Augmented KKT solver: matrix abstractions
- Augmented KKT solver → Sparse solver interface: uses
- Sparse solver interface → Sparse solver backends: implemented by
- Linear algebra abstractions → BLAS / LAPACK: dense operations
- AMPL solver executable → TNLP callbacks: creates
- ipoptr R interface → TNLP adapter: bridges to
- sIPOPT sensitivity layer → IpoptApplication: extends