% OBJECTIVE FUNCTION
f  = @(x) [x(:,1).^2 - x(:,2), -0.5*x(:,1) - x(:,2) - 1]

% OPTIMIZATION SETTINGS
o = struct	% initializing struct 
g1 = @(x) 6.5 - x(:,1)./6 - x(:,2)
g2 = @(x) 7.5 - 0.5*x(:,1) - x(:,2)
g3 = @(x) 30 - 5*x(:,1) - x(:,2)
o.g = @(x) g1(x).*(g1(x)<0) + g2(x).*(g2(x)<0) + g3(x).*(g3(x)<0)	% constraints
o.d = 2	% dimension of decision variable
o.lb = -7	% lower bounds
o.ub = 4	% upper bounds

% ALGORITHM OPTIONS

o.maxit = 40	% number of iterations 
o.pop = 100	% number of population 

% OPTIMIZATION 
rng(0)	% for tractability 
[popPos,popFront,popCost,popInfo,traceIt] = nsga2(f,o)	% running minimization  

% ANIMATION
% Uncomment the following code to generate animation % 
% rng(0)
% [~,~,~,~,~,info] = nsga2(f,o)
% info.plot = 'pareto'
% info.animate = true	% plot animation 
% info.animfreq = 4	% frame frequency 
% optimview('nsga2',info)