Engineering Optimization: Theory and Practice, Fourth Edition

(Martin Jones) #1
7.23 MATLAB Solution of Constrained Optimization Problems 475

Step 3: Invoke constrained optimization program (write this in new MATLAB file).


clc
clear all
warning off
x0 = [.1,.1, 3.0]; % Starting guess
fprintf ('The values of function value and constraints at
starting pointn');
f=objfun (x0)
[c, ceq] = constraints (x0)
options = optimset ('LargeScale', 'off');
[x, fval]=fmincon (@objfun, x0, [], [], [], [], [], [],
@constraints, options)
fprintf ('The values of constraints at optimum solutionn');
[c, ceq] = constraints (x)
% Check the constraint values at x

This Produces the Solution or Ouput as follows:
The values of function value and constraints at
starting point
f=
4.0410
c=
-8.9800
-5.0200
-2.0000
-0.1000
-0.1000
-3.0000
ceq =
[]
Optimization terminated: first-order optimality measure
less
than options. TolFun and maximum constraint violation is
less
than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
1
2
4
x=
0 1.4142 1.4142
fval =
1.4142
The values of constraints at optimum solution
c=
Free download pdf