Multi-Objective Optimization for two functions

5 views (last 30 days)
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.

Answers (1)

Walter Roberson
Walter Roberson on 15 Feb 2022
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
T = function_handle with value:
@(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
R = function_handle with value:
@(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]
lb = 1×4
0 0 2 88
ub = [0.71, 0.71, 5, 155]
ub = 1×4
0.71 0.71 5 155
A = []; b = []; Aeq = []; beq = []
beq = []
[bestX, fval] = gamultiobj(TR, 4, A, b, Aeq, beq, lb, ub)
Optimization terminated: average change in the spread of Pareto solutions less than options.FunctionTolerance.
bestX = 18×4
0.709997365707752 0.00117532062711235 4.49301411408982 98.5507518633246 0.30630689888335 0.00268792681463366 4.53752353503289 90.6453536304247 0.709861013382623 0.00133591947135271 4.49998092805107 94.349974364998 0.645939122230789 0.00233389065794029 4.51520117117762 91.2917504525896 0.537267661066609 0.00221183960966524 4.49862888183494 91.3300428124223 0.398938783555557 0.00204386516674865 4.51503367120587 91.5432055679813 0.501122351194164 0.00228806083862569 4.54754844546615 91.292777698751 0.666812546404952 0.0021858050456307 4.47535686524105 91.1666602012273 0.701127915768272 0.00171843839098094 4.51431491477689 93.1029358681221 0.52034025830135 0.00226124412260621 4.5284134191599 91.3106979288826
fval = 18×2
-17.0959322218368 -68.2521397851279 -121.290026452282 -12.7599995595551 -28.703854541921 -67.8660672012964 -60.7298178625101 -54.9079478935059 -91.5330752144862 -36.8702812070655 -113.841921445558 -20.1699859684843 -99.3532485997198 -31.8218142535223 -53.8924467170037 -58.8552219944456 -35.5939122957008 -65.9239769312704 -95.3640348585106 -34.4469080372334
No = fval(:,1).^2 + fval(:,2).^2
No = 18×1
1.0e+00 * 4950.62548378228 14874.0881055551 5429.71434293464 6702.99351948961 9737.72149450887 13366.8114123854 10883.6958697034 6368.33296916056 5612.89732694872 10280.8886178208
[~, Noidx] = max(No)
Noidx =
2
No_bestX = bestX(Noidx,:)
No_bestX = 1×4
0.30630689888335 0.00268792681463366 4.53752353503289 90.6453536304247
No_fval = fval(Noidx,:)
No_fval = 1×2
-121.290026452282 -12.7599995595551
[~, minidx] = min(fval(:));
[r, c] = ind2sub(size(fval),minidx);
min_bestX = bestX(r,:)
min_bestX = 1×4
0.30630689888335 0.00268792681463366 4.53752353503289 90.6453536304247
min_fval = fval(r,:)
min_fval = 1×2
-121.290026452282 -12.7599995595551
rTR = @(X) -(T(X).^2 + R(X).^2)
rTR = function_handle with value:
@(X)-(T(X).^2+R(X).^2)
[rbestX, rfval] = fmincon(rTR, [.1 .001 4 100], A, b, Aeq, beq, lb, ub)
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
rbestX = 1×4
0.302169691427012 1.80336350948209e-13 4.51841469753535 88.0000000000243
rfval =
-17221.4044970487
TR(rbestX)
ans = 2×1
-130.651343179258 -12.313854900247
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 Comments
Walter Roberson
Walter Roberson on 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.
Walter Roberson
Walter Roberson on 21 Oct 2022
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
T = function_handle with value:
@(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
R = function_handle with value:
@(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 terminated: average change in the spread of Pareto solutions less than options.FunctionTolerance.
bestX = 18×4
0.709631215027965 0.000691612163016357 4.30209680211547 92.6642066027538 0.30655043793747 0.000108118699707399 4.3123156554594 92.0168924018971 0.620747164373015 0.00030956619066227 4.30172782265778 92.7982331659491 0.665090708946464 0.000650536460640152 4.30187779462374 93.0409008270443 0.314952951616484 0.00105495355648429 4.30940390073092 92.0220295774308 0.524813759563309 0.000384240196553653 4.29813065479222 92.2443724963692 0.373787665184151 0.000241890089365513 4.307849582199 92.7631466220264 0.689143795922265 0.000541575737177529 4.28347863319979 93.9451764377616 0.709998908389394 5.0298156638448e-05 4.28070738411478 95.4734147752523 0.673741613072996 0.000411430851449062 4.28888020498379 94.082017054141
fval = 18×2
-32.8260848411393 -67.6296415587247 -117.231190008191 -12.9555342643202 -64.1353959973165 -50.5089100130343 -48.4947132845872 -58.7141188848959 -116.670643470967 -13.4543450964579 -91.2175874138393 -35.1809437210895 -112.085477776996 -18.0125427182392 -36.9012718908675 -63.5404353234055 -24.636080535138 -67.9795765595963 -42.3306665047854 -60.4973539731064
%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
No = 18×1
1.0e+00 * -5651.32026335926 -13910.9977788105 -6664.4990104374 -5799.08497298401 -13793.0584499041 -9558.34705470789 -12887.6060236739 -5399.09078825161 -5228.15929335582 -5451.81516448669
[~, Noidx] = min(No)
Noidx =
2
No_bestX = bestX(Noidx,:)
No_bestX = 1×4
0.30655043793747 0.000108118699707399 4.3123156554594 92.0168924018971
No_fval = fval(Noidx,:) %minimum sum-of-squares
No_fval = 1×2
-117.231190008191 -12.9555342643202
%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_bestX = 1×4
0.30655043793747 0.000108118699707399 4.3123156554594 92.0168924018971
min_fval = fval(r,:) %location with minimum individual function value
min_fval = 1×2
-117.231190008191 -12.9555342643202
%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)
rTR = function_handle with value:
@(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)
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
rbestX = 1×4
0.302169691427012 1.80336350948209e-13 4.51841469753535 88.0000000000243
rfval =
-17221.4044970487
TR(rbestX)
ans = 2×1
-130.651343179258 -12.313854900247

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!