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
8 ビュー (過去 30 日間)
古いコメントを表示
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')

0 件のコメント
採用された回答
Torsten
2023 年 4 月 9 日
f4 = @(x,y) (x.^2-1).^2+(y.^2)-(3*y)+1;
instead of
f4 = @(x,y) (x.^2-1)^2+(y.^2)-(3*y)+1;
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multiobjective Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!