fmincon nonlinear constraints not being optimized

조회 수: 1 (최근 30일)
Anosh Mevawalla
Anosh Mevawalla 2021년 2월 21일
댓글: Anosh Mevawalla 2021년 2월 24일
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