Page 253 - Numerical Methods for Chemical Engineering
P. 253

242     5 Numerical optimization



                   Because the constraints of (5.123) are linear, it is easier to identify how far one may move
                   before violating them. Quadratic problems such as (5.123) thus can be solved efficiently
                   with specialized techniques. For more on this topic (interior point, active set methods),
                   consult Nocedal & Wright (1999) or view the documentation for fmincon.




                   Constrained minimizer fmincon in MATLAB

                   The fmincon constrained minimizer
                   fmincon solves constrained optimization problems with the structure


                                          minimize  F(x)
                                       subject to the constraints (linear and nonlinear)
                                                                                     (5.124)
                         Ax ≤ b    A (eq) x = b (eq)  c(x) ≤ 0  c (eq) (x) = 0

                   and the upper and lower bounds LB j ≤ x j ≤ UB j
                     The routine is called with the syntax

                   [x, F, exitflag, output, grad, Hessian] = fmincon (. . .
                     fun, x0, A, b, A eq, b eq, LB, UB, nonlcon, OPTIONS, P1, P2,...);
                   fun is the name of a function that returns the cost function (and optionally the gradient and
                   Hessian),
                   function F = fun(x, P1, P2, ...);

                   x0 is the initial guess, and A, b, A eq, and b eq specify the linear constraints (if any). The
                   nonlinear constraint functions are returned by a user-supplied routine,

                   function [c,c eq] = nonlcon(x, P1, P2, ...);
                   If any constraint is not present, use[]asaplaceholder. The vectors of lower and upper
                   bounds for each parameter are LB and UB.If x j has no lower bound, set LB(j) = -Inf.If x j
                   has no upper bound, set UB(j) = Inf. OPTIONS is set by optimset. P1, P2,...are optional
                   parameters to be passed to fun.
                     The output variables are the constrained local minimum x, the cost function value F,
                   exitflag and output that provide information around the work done by fmincon.



                   Example. Finding the closest points on two ellipses

                   We revisit the problem of finding the closest points on two ellipses by minimizing the
                   squared distance between them,

                                                             2
                                     F(x 1 , y 1 , x 2 , y 2 ) = (x 1 − x 2 ) + (y 1 − y 2 ) 2  (5.125)
   248   249   250   251   252   253   254   255   256   257   258