Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments
Show older comments
I run the code with seperately set the function and f1, f2, f3, and f4. Why I still got the orange warning. Moreover, could you please check my code. Is it correct?
clear all
%Assignment 2 Multi-Objective functions with Pareto Frontier
%Objective functions
f1 = @(x) (x(1).^4) + ((2.*x(1).^2).*x(2)) + x(2).^2 +3;
f2 = @(x) (x(1).^2-1)^2+x(2).^2-3*x(2)+1;
FITNESSFCN = @(x) [(x(1).^4) + ((2.*x(1).^2).*x(2)) + x(2).^2 + 3, (x(1).^2-1)^2+x(2).^2-3*x(2)+1];
f3 = @(x,y) x.^4 + 2*x.^2.*y + y.^2 +3;
f4 = @(x,y) (x.^2-1)^2+(y.^2)-(3*y)+1;
%Input values
nvars = 2;
A = [];
b = [];
Aeq = [];
beq = [];
nonlcon = [];
lb = [];
ub = [];
%Plot pareto frontier
options = optimoptions(@gamultiobj,'PlotFcn',{@gaplotpareto});
[x, fval] = gamultiobj(FITNESSFCN,nvars,A,b,Aeq,beq,lb,ub,nonlcon,options);
xlabel('f1')
ylabel('f2')
title('Pareto Frontier in Objective Space')
figure
hold on
% Plot Pareto Frontier in Design Space
fcontour(f3, [-30 30 -20 20], 'LineColor', 'red')
fcontour(f4, [-30 30 -20 20], 'LineColor', 'blue')
scatter(x(:,1),x(:,2),10,[0 0 0],'filled','black')
xlabel('x1')
ylabel('x2')
title('Pareto Frontier in Design Space')

Accepted Answer
More Answers (0)
Categories
Find more on Multiobjective Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
