How to use one fmincon optimizer in a loop and one optimizer out of that loop?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Torsten
2023-1-20
编辑:Torsten
2023-1-20
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 个评论
Torsten
2023-1-20
Maybe I did not define the data set in a correct way.
You mean the parameter set here, don't you ?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geometry and Mesh 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!