Engineering Optimization: Theory and Practice, Fourth Edition

(Martin Jones) #1

38 Introduction to Optimization


SOLUTION

Step 1: Write an M-fileprobofminobj.mfor the objective function.

function f= probofminobj (x)
f= 9.82*x(1)*x(2)+2*x(1);

Step 2: Write an M-fileconprobformin.mfor the constraints.

function [c, ceq] = conprobformin(x)
% Nonlinear inequality constraints
c = [2500/(pi*x(1)*x(2))-500;2500/(pi*x(1)*x(2))-
(pi^2*(x(1)^2+x(2)^2))/0.5882;-x(1)+2;x(1)-14;-x(2)+0.2;
x(2)-0.8];
% Nonlinear equality constraints
ceq = [];

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

clc
clear all
warning off
x0 = [7 0.4]; % Starting guess\
fprintf ('The values of function value and constraints
at starting point\n');
f=probofminobj (x0)
[c, ceq] = conprobformin (x0)
options = optimset ('LargeScale', 'off');
[x, fval]=fmincon (@probofminobj, x0, [], [], [], [], [],
[], @conprobformin, options)
fprintf('The values of constraints at optimum solution\n');
[c, ceq] = conprobformin(x) % Check the constraint values at x

This produces the solution or output as follows:

The values of function value and constraints at starting point
f=
41.4960
c =
-215.7947
-540.6668
-5.0000
-7.0000
-0.2000
-0.4000
ceq =
[]
Optimization terminated: first-order optimality
measure less
Free download pdf