Multi-Objective Optimization for two functions
Afficher commentaires plus anciens
I have two objective functions(both objectives need to minimize) & in one objective function consisting with 4 varibales ( x1, x2, x3, x4) with boundryies[0<= x1=>0.71, 0<= x2=>0.71,2<= x3=>5,0.71,88<= x4=>155]. Now I want to optimize bothe function together.
Objective fun 01
T=-48-285*X(1)+421*X(2)-220.4*X(3)+7.24*X(4)+481*X(1)^2+ 51.5*X(2)^2+24.39*X(3)^2-0.0232*X(4)^2
Objective fun 02
R= 28.66+50.01*X(1)+35.80*X(2)-6.925*X(3)-0.4221*X(4)-182.6*X(1)^2-3.741*X(2)^2+0.7566*X(3)^2+0.001753*X(4)^2
how can I optimize both objective at once time ?
Please help.
Réponses (1)
format long g
T = @(X) -48-285*X(1)+421*X(2)-220.4*X(3)+7.24*X(4)+481*X(1)^2+ 51.5*X(2)^2+24.39*X(3)^2-0.0232*X(4)^2
R = @(X) 28.66+50.01*X(1)+35.80*X(2)-6.925*X(3)-0.4221*X(4)-182.6*X(1)^2-3.741*X(2)^2+0.7566*X(3)^2+0.001753*X(4)^2
TR = @(X) [T(X); R(X)];
lb = [0, 0, 2, 88]
ub = [0.71, 0.71, 5, 155]
A = []; b = []; Aeq = []; beq = []
[bestX, fval] = gamultiobj(TR, 4, A, b, Aeq, beq, lb, ub)
No = fval(:,1).^2 + fval(:,2).^2
[~, Noidx] = max(No)
No_bestX = bestX(Noidx,:)
No_fval = fval(Noidx,:)
[~, minidx] = min(fval(:));
[r, c] = ind2sub(size(fval),minidx);
min_bestX = bestX(r,:)
min_fval = fval(r,:)
rTR = @(X) -(T(X).^2 + R(X).^2)
[rbestX, rfval] = fmincon(rTR, [.1 .001 4 100], A, b, Aeq, beq, lb, ub)
TR(rbestX)
Under at least one definition, at least to working precision, rbestX is the best value. But you can see from min_fval that there are other locations that might give a smaller R output.
6 commentaires
Kumar sirinath
le 17 Fév 2022
Modifié(e) : Kumar sirinath
le 17 Fév 2022
Kumar sirinath
le 17 Fév 2022
Walter Roberson
le 17 Fév 2022
Look at the bestX output from gamultiobj() and mentally round them off to give an approximate solution as a starting point for fmincon()
Kumar sirinath
le 18 Fév 2022
Walter Roberson
le 21 Oct 2022
To be honest, I no longer remember why I used
[~, Noidx] = max(No)
instead of min(No) . The max() would be for some kind of maximization, and I don't know now why I did that.
rTR = @(X) -(T(X).^2 + R(X).^2)
and that was for a maximization too, and I don't know why I asked for that.
format long g
T = @(X) -48-285*X(1)+421*X(2)-220.4*X(3)+7.24*X(4)+481*X(1)^2+ 51.5*X(2)^2+24.39*X(3)^2-0.0232*X(4)^2
R = @(X) 28.66+50.01*X(1)+35.80*X(2)-6.925*X(3)-0.4221*X(4)-182.6*X(1)^2-3.741*X(2)^2+0.7566*X(3)^2+0.001753*X(4)^2
TR = @(X) [T(X); R(X)];
lb = [0, 0, 2, 88];
ub = [0.71, 0.71, 5, 155];
A = []; b = []; Aeq = []; beq = [];
[bestX, fval] = gamultiobj(TR, 4, A, b, Aeq, beq, lb, ub)
%optimization of two functions together is not really defined, but one
%thing we can do is look for the minimum sum-of-squares for the functions.
%but that by itself looks for values closest to zero, which is not
%appropriate for cases where the values are negative and you want
%most-negative. So we modify the square by the sign
No = sign(fval(:,1)).*fval(:,1).^2 + sign(fval(:,2)).*fval(:,2).^2
[~, Noidx] = min(No)
No_bestX = bestX(Noidx,:)
No_fval = fval(Noidx,:) %minimum sum-of-squares
%we can also look for the point that has the lowest overall function value,
%which is a different form of optimization
[~, minidx] = min(fval(:));
[r, c] = ind2sub(size(fval),minidx);
min_bestX = bestX(r,:)
min_fval = fval(r,:) %location with minimum individual function value
%now we can cross-check by running fmincon on the sum-of-squares modified
%by sign
rTR = @(X) (sign(T(X)).*T(X).^2 + sign(R(X)).*R(X).^2)
[rbestX, rfval] = fmincon(rTR, [.1 .001 4 100], A, b, Aeq, beq, lb, ub)
TR(rbestX)
Catégories
En savoir plus sur Surrogate Optimization dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!