Azzera filtri
Azzera filtri

how can I solve an error of a different number of elements in GA multiobjective optimization?

3 visualizzazioni (ultimi 30 giorni)
Hello all,
here is my code.
fitness =@levulinicAcid;
nvars = 2;
[x,fval] = gamultiobj(fitness, nvars, [],[],[],[],[0.2 10],[0.3 100]);
%%Check the results
x(1) = 10:10:100;
x(2) = 0.2:0.01:0.3;
f1 = -(-4.398907104 + 69.627287709*x(1) - 73.88575606*x(2));
f2 = 5.5828360656 + 0.0697243039*x(1) - 0.052863409*x(2); %FEDI
f3 = 119.81506557 + 1291.2552396*x(1) - 249.4926284*x(2); %GWP
figure; hold on
plot(x(1),x(2),f1);
plot(x(1),x(2),f2);
plot(x(1),x(2),f3);
grid;
xlabel('x');
ylabel('f');
  2 Commenti
Stephan
Stephan il 9 Gen 2019
Modificato: Stephan il 9 Gen 2019
What error do you get? Provide the complete red text. Also provide the fitness function and data if needed to run the code. Why do you overwrite the reults of gamultiobj after determining them?
Rendra Hakim hafyan
Rendra Hakim hafyan il 9 Gen 2019
As I have two variables in my optimization. I have got the error of different elements in my lower bound and upper bound. this below part:
x(1) = 10:10:100;
x(2) = 0.2:0.01:0.3;
actually the fitness function contains the objective function only.
function y = levulinicAcid(x)
y(1) = -(-4.398907104 + 69.627287709*x(1) - 73.88575606*x(2)); %NPV
y(2) = 5.5828360656 + 0.0697243039*x(1) - 0.052863409*x(2); %FEDI
y(3) = 119.81506557 + 1291.2552396*x(1) - 249.4926284*x(2); %GWP
end
My objective is to maximize NPV then minimize both GWP and FEDI.

Accedi per commentare.

Risposte (1)

Stephan
Stephan il 9 Gen 2019
Hi,
try:
% Optimize with gamultiobj
fitness =@levulinicAcid;
nvars = 2;
[x,fval] = gamultiobj(fitness, nvars, [],[],[],[],[0.2 10],[0.3 100]);
% Plot results
subplot(3,1,1)
scatter3(x(:,1),x(:,2),fval(:,1),'or')
xlabel('x(1)')
ylabel('x(2)')
title('y1')
subplot(3,1,2)
scatter3(x(:,1),x(:,2),fval(:,2),'og')
xlabel('x(1)')
ylabel('x(2)')
title('y2')
subplot(3,1,3)
scatter3(x(:,1),x(:,2),fval(:,3),'ob')
xlabel('x(1)')
ylabel('x(2)')
title('y3')
% Objective function
function y = levulinicAcid(x)
y(1) = -(-4.398907104 + 69.627287709*x(1) - 73.88575606*x(2)); %NPV
y(2) = 5.5828360656 + 0.0697243039*x(1) - 0.052863409*x(2); %FEDI
y(3) = 119.81506557 + 1291.2552396*x(1) - 249.4926284*x(2); %GWP
end
This runs for me on R2018b and gives a result:
result_gamultiobj.PNG
Best regards
Stephan
  5 Commenti
Stephan
Stephan il 10 Gen 2019
"I would like to know how many generation can be formed?"
I do not know that there is a limit other than the time and resources you have available. The default is 100 * nvars. But look at your iterations - the algorithm converges after about 100...120 generations for your problem. So why do you want to change that?
"what result am I supposed to show from Genetic Algorithm? pareto front only?"
I can not tell you which plot is the most useful for you. For the given problem the pareto front is a straight line in the 3D-space of your objectives. Does it help you to interpret the results? Do you have more insight to the problem by looking how the y(i) depends from x(1) and x(2)? I can not say - it is just the question of what helps you most to interprete your results and work with them.
A possible way to get an idea of what could be the most helpful plot is to try it out with some different plots and with a quiet big population:
% Optimize with gamultiobj
options = optimoptions('gamultiobj','Display','iter',...
'MaxGeneration',200,...
'PopulationSize',2500,...
'PlotFcn',@gaplotpareto);
fitness =@levulinicAcid;
nvars = 2;
[x,fval] = gamultiobj(fitness, nvars, [],[],[],[],[0.2 10],[0.3 100],options);
% Plot results
figure(2)
subplot(2,2,1)
scatter3(fval(:,1),fval(:,2),fval(:,3),'or')
xlabel('y(1)')
ylabel('y(2)')
zlabel('y(3)')
title('Pareto Front')
subplot(2,2,2)
scatter3(x(:,1),x(:,2),fval(:,1),'or')
xlabel('x(1)')
ylabel('x(2)')
title('y1')
subplot(2,2,3)
scatter3(x(:,1),x(:,2),fval(:,2),'og')
xlabel('x(1)')
ylabel('x(2)')
title('y2')
subplot(2,2,4)
scatter3(x(:,1),x(:,2),fval(:,3),'ob')
xlabel('x(1)')
ylabel('x(2)')
title('y3')
% Objective function
function y = levulinicAcid(x)
y(1) = -(-4.398907104 + 69.627287709*x(1) - 73.88575606*x(2)); %NPV
y(2) = 5.5828360656 + 0.0697243039*x(1) - 0.052863409*x(2); %FEDI
y(3) = 119.81506557 + 1291.2552396*x(1) - 249.4926284*x(2); %GWP
end
Using this code you get this result:
result_multiobj.PNG
Rendra Hakim hafyan
Rendra Hakim hafyan il 11 Gen 2019
Modificato: Rendra Hakim hafyan il 11 Gen 2019
After I tried to change the number of population, the generation stopped at around 100 - 120 as you did as well. I'd like to see the effect of number population to the solution I get anyway.
so, it can conclude that my result shows a trade-off. what if I would like to combine three objective into single objective. Should I use weighted factor? how could I do a weighted objective?
y(1) = -(-4.398907104 + 69.627287709*x(1) - 73.88575606*x(2)); %NPV
y(2) = 5.5828360656 + 0.0697243039*x(1) - 0.052863409*x(2); %FEDI
y(3) = 119.81506557 + 1291.2552396*x(1) - 249.4926284*x(2); %GWP
I want to compared the multi-objective result with single objective.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by