Optimization is generating error plotting pareto front

1 view (last 30 days)
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;

Accepted Answer

Walter Roberson
Walter Roberson on 10 Jan 2017
Change
[x, fval] = gamultiobj(fitness, nvar);
to
[xy, fval] = gamultiobj(fitness, nvar);
x = xy(1); y = xy(2);
  2 Comments
Ba Ba Black Sheep!
Ba Ba Black Sheep! on 10 Jan 2017
How can I generate the table for data values for the Pareto front?
Walter Roberson
Walter Roberson on 10 Jan 2017
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!