![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1720126/image.png)
Can I use fmincon with a whole model as function?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Timo Beune
am 21 Jun. 2024
Kommentiert: Timo Beune
am 24 Jun. 2024 um 11:13
I am currently working on an optimization for a flow and electric current problem. The parameters to be optimized are geometric parameters like lengths, diameters, thicknesses of channels etc. I want to use fmincon, but to my understanding I would need to define a function that is dependent on my variables. However the problem itself needs to iterate before a solution is found. Therefore, fmincon would need to put the values of x into the flow and current model, calculate values for current efficiency and pressure drop, and then use these values to optimize. Is that in someway possible? and if yes, how would I define fmincon and the function itself? The model itself is too big to put in, but i will try to give an example:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1719936/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1719941/image.png)
The value of Dp depends on the input parameters defined in x and the same goes for Ic,k but cannot immediatly be linked to them since they first need to iterate. Fmincon then needs to find an optimum for the system efficiency, which is defined as
. So basically my function would be something like
, where x is a vector containing values for channel length, diameter, depth etc. Hopefully this is somewhat clear.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1719946/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1719951/image.png)
2 Kommentare
Sam Chak
am 21 Jun. 2024
Because fmincon() only minimizes the objection function, if you wish to maximize the system efficiency, then the objection function should be written as
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1720126/image.png)
unless I misunderstand the concept of optimality in system efficiency.
Akzeptierte Antwort
Torsten
am 21 Jun. 2024
Bearbeitet: Torsten
am 21 Jun. 2024
I don't see your problem.
You call "fmincon" as
sol = fmincon(@fun,x0)
and write a function "fun" as
function obj = fun(x)
% Compute P_p from x (maybe by iteration or even software different from MATLAB)
% Compute eta_i from x (maybe by iteration or even software different from MATLAB)
obj = -eta_i/P_p
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surrogate Optimization 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!