Solve a multiobjective optimization problem by problem-based approach in Matlab2021a
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ulisses Anastácio de Oliveira
le 15 Jan 2023
Modifié(e) : Torsten
le 16 Jan 2023
I am trying this:
% teste_multiobjective file
x1 = optimvar('x1','LowerBound',0);
x2 = optimvar('x2','LowerBound',0);
s1 = 5*x1 + 2.5*x2 >= 5;
s2 = x1 + x2 <= 5;
s3 = 2*x1 + 2*x2 >= 3;
% s4 = 20*x1 + 10 * x2 == 20;
% s5 = 60*x1+90*x2 == 90;
prob = optimproblem('ObjectiveSense','minimize');
prob.Objective.obj1 = 20*x1 + 10*x2;
prob.Objective.obj2 = 60*x1 + 90*x2;
prob.Constraints.s1 = s1;
prob.Constraints.s2 = s2;
prob.Constraints.s3 = s3;
% prob.Constraints.s4 = s4;
% prob.Constraints.s5 = s5;
options = optimoptions('gamultiobj',HybridFcn="fgoalattain");
[sol,fval,exitflag,output] = solve(prob,Options=options);
disp(sol.x1)
disp(sol.x2)
disp(fval)
And matlab 2021a show me this:
Error using test_multiobjective
(line 16)
Objective must be a scalar
OptimizationExpression or a
struct containing a scalar
OptimizationExpression.
Does anyone help me, please?
0 commentaires
Réponse acceptée
Matt J
le 16 Jan 2023
Modifié(e) : Matt J
le 16 Jan 2023
You can use prob2matrices from this FEX download,
% teste_multiobjective file
x1 = optimvar('x1','LowerBound',0);
x2 = optimvar('x2','LowerBound',0);
con.s1 = 5*x1 + 2.5*x2 >= 5;
con.s2 = x1 + x2 <= 5;
con.s3 = 2*x1 + 2*x2 >= 3;
options = optimoptions('gamultiobj',HybridFcn="fgoalattain");
p=prob2matrices({x1,x2},'Constraints', con);
fitnessfcn = @(x)[20*x(1) + 10*x(2),60*x(1) + 90*x(2)];
x = gamultiobj(fitnessfcn,2,p.A,p.b,p.Aeq,p.beq,p.lb,p.ub,[],p.intcon,options)
0 commentaires
Plus de réponses (2)
Sulaymon Eshkabilov
le 15 Jan 2023
It is working ok:
% teste_multiobjective file
x1 = optimvar('x1','LowerBound',0);
x2 = optimvar('x2','LowerBound',0);
s1 = 5*x1 + 2.5*x2 >= 5;
s2 = x1 + x2 <= 5;
s3 = 2*x1 + 2*x2 >= 3;
% s4 = 20*x1 + 10 * x2 == 20;
% s5 = 60*x1+90*x2 == 90;
prob = optimproblem('ObjectiveSense','minimize');
prob.Objective.obj1 = 20*x1 + 10*x2;
prob.Objective.obj2 = 60*x1 + 90*x2;
prob.Constraints.s1 = s1;
prob.Constraints.s2 = s2;
prob.Constraints.s3 = s3;
% prob.Constraints.s4 = s4;
% prob.Constraints.s5 = s5;
options = optimoptions('gamultiobj',HybridFcn="fgoalattain");
[sol,fval,exitflag,output] = solve(prob,Options=options);
disp(sol.x1)
disp(sol.x2)
disp(fval)
Torsten
le 15 Jan 2023
% teste_multiobjective file
x1 = optimvar('x1','LowerBound',0);
x2 = optimvar('x2','LowerBound',0);
s1 = 5*x1 + 2.5*x2 >= 5;
s2 = x1 + x2 <= 5;
s3 = 2*x1 + 2*x2 >= 3;
% s4 = 20*x1 + 10 * x2 == 20;
% s5 = 60*x1+90*x2 == 90;
prob = optimproblem('ObjectiveSense','minimize');
prob.Objective.obj1 = 20*x1 + 10*x2;
prob.Objective.obj2 = 60*x1 + 90*x2;
prob.Constraints.s1 = s1;
prob.Constraints.s2 = s2;
prob.Constraints.s3 = s3;
% prob.Constraints.s4 = s4;
% prob.Constraints.s5 = s5;
options = optimoptions('gamultiobj',HybridFcn="fgoalattain");
[sol,fval,exitflag,output] = solve(prob,Options=options);
[x1,I] = sort(sol.x1);
x2 = sol.x2;
x2 = x2(I);
plot(x1,x2)
0 commentaires
Voir également
Catégories
En savoir plus sur Multiobjective Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

