Appendix A. MATLAB Scripts

Script 1: Solving single-objective optimization problems of objectives A and T, respectively, in the pyramid example.
objfun_s.m
function f = objfun_s(x)
f = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2);
objfun_t.m
function f = objfun_t(x)
f = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)+x(1) ˆ 2;
confun.m
function [c, ceq] = confun(x)
% Nonlinear inequality constraints
c = 1500-x(1) ˆ 2∗x(2)/3;
% Nonlinear equality constraints
ceq = [];
x0 = [10,10]; % Make a starting guess at the solution
options = optimset('Algorithm','active-set'),
[x_s,fval_s] = fmincon(@objfun_s,x0,[],[],[],[],[],[],@confun, options);
[x_s,fval_s]       % Print results.
[x_t,fval_t] = fmincon(@objfun_t,x0,[],[],[],[],[],[],@confun, options);
[x_t,fval_t]       % Print results.
Script 2: Solving and graphing the Pareto front for the pyramid example using the generative method.
%Pyramid example; plot objective domain
clear all;format long
NN=1000000;  %No. of random points for plotting
%----------------------------------------------
A=1; %counting feasible points
B=1; %counting infeasible points
Smin=1000000;
aos=0;
hos=0;
Tmin=1000000;
aot=0;
hot=0;
for ii=1:NN
        a=rand∗30;
        h=rand∗30;
        V=(1/3)∗a ˆ 2∗h;
        s=sqrt((a/2) ˆ 2+h ˆ 2);
        S=2∗a∗s;
        T=S+a ˆ 2;
        if V>1500;
               feasi(:,A)=[S,T];
               if Smin > feasi(1,A);
                    Smin = feasi(1,A);
                    aos=a; hos=h;
               end
               if Tmin > feasi(2,A);
                    Tmin = feasi(2,A);
                    aot=a; hot=h;
               end
               A=A+1;
        else
              infeasi(:,B)=[S,T];
              B=B+1;
        end
end
figure (1)
plot(feasi(1,:),feasi(2,:),'bs','MarkerSize',3)
plot(infeasi(1,:),infeasi(2,:),'rs','MarkerSize',3)
xlabel('S'), ylabel('T')
axis equal
Script 3: Solving the pyramid problem using the weighted-sum method (Example 5.4).
objfun_pyramid_ws.m
function f = objfun_pyramid_ws(x)
ws=0.1;
wt=1–ws;
f = ws∗(2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2))+wt∗(2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)+x(1) ˆ 2);
confun.m
function [c, ceq] = confun(x)
% Nonlinear inequality constraints
c = 1500–x(1) ˆ 2∗x(2)/3;
% Nonlinear equality constraints
ceq = [];
x0 = [10,10]; % Make a starting guess at the solution
options = optimset('Algorithm','active–set'),
[x,fval] = fmincon(@objfun_pyramid_ws,x0,[],[],[],[],[],[],@confun, options);
[x,fval]       % Print results
S = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)
T = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)+x(1) ˆ 2
Script 4: Solving Example 5.5 using the weighted min–max method.
objfun.m
function f = objfun(x)
f = x(3);
confun.m
function [c, ceq] = confun(x)
% Inequality constraints
c = 0.5∗x(1)+0.5∗x(2)+1–x(3);
% Equality constraints
ceq = x(1) ˆ 2+x(2) ˆ 2–1;
x0 = [0.5,0,0]; % Make a starting guess at the solution
options = optimset('Algorithm','active-set'),
[x,fval] = fmincon(@objfun,x0,[],[],[],[],[],[],@confun, options);
Script 5: Solving Example 5.7 using the NBI method.
objfun.m
function f = objfun(x)
f = x(3);
confun.m
function [c, ceq] = confun(x)
% Equality constraints
a1=0.7;
a2=(1+a1);
c=[];
ceq(1) = a1–x(3)x(1);
ceq(2) = a2–x(3)x(2);
ceq(3) = x(1) ˆ 2+x(2) ˆ 2–1;
x0 = [0.5,0,0]; % Make a starting guess at the solution
options = optimset('Algorithm','active-set'),
[x,fval] = fmincon(@objfun,x0,[],[],[],[],[],[],@confun, options);
Script 6: Solving the pyramid example using the NBI method (Example 5.8).
objfun_pyramid_nbi.m
function f = objfun_pyramid_nbi(x)
f = x(3);
confun.m
function [c, ceq] = confun(x)
w1=1;
w2=1–w1;
% Nonlinear inequality constraints
c = 1500–x(1) ˆ 2∗x(2)/3;
% Nonlinear equality constraints
ceq(1)=w2∗(648.5595.8)x(3)∗(648.5595.8)2∗x(1)∗((0.5∗x(1)) ˆ 2+x(2) ˆ 2) ˆ 0.5+595.8;
ceq(2)=w1∗(935.6865.3)x(3)∗(935.6865.3)(2∗x(1)∗((0.5∗x(1)) ˆ 2+x(2) ˆ 2) ˆ 0.5+x(1) ˆ 2)+865.3;
x0 = [10,10,10]; % Make a starting guess at the solution
options = optimset('Algorithm','active-set'),
[x,fval] = fmincon(@objfun_pyramid_nbi,x0,[],[],[],[],[],[],@confun, options);
[x,fval]       % Print results
S = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)
T = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)+x(1) ˆ 2
Script 7: Solving the pyramid problem using the min–max method (Example 5.9).
objfun_pyramid_minmax.m
function f = objfun_pyramid_minmax(x)
f = x(3);
confun.m
% Nonlinear inequality constraints
c(1) = 1500–x(1) ˆ 2∗x(2)/3;
c(2) = 2∗x(1)∗((0.5∗x(1)) ˆ 2+x(2) ˆ 2) ˆ 0.5–x(3);
c(3) = c(2)+x(1) ˆ 2;
% Nonlinear equality constraints
ceq = [];
x0 = [50,50,10]; % Make a starting guess at the solution
options = optimset('Algorithm','active-set'),
[x,fval] = fmincon(@objfun_pyramid_minmax,x0,[],[],[],[],[],[],@confun, options);
[x,fval]       % Print results
S = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)
T = 2∗x(1)∗sqrt((0.5∗x(1)) ˆ 2+x(2) ˆ 2)+x(1) ˆ 2
Script 8: Pareto solutions of the beam example.
%Beam example; plot objective domain
clear all;format long
NN=1000000;  %No. of random points for plotting
L=200; rou=2.7∗10ˆ(-3); g=9806;P=1000; E=69000; Sy=27.6;
%----------------------------------------------
A=1; %counting feasible points
B=1; %counting infeasible points
Wmin=1000000;
bow=0;
how=0;
Zmin=1000000;
boz=0;
hoz=0;
for ii=1:NN
        b=rand∗60;
        h=rand∗80;
        W=rou∗b∗h∗L∗g∗10ˆ(-6);
        I=b∗hˆ3/12;
        Z = P∗Lˆ3/(3∗E∗I);
        S=6∗P∗L/(b∗h ˆ 2);
        if S<=Sy & 10<=b & b<=60 & 20<=h & h<=80;
               feasi(:,A)=[W,Z];
               if Wmin > feasi(1,A);
                      Wmin = feasi(1,A);
                      bow=b; how=h;
               end
               if Zmin > feasi(2,A);
                      Zmin = feasi(2,A);
                      boz=b; hoz=h;
               end
               A=A+1;
        else
               infeasi(:,B)=[W,Z];
               B=B+1;
        end
end
figure (1)
plot(feasi(1,:),feasi(2,:),'bs','MarkerSize',3)
xlabel('fw'), ylabel('fz')
Script 9: Solving the pressure vessel example.
%Vessel example; plot objective domain
clear all;format long
NN=1000000;  %No. of random points for plotting
L=100; R = 30; gamma=0.283; P=4000; Sy=32000; pi = 3.1415916;
%----------------------------------------------
A=1; %counting feasible points
B=1; %counting infeasible points
Wmin=1000000;
Row=0;
tow=0;
Vmin=0;
Rov=0;
tov=0;
for ii=1:NN
        R=rand∗10;
        t=rand;
        W=gamma∗(pi∗(R+t) ˆ 2∗(L+2∗t)-pi∗R ˆ 2∗L);
        V = pi∗R ˆ 2∗L;
        if 5∗t<=R & R<=8∗t & t+R<=40 & 0.5<=t & t<=6 & 2.5 < R & R<=5.55;
               feasi(:,A)=[W,V];
               if Wmin > feasi(1,A);
                      Wmin = feasi(1,A);
                      Row=R; tow=t;
               end
               if Vmin > feasi(2,A);
                      Vmin = feasi(2,A);
                      Rov=R; tov=t;
               end
               A=A+1;
         else
               infeasi(:,B)=[W,V];
               B=B+1;
         end
end
figure (1)
plot(feasi(1,:),feasi(2,:),'bs','MarkerSize',3)
xlabel('Self–weight (W)'), ylabel('Negative volume (–V)')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset