NAG routine e04uc is designed to find a minimum point of an arbitrary smooth function, which may be subject to linear and nonlinear constraints, using a sequential quadratic programming (SQP) method - see the e04uc document for more details of the method.
You can use this demo to illustrate finding a minimum of one of two functions with e04uc. The first one is the well-known Rosenbrock function, which is a 2D function given by
f(x,y) = 100(y-x2)2 + (1-x)2
The second function handled by this demo is MATLAB's "peaks" function, which can be computed using the MATLAB call
[x,y,z] = peaks;
Figure 1 - using e04uc to minimize Rosenbrock's function
Demo controls
The demo can be controlled by use of a number of buttons and drop-down list boxes, down the left-hand side and along the bottom of the GUI.
- You can choose the function you want to minimize using the drop-down list box on the left hand side of the demo, selecting either "Rosenbrock" or "peaks".
- The drop-down box below that allows you to control the speed of the animation - slow, medium or fast.
- The next list lets you choose whether you want to allow derivative information to be used by the NAG routine - see below.
- The slider bar labelled "step limit" lets you control the maximum change in variables allowed at the first step of the linesearch in each search direction taken by the SQP algorithm. Setting this to different values may affect the number of evaluations of the objective function required to solve the problem.
- The "Start" button in the bottom left corner kicks off the solver. Every time the objective function is evaluated, the evaluation point is plotted on the contour diagram. The current values of the variables x and y are displayed, along with the current value of the objective function, and the total number of evaluations so far.
- Typically, a minimization algorithm requires you to supply a starting point at which to begin the search for the minimum. The starting point is denoted by a blue circle on the contour plot. You may change the starting point by clicking on the "Set starting point" button and then clicking on the contours. The global minimum point of the function is denoted by a green circle (naturally it is not possible to change this!)
- It is possible to add constraints to the minimization problem using the "Add linear constraint" button. After you've clicked the button, you are required to click three more times on the contour plot. The first two clicks are used to define a straight line. The third click lets you choose which side of the line you wish to allow the solution to lie on. The opposite side of the line will be coloured pale yellow to show that it is an infeasible area. Any number of linear constraints may be added, and if you make a mistake you can delete one of them at a time using the "Delete last constraint" button.
- The "Close" button will shut down the demo.
Because of the 'banana shaped valley' contours characteristic of Rosenbrock's function, as shown in figure 1 above, the function is often used as a test problem for minimization routines like e04uc. Simplistic algorithms such as a basic 'steepest descent' method have a hard time following the shallow curving valley floor in their quest for the minimum point, but the NAG routine has no trouble.
Derivative information
A feature of e04uc is that the first derivatives of the function to be minimized are not required to be known analytically. If they are not known, or are hard to determine, e04uc can estimate them using difference approximations. If the user is able to supply them, though, convergence of the algorithm is likely to be faster and more robust.
Figure 2 - the demo set up to minimize the peaks function, with some linear constraints
When the problem has been solved, you can use the "Repeat problem" button to solve the same problem again, perhaps after choosing a different starting point.