Optimization is generating error plotting pareto front

2 次查看(过去 30 天)
The following code is generating the following error,
>> main
Optimization terminated: average change in the spread of Pareto
solutions less than options.TolFun.
Undefined function or variable 'y'.
Error in main (line 9)
f1 = x.^4 + y.^4 - x.^2 * y.^2 + x * y - 10 * x.^2;
simpleMultiObjective.m
function z = simpleMultiObjective(xy)
x = xy(1); y = xy(2);
z(1) = x.^4 + y.^4 - x.^2 * y.^2 + x * y - 10 * x.^2;
z(2) = x.^4 + y.^4 - x.^2 * y.^2 + x * y;
end
main.m
fitness = @simpleMultiObjective;
nvar = 2;
[x, fval] = gamultiobj(fitness, nvar);
x0 = -5:0.5:5;
f1 = x.^4 + y.^4 - x.^2 * y.^2 + x * y - 10 * x.^2;
f2 = x.^4 + y.^4 - x.^2 * y.^2 + x * y;
figure; hold on
plot(x0, f1);
plot(x0, f2);
grid;
xlabel('x');
ylabel('f');
plot(x, fval(:, 1), 'x');
plot(x, fval(:, 2), 'o');
figure;
plot(fval(:, 1), fval(:,2), 'o');
xlabel('f1');
ylabel('f2');
grid;

采纳的回答

Walter Roberson
Walter Roberson 2017-1-10
Change
[x, fval] = gamultiobj(fitness, nvar);
to
[xy, fval] = gamultiobj(fitness, nvar);
x = xy(1); y = xy(2);
  2 个评论
Ba Ba Black Sheep!
Ba Ba Black Sheep! 2017-1-10
How can I generate the table for data values for the Pareto front?
Walter Roberson
Walter Roberson 2017-1-10
What table? The answer to what you calculated is a particular pair of values that is the pareto optimum. There is no "table" associated with a pair of values.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multiobjective Optimization 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by