Page 230 - Numerical Methods for Chemical Engineering
P. 230
Gradient methods 219
1 1
initia ess iter = 2
initia ess iter = 2
2
2
− −
− 1 − 1
1 1
1 1
2
2
initia ess − iter = 11 initia ess − iter = 2
− −
− 1 − 1
1 1
Figure 5.6 Gradient minimizers applied to a quadratic cost function. Results at left from steepest
descent method and those at right from conjugate gradient method.
grad = zeros(size(x));
F = dx1ˆ2 + 10*dx2ˆ2 + c*(dx1ˆ4) + c*(dx2ˆ4);
grad(1) = 2*dx1 + 4*c*dx1ˆ3; grad(2) = 2*10*dx2 + 4*c*dx2ˆ3;
iOK=1;
return;
For the quadratic case (c = 0) with the default (CG-PR) method, the minimization is per-
formed by
ModelParam.c = 0;
x0 = [5; 0];
[x, F, grad, iflag, x traj] = gradient minimizer(‘simple cost func’, . . .
x0, [], ModelParam);
To use the steepest descent method, we type
OptParam.method = 0;
[x, F, grad, iflag, x traj] = gradient minimizer(‘simple cost func’, . . .
x0, OptParam, ModelParam);