I have tried so many times to write the code of extracting the non-dominated (or dominated)
solutions for two objective functions using MATLAB.
I have two simple objective functions:
J1=x.^2
J2=(x-2).^2
and I have a range for x values, say from -5 to 5 and there are, for example, 100 solutions to be
generated randomly within the range specified.
I want to extract the non-dominated solutions from these solutions.
I have no problem of all above operations. What I have done so far is:
% generating 100 solutions randomly between -5 and 5:
x=-5+10*rand(100,1);
% calculate both objective functions, J1 and J2 at each solution:
J1=x.^2;
J2=(x-2).^2;
Now, I faced the problem of how to translate the concept to a written code.
I know the concept of how to extract the non-dominated solutions and Pareto front.
I can do it manually but this will take very long time.
I tried using if statements but the results were not accurate.
I think it is better to extract the indices of the dominated solutions and then remove them from
the main vector x to get the non-dominated solutions.
Thanks in advance
do you mind files from FEX? This one works perfectly: "Pareto Front" by Yi Cao
giving you the indices of x
of dominating solutions.
Then you just have to use it like this:
x=-5+10*rand(100,1);
J1=x.^2;
J2=(x-2).^2;
idx = paretofront([J1,J2]);
xdi = ~ismember(idx,1:numel(x));
figure(1)
hold on
scatter(J1,J2,10,'red');
scatter(J1(idx),J2(idx),50,'blue');
scatter(J1(xdi),J2(xdi),50,'green');
hold off
legend('all solutions','dominating solutions','non dominating solutions')
leads to:
which is exactly how it is supposed to look like. Otherwise you need to clarify your question.