How use fmincon for a function with many variables?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I should minimize this function but don't know how please help me.
cost function:
([31.4*(R0^2- R1^2) *H1 ] + [ 24.7* R2^2*H2]) +u1(-10.856*(R0^2-R1^2)+2400+S1^2) + u2(10.856*(R0^2-R1^2)-2950+S2^2) + u3(-R0 + S3^2) + u4(R0 -17+ S4^2) + u5(-R1 + S5^2) + u6(R1 -13.3+ S6^2) + u7(-R2 + S7^2) + u8(R2 -24.6+ S8^2) + u9(-H1 + S9^2) + u10(H1-32+ S10^2) + u11(-H2 + S11^2) + u12(H1 -69.8+ S12^2).
constraints :
1: u4 - u3 - (2714*R0*u1)/125 + (2714*R0*u2)/125 + (314*H1*R0)/5=0
2:u6 - u5 + (2714*R1*u1)/125 - (2714*R1*u2)/125 - (314*H1*R1)/5=
3:u8 - u7 + (247*H2*R2)/5=0
4:(157*R0^2)/5 - u9 + u10 + u12 - (157*R1^2)/5 =0
5:(247*R2^2)/10 - u11=0
1357*R1^2)/125 + S1^2 - (1357*R0^2)/125 + 2400=0
1357*R0^2)/125 + S2^2 - (1357*R1^2)/125 – 2950=0
S3^2 - R0=0
S4^2 + R0 – 17=0
S5^2 - R1=0
S6^2 + R1 - 133/10 =0
S7^2 - R2=0
S8^2 + R2 - 123/5= 0
S9^2 – H1=0
S10^2 + H1 – 32=0
S11^2 - H2=0
S12^2 + H1 - 349/5=0
ui * sj=0. i= 0 to 12.
j= 0 to 12.
Thanks in advance
0 Kommentare
Antworten (1)
Ayush Modi
am 30 Aug. 2024
Hi Reihaneh,
I understand you want to minimize the given cost function using "fmincon" variable but having difficulty due to multiple parameters. You can pass them as an array in the function parameters. Here is the example code to get you started:
function example(vars)
a = vars(1);
b = vars(2);
... your logic...
end
% To call the fmincon
fmincon(@(x) example(x,n), initial_guess, ...other arguments...)
% Here, vars is an array of variables
Refer to the following MathWorks documentation to know how to pass extra or fixed parameters:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!