Interfacing with IPOPT through code

- Problem dimensions
- number of variables
- number of constraints

- Problem bounds
- variable bounds
- constraint bounds

- Initial starting point
- Initial values for the primal variables
- Initial values for the multipliers (only required for a warm start option)

- Problem Structure
- number of nonzeros in the Jacobian of the constraints
- number of nonzeros in the Hessian of the Lagrangian function
- sparsity structure of the Jacobian of the constraints
- sparsity structure of the Hessian of the Lagrangian function

- Evaluation of Problem Functions

Information evaluated using a given point ( coming from IPOPT)- Objective function,
- Gradient of the objective
- Constraint function values,
- Jacobian of the constraints,
- Hessian of the Lagrangian function,

(this is not required if a quasi-Newton options is chosen to approximate the second derivatives)

Providing the sparsity structure of derivative matrices is a bit more involved. IPOPT is a nonlinear programming solver that is designed for solving large-scale, sparse problems. While IPOPT can be customized for a variety of matrix formats, the triplet format is used for the standard interfaces in this tutorial. For an overview of the triplet format for sparse matrices, see Appendix A. Before solving the problem, IPOPT needs to know the number of nonzero elements and the sparsity structure (row and column indices of each of the nonzero entries) of the constraint Jacobian and the Lagrangian function Hessian. Once defined, this nonzero structure MUST remain constant for the entire optimization procedure. This means that the structure needs to include entries for any element that could ever be nonzero, not only those that are nonzero at the starting point.

As IPOPT iterates, it will need the values for Item 5 in Section 3.2 evaluated at particular points. Before we can begin coding the interface, however, we need to work out the details of these equations symbolically for example problem (4)-(7).

The gradient of the objective is given by

We also need to determine the Hessian of the Lagrangian^{16}.
The Lagrangian function for the NLP
(4)-(7) is defined as
and the Hessian of the Lagrangian function is, technically,
. However,
we introduce a factor () in front of the objective term
so that IPOPT can ask for the Hessian of the objective or the
constraints independently, if required.Thus, for IPOPT the symbolic form of the Hessian of the
Lagrangian is

and for the example problem this becomes

The remaining sections of the tutorial will lead you through
the coding required to solve example problem
(4)-(7) using, first C++, then C, and finally
Fortran. Completed versions of these examples can be found in `$IPOPTDIR/Ipopt/examples` under `hs071_cpp`, `hs071_c`, `hs071_f`.

As a user, you are responsible for coding two sections of the program
that solves a problem using IPOPT: the main executable (e.g., ` main`) and the problem representation. Typically, you will write an
executable that prepares the problem, and then passes control over to
IPOPT through an `Optimize` or `Solve` call. In this call,
you will give IPOPT everything that it requires to call back to your
code whenever it needs functions evaluated (like the objective
function, the Jacobian of the constraints, etc.). In each of the
three sections that follow (C++, C, and Fortran), we will first
discuss how to code the problem representation, and then how to code
the executable.

- ... Lagrangian
^{16} - If a quasi-Newton option is chosen to approximate the second derivatives, this is not required. However, if second derivatives can be computed, it is often worthwhile to let IPOPT use them, since the algorithm is then usually more robust and converges faster. More on the quasi-Newton approximation in Section 4.2.