clc;
clear;
close all;
%% Problem Definition
nVar=3; % Number of Decision Variables
VarSize=[1 nVar]; % Decision Variables Matrix Size
VarMin=-5; % Lower Bound of Variables
VarMax= 5; % Upper Bound of Variables
%% Weighted-Sum Approach
t1=inf;
for k=1:50
x0=unifrnd(VarMin,VarMax,VarSize);
[~, t1k]=fminunc(@Objective1,x0);
if t1k<t1
t1=t1k;
end
end
t2=inf;
for k=1:50
x0=unifrnd(VarMin,VarMax,VarSize);
[~, t2k]=fminunc(@Objective2,x0);
if t2k<t2
t2=t2k;
end
end
N=1000;
empty_sol.Position=[];
empty_sol.Cost=[];
sol=repmat(empty_sol,N,1);
w1=linspace(0,1,N);
w2=1-w1;
for i=1:N
FWS=@(x) w1(i)*(Objective1(x)-t1)+w2(i)*(Objective2(x)-t2);
x0=unifrnd(VarMin,VarMax,VarSize);
options=optimset('MaxIter',1000,'MaxFunEvals',1000);
sol(i).Position=fminunc(FWS,x0);
sol(i).Cost=MyCost(sol(i).Position);
end
sol=GetNonDominatedSolutions(sol);
Costs=[sol.Cost];
figure;
plot(Costs(1,:),Costs(2,:),'.');