Clear Filters
Clear Filters

Number of plots by gaplotpareto

5 views (last 30 days)
asaii
asaii on 22 Nov 2023
Commented: Alan Weiss on 28 Nov 2023
How is the number of plots in the graph from this document defined?
x = -10:0.5:10;
f1 = (x+2).^2 - 10;
f2 = (x-2).^2 + 20;
plot(x,f1);
hold on;
plot(x,f2,'r');
grid on;
title('Plot of objectives ''(x+2)^2 - 10'' and ''(x-2)^2 + 20''');
FitnessFunction = @simple_multiobjective;
numberOfVariables = 1;
[x,fval] = gamultiobj(FitnessFunction,numberOfVariables);
size(x)
size(fval)
A = []; b = [];
Aeq = []; beq = [];
lb = -1.5;
ub = 0;
x = gamultiobj(FitnessFunction,numberOfVariables,A,b,Aeq,beq,lb,ub);
options = optimoptions(@gamultiobj,'PlotFcn',{@gaplotpareto,@gaplotscorediversity});
gamultiobj(FitnessFunction,numberOfVariables,[],[],[],[],lb,ub,options);
FitnessFunction = @(x) vectorized_multiobjective(x);
options = optimoptions(@gamultiobj,'UseVectorized',true);
gamultiobj(FitnessFunction,numberOfVariables,[],[],[],[],lb,ub,options);

Accepted Answer

Alan Weiss
Alan Weiss on 27 Nov 2023
If I understand your question, you are asking either
  • How does the solver choose the number of points to plot? Or
  • How does the solver decide to make a 2-D plot?
The first question is asking how does the solver work. You can find out be reading the algorithm description: https://www.mathworks.com/help/gads/gamultiobj-algorithm.html
For the second question, the plot function plots one axis for each objective function as long as there are only 2 or 3 objective functions. This problem has two objective functions, so produces a 2-D plot.
If I misunderstood what you were asking, please ask again in more detail.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 Comments
asaii
asaii on 28 Nov 2023
Thank you for teaching me so kindly.
The content I wanted to ask about was "How does the solver choose the number of points to plot?"
I found more details at the URL you provided.
As an additional question, is it possible to monitor the process of calculating the number of plots programmatically?
Alan Weiss
Alan Weiss on 28 Nov 2023
I'm not sure that I understand what you are asking. If you are asking about the number of points plotted, the last line of the algorithm description of iterations says "Trim the extended population to have PopulationSize individuals by retaining the appropriate number of individuals of each rank." In other words, the number of points plotted grows as the process continues until PopulationSize points are plotted, and then the software keeps the number at PopulationSize. I don't know offhand how to programmatically query how many points are plotted; I supose that you could use an output function to do that, but I don't know for sure.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

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!