fmincon nonlinear constraints not being optimized

2 次查看(过去 30 天)
Im working on modeling battery gassing. I have IR absorption data from research papers. I know the ratios of these absorption intensities are proportional to the ratios of the number of moles of component gases and thus the average parasitic currents for each component. When i try to optimize my chemical reaction equations to the absorption data my nonlinear constraints do not change. My non linear constraints are of the form:
ceq3=totalcurrent/totalcurrent313K-0.265873214;
ceq4=totalcurrent/totalcurrent333K-0.06471225;
but the final values are just the constants ie ceq3=-0.26 and ceq4=-0.065
How do i get the solver to do this better? I have tried messing with the contraint tolerances and function tolerance.

回答(1 个)

Alan Weiss
Alan Weiss 2021-2-22
编辑:Alan Weiss 2021-2-22
Your code contains a lot of lines of the form
averagecurrentH2(isnan(averagecurrentH2))=0;
When I run your entire code in debugging mode I see that many of these lines are active; in other words, many of the calculations are returning NaN and then returning 0. I suspect that you don't really want all these NaN values, and that something is going wrong with your calculation, and that is why fmincon gets stuck.
FYI, I set a 0 objective function
fun = @(x)0;
I suggest that you debug your nonlinear constraint function. And also, when that is debugged, set your objective to the square of the difference, not the absolute value of the difference:
error = norm((averagecurrentCO2+averagecurrentCO+averagecurrentC2H4+averagecurrentC2H6+averagecurrentO2+averagecurrentPOF3+averagecurrentH2) - 1e-3)^2;
% not
error=abs((averagecurrentCO2+averagecurrentCO+averagecurrentC2H4+averagecurrentC2H6+averagecurrentO2+averagecurrentPOF3+averagecurrentH2)-1*10^-3);
Alan Weiss
MATLAB mathematical toolbox documentation
  1 个评论
Anosh Mevawalla
Anosh Mevawalla 2021-2-24
i did that and is not having any effect my ceq is still converging to
ceq =
-0.0000
0.0000
-0.2659
-0.0647
for some reason it is not considering the constant term subtracted.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by