Optimizing with IPOPT

IPOPT (Interior Point OPTimizer) is a software package for large-scale ​nonlinear optimization, designed to find local solutions of mathematical optimization problems.

IPOPTLink is a Wolfram System application that uses Wolfram LibraryLink to link to IPOPT functions. IPOPTLink provides, among others, the functions IPOPTMinimize and ParametricIPOPTMinimize. These functions can be used for local minimization with or without parameters. They may be automatically called by optimization functions such as FindMinimum.

Use FindMinimum with the IPOPT solver.

However, IPOPTLink functions can also be called directly providing a more flexible way to use the functionality implemented in IPOPT.

IPOPTMinimizecompute local minimum using IPOPT
IPOPTDatadata expression returned by IPOPTMinimize
IPOPTMinValuegets the minimal objective value from IPOPTData expression
IPOPTArgMingets the local minimum position from IPOPTData expression
ParametricIPOPTMinimizecompute local minimum with parameters using IPOPT

Basic IPOPTLink functions.

IPOPT is designed to find local solutions of mathematical constrained optimization problems in dimensions. Constrained optimization problems are problems for which a real valued function of several variables , referred to as the objective function, is to be minimized subject to constraints. Two types of constraints may be specified -- either variable bound constraints or constraints defined by functions. Variable bound constraints are of the form where x=(x1,,xn). Function constraints are of the form .

Depending on the type of constraints IPOPTMinimize can be used in the following three ways :

IPOPTMinimize[f(x),x,x0]unconstrained minimization
IPOPTMinimize[f(x),x,x0,xbounds]bound constrained minimization
IPOPTMinimize[f(x),x,x0,xbounds,g(x),gbounds]constrained minimization by function constraints and variable bounds

IPOPTMinimize usages.

Maximizing an objective function can be done by minimizing the negative of the function to maximize.

Unconstrained minimization

IPOPTMinimize[f,{x1,},{x1i0,}]unconstrained minimization

IPOPTMinimize unconstrained minimization.

In order to use IPOPTLink the package needs to be loaded.

Load the IPOPTLink package.

As an initial example, find a local minimum of starting from .

Plot the objective function.

Call the IPOPT solver using IPOPTMinimize with objective function , argument variables {} and initial value }.

Minimize starting from x=10.

IPOPTMinimize returns an IPOPTData object. This object contains the minimal value.

Extract the minimal objective function value from the IPOPTData object.

The IPOPTData object also contains the coordinate point at which the minimum was found.

Extract the minimization point from the IPOPTData object.
Plot the objective function with the location of the local minimum found.

Bound constrained minimization

IPOPTMinimize[f,{x1,},{x1i0,},{{x1min,x1max},}]bound constrained minimization

IPOPTMinimize bound constrained minimization.

Find a local minimum of with x constrained in the interval , starting from . We can again use IPOPTMinimize with objective function , argument variable and initial value . We also need to specify the variable bounds :

Minimize with x between 10 and 20 starting from x=11.

IPOPTMinimize returns an IPOPTData object. This object contains the minimal value and the minimization point.

Extract the minimum objective function value and position from the IPOPTData object.
Plot the objective function with the location of the local minimum found.

Note that bound constraints are a special case of function constraints.

Express the same problem using a function constraint with constraint function x:
Extract the minimal value and minimization point from the IPOPTData object.

Function constrained minimization

IPOPTMinimize[f,{x1,},{x1i0,},{{x1min,x1max},},{g1,},{{g1min,g1max},}]constrained minimization with function constraints and variable bounds

IPOPTMinimize constrained minimization with function constraints and variable bounds.

Minimize over the circle , described by a constraint function with lower and upper constraint bounds both equal to 1.

Minimize subject to , starting from {x,y}={0,1}.
Extract the minimal value and minimization point from the IPOPTData object.
Plot the solution:

ParametricIPOPTMinimize

ParametricIPOPTMinimize can be used to set up a minimization problem with parameters present anywhere in the problem formulation. The optimization problem may then be solved repeatedly with different parameter values. ParametricIPOPTMinimize has all of the arguments of IPOPTMinimize with the addition of the parameter variables argument {p1,} given last.

ParametricIPOPTMinimize[f,{x1,},{x1i0,},{{x1min,x1max},},{g1,},{{g1min,g1max},},{p1,}]parametric constrained minimization

ParametricIPOPTMinimize parametric constrained minimization.

Set up a minimization problem over the circle , where r is a parameter.

Minimize subject to , starting from {x,y}={0,-r}.

The previous step performs the preprocessing of the functions and all necessary derivatives and returns a ParametricFunction object awaiting parameter values.

The actual minimization begins after providing parameter values and the solution is stored in an IPOPTData expression.

Minimize for a given parameter value r=1.
Extract the minimal value and minimization point from the IPOPTData expression.

Compute other solutions for different parameter values.

Solve the problem for different parameter values of the circle radius r.
Minimize with all of the above parameter values:
Extract the minimal value from all IPOPTData objects.
Plot the minimal value for the all the parameter values used.
Observe the solution with Manipulate for different parameter values:

Using ParametricIPOPTMinimize instead of IPOPTMinimize with multiple parameter values reduces the overhead of repeatedly preprocessing the objective and constraint functions as well as all necessary derivatives, which can be significant depending on their complexity.

Compare timings with IPOPTMinimize and ParametricIPOPTMinimize.

Maximizing with IPOPTMinimize

A maximum value can be found by minimizing the negative of the objective function.

Find a local maximum of over the circle .

Maximize subject to , starting from {x,y}={1,0}.

The minimum value of -f should then be negated again to obtain the maximum value of f.

Get the maximal value of and the maximization point:

Engineering example

Design a cam to maximize the area of the valve opening for one rotation of the convex cam with constraints on the curvature and the radius of the cam. The problem formulation is from the COPS test suite and is summarized below.

We assume that the shape of the cam is circular over an angle of 6π/5 of its circumference with radius rmin. The design variables ri,i=1,,n, represent the radius of the cam at equally spaced angles θ distributed over an angle of 2π/5. Symmetry is used in the remaining angle of 2π/5.

The following constraints are specified. Each radius ri is constrained in the interval {rmin, rmax}. Additionally we have convexity constraints expressed by A(ri-1,ri+1)A(ri-1,ri)+ A(ri,ri+1), where A(ri,rj) is the area of the triangle defined by the origin and the points ri and rj on the cam surface. There is also a curvature requirement -α (ri+1-ri)/θ α depending on the parameter α.

To define the objective function the valve opening area is assumed to have a simple linear relationship with the design variables ri given as: π rv 2(r1++rn)/n, where rv is a constant related to the geometry of the valve.

We can set this as a parametric problem with parameters rmin,rmax, α. The number of design variables is chosen to be n=20 and we assume .

Load the package.
Set up the variables, initial values, constraints and the objective function.
Set up the parametric problem.
Find a solution for given parameter values.
Plot the cam shape.
Use the parametric formulation to easily recompute with different parameter values.

References

IPOPT is written by ​Andreas Wächter, ​Carl Laird and others as part of the COIN-OR Initiative. It is based on the following paper: A. Wächter and L. T. Biegler, ​On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming, Mathematical Programming 106(1), pp. 25-57, 2006.