How to use one fmincon optimizer in a loop and one optimizer out of that loop?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!