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 Lagrangian16. 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
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.