optimize four functions together

3 次查看(过去 30 天)
Hello,
I have four functions and I want to optimize them together by ga. I know that I can solve each function alone and I already got an answer about that, but if I have all of them. The values I want to get is F1=0.405, F2=24.736 ,F3=0.525, F4=14.97. I approciate any help.
F1=@(x) 0.25-4.27*x(1)+0.61*x(2)+13.34*x(1)*x(2)-4.69*x(2).^2;
F2 = @(x) 30.07+71.68*x(1)-21.83*x(2)-306.55*x(1)*x(2)+179*x(2)^2;
F3 = @(x) 0.54-18.32*x(3)-10.6*x(1)-3.22*x(2)+0.3*x(4)+273.71*x(3)*x(1)+60.28*x(1)*x(2)-19.81*x(2).^2;
F4 = @(x) 17.39+1246.36*x(3)+348.83*x(1)-88.27*x(2)-43.72*x(4)-24455.25*x(3)*x(1)-1164.66*x(1)*x(2)+347.38*x(2)*x(4);
FitnessFunction=[F1;F2;F3;F4];
% [ fn, fc, f0, ff] ; % the range like this
lb = [0.001,0.01,0.0002,0.1];
ub = [0.045,0.1,0.0045,0.2];
numberOfVariables = 4;
A = []; b = [];
Aeq = []; beq = [];
[x,fval] = ga(FitnessFunction, numberOfVariables, A, b, Aeq, beq, lb, ub)
Many thanks

采纳的回答

Walter Roberson
Walter Roberson 2023-5-24
移动:Matt J 2023-5-24
  6 个评论
Walter Roberson
Walter Roberson 2023-5-25
Option 1: functions are independent, but for some reason you want to call an optimizer only once instead of making four separate optimization calls. Note that this approach will always be less efficient than making separate optimization calls:
F1=@(x) 0.25-4.27*x(1)+0.61*x(2)+13.34*x(1)*x(2)-4.69*x(2).^2;
F2 = @(x) 30.07+71.68*x(1)-21.83*x(2)-306.55*x(1)*x(2)+179*x(2)^2;
F3 = @(x) 0.54-18.32*x(3)-10.6*x(1)-3.22*x(2)+0.3*x(4)+273.71*x(3)*x(1)+60.28*x(1)*x(2)-19.81*x(2).^2;
F4 = @(x) 17.39+1246.36*x(3)+348.83*x(1)-88.27*x(2)-43.72*x(4)-24455.25*x(3)*x(1)-1164.66*x(1)*x(2)+347.38*x(2)*x(4);
FitnessFunction = @(x)[F1(x(1:2));F2(x(3:4));F3(x(5:8));F4(x(9:12))];
lb = [0.001,0.01,0.001,0.01,0.001,0.01,0.0002,0.1,0.001,0.01,0.0002,0.1]
lb = 1×12
0.0010 0.0100 0.0010 0.0100 0.0010 0.0100 0.0002 0.1000 0.0010 0.0100 0.0002 0.1000
ub = [0.045,0.1,0.045,0.1,0.045,0.1,0.0045,0.2,0.045,0.1,0.0045,0.2]
ub = 1×12
0.0450 0.1000 0.0450 0.1000 0.0450 0.1000 0.0045 0.2000 0.0450 0.1000 0.0045 0.2000
numberOfVariables = length(lb);
A = []; b = [];
Aeq = []; beq = [];
[x,fval] = gamultiobj(FitnessFunction, numberOfVariables, A, b, Aeq, beq, lb, ub)
Optimization terminated: average change in the spread of Pareto solutions less than options.FunctionTolerance.
x = 70×12
0.0069 0.0874 0.0029 0.0699 0.0449 0.0998 0.0044 0.1174 0.0228 0.0671 0.0045 0.1266 0.0197 0.0478 0.0209 0.0822 0.0237 0.0424 0.0014 0.1303 0.0023 0.0850 0.0003 0.1963 0.0428 0.0262 0.0249 0.0678 0.0434 0.0967 0.0043 0.1480 0.0424 0.0103 0.0036 0.1437 0.0450 0.0133 0.0194 0.0335 0.0375 0.0753 0.0036 0.1438 0.0368 0.0509 0.0022 0.1538 0.0233 0.0527 0.0104 0.0886 0.0072 0.0194 0.0009 0.1574 0.0022 0.0842 0.0009 0.1781 0.0283 0.0451 0.0159 0.0898 0.0034 0.0173 0.0005 0.1603 0.0018 0.0845 0.0008 0.1790 0.0295 0.0369 0.0066 0.0876 0.0050 0.0162 0.0014 0.1669 0.0107 0.0921 0.0010 0.1376 0.0097 0.0709 0.0010 0.0641 0.0448 0.0706 0.0045 0.1184 0.0090 0.0996 0.0045 0.1625 0.0277 0.0369 0.0066 0.0872 0.0031 0.0162 0.0003 0.1669 0.0105 0.0910 0.0010 0.1376 0.0281 0.0523 0.0101 0.0892 0.0037 0.0188 0.0009 0.1593 0.0021 0.0844 0.0009 0.1784
fval = 70×4
0.2461 29.5665 -0.1761 18.1384 0.1969 30.4569 0.2000 8.0086 0.0949 30.6783 -0.1471 25.7319 0.0731 30.7326 -0.0284 20.2926 0.1861 30.0021 0.4339 9.0363 0.1641 30.2558 0.4850 8.7437 0.1546 29.8277 0.4598 11.2062 0.2375 29.4582 -0.0617 13.7948 0.1615 29.8246 0.4979 11.2112 0.1686 29.9956 0.4701 8.9272
Walter Roberson
Walter Roberson 2023-5-25
Option 2: variables are shared, x(1) is the same variable for each, x(2) is the same for each, x(3) is the same for each that uses it, etc.
F1=@(x) 0.25-4.27*x(1)+0.61*x(2)+13.34*x(1)*x(2)-4.69*x(2).^2;
F2 = @(x) 30.07+71.68*x(1)-21.83*x(2)-306.55*x(1)*x(2)+179*x(2)^2;
F3 = @(x) 0.54-18.32*x(3)-10.6*x(1)-3.22*x(2)+0.3*x(4)+273.71*x(3)*x(1)+60.28*x(1)*x(2)-19.81*x(2).^2;
F4 = @(x) 17.39+1246.36*x(3)+348.83*x(1)-88.27*x(2)-43.72*x(4)-24455.25*x(3)*x(1)-1164.66*x(1)*x(2)+347.38*x(2)*x(4);
FitnessFunction = @(x)[F1(x(1:2));F2(x(1:2));F3(x(1:4));F4(x(1:4))];
lb = [0.001,0.01,0.0002,0.1];
ub = [0.045,0.1,0.0045,0.2];
numberOfVariables = length(lb);
A = []; b = [];
Aeq = []; beq = [];
[x,fval] = gamultiobj(FitnessFunction, numberOfVariables, A, b, Aeq, beq, lb, ub)
Optimization terminated: average change in the spread of Pareto solutions less than options.FunctionTolerance.
x = 20×4
0.0450 0.0100 0.0045 0.2000 0.0435 0.0991 0.0023 0.1445 0.0018 0.0867 0.0011 0.1504 0.0015 0.0672 0.0020 0.1515 0.0015 0.0627 0.0021 0.1536 0.0027 0.0203 0.0025 0.1472 0.0353 0.0101 0.0043 0.1983 0.0021 0.0138 0.0023 0.1839 0.0409 0.0872 0.0031 0.1794 0.0404 0.0106 0.0044 0.1578
fval = 20×4
0.0695 32.9573 0.0889 24.2877 0.1360 31.4632 -0.1465 17.8785 0.2620 29.6038 0.1286 9.4199 0.2646 29.4904 0.2332 11.2367 0.2645 29.4862 0.2587 11.4209 0.2497 29.8765 0.4412 14.0291 0.1098 32.2882 0.1753 22.0645 0.2491 29.9413 0.4849 12.5083 0.1403 31.3677 -0.0786 18.1736 0.0891 32.6241 0.1160 24.8790

请先登录,再进行评论。

更多回答(1 个)

nadia nadi
nadia nadi 2023-5-25
编辑:nadia nadi 2023-5-25

Hello Walter,

I have two variables in First and second equations and four variables in the third and fourth. So you mean I need to write 12 different variables, I set their range and run the code ??

  1 个评论
Torsten
Torsten 2023-5-25
编辑:Torsten 2023-5-25
If these 12 variables are not interconnected, you have 4 independent problems to solve. Thus call "fmincon" 4 times, with F_i as objective function for the i-th call.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by