How to use one fmincon optimizer in a loop and one optimizer out of that loop?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Farangis
am 20 Jan. 2023
Kommentiert: Farangis
am 20 Jan. 2023
I am trying to optimize k and Ea values for a set of reactions (ode equations) for two different data sets (t,T). We know that k and Ea values can be different for each data set based on the temperature. Also, there is a stoichiometric factor (alpha) that should be optimized which logically, should be the same for both data sets.
So, I need to optimize the k and Ea values first inside a loop and then take the optimized k and Ea values to be utilized for an outer loop optimization part optimizing the stoichiometric factor (alpha).
My problem is that I do ot know haw to take the optimized k and Ea values and substitute them in ode equations to be utilized for the outer loop optimization part. Also, I do not know what the lenght of "i" should be exactly. I would be thankful if anyone could help me with that.
Here is that part of my code:
function Res = Alpha_objfunc(alpha)
for i = 1:1
k0_vec0 = [0.63, 0.03, 0.951; 17000, 10000, 100000]; % combination of k and Ea (the second raw)
A=[];
b=[];
Aeq=[];
beq=[];
lb=[];
ub=[];
options=optimoptions('fmincon','Display','iter','Algorithm','sqp');
[k0_vec,fval]=fmincon(@Obj_func60,k0_vec0,A,b,Aeq,beq,lb,ub,@Con_func60,options);
% k0_vec0=k0_vec;
while fval > 0.000001 % I am not sure if it is useful or not
Ode_Cell_deg60;
k0_vec = k0_vec(i);
end
fvalnew = fval(end);
end
Res = fvalnew; % Taking Rseiduals for alpha optimization part
end
0 Kommentare
Akzeptierte Antwort
Torsten
am 20 Jan. 2023
Bearbeitet: Torsten
am 20 Jan. 2023
Why don't you optimize all parameters in one call to fmincon ?
It's not a problem that Ea and k are different for each dataset, but that they share a common value for alpha.
Further I suggest using "lsqcurvefit" instead of "fmincon" which is especially designed for such fitting problems.
Take a look at
to see how to proceed.
6 Kommentare
Torsten
am 20 Jan. 2023
Maybe I did not define the data set in a correct way.
You mean the parameter set here, don't you ?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Geometry and Mesh 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!