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!