How to handle warnings in SimBiology within series of simulations?
조회 수: 1 (최근 30일)
이전 댓글 표시
To perform a sensitivity analysis I am running *.sbproj coded models using 'biosimulate' in a for-loop and see for some parameter combinations the following warning:
Warning: The right-hand side of the system of SimBiology ODEs results in complex numbers. The imaginary part of the result will be ignored.
> In sbioodeflux_298d036b_ba03_4469_9210_25b32c7bbb2b (line 44)
In sbiosimulate (line 140)
In GSA (line 107)
Can I trust the solutions? If not, how can I exclude the solutiuons which resulted in the warning above, i.e. is there a way to find programatically if a warning was produced?
Update
I added assignment of NaN's in case of fatal errors but still don't know how to handle the warnings.
try
...
[t,y] = sbiosimulate(m1);
f1(i,j) = trapz(t,y(:,varNo)); % f1 AUC
f2(i,j) = y(end,varNo); % f2 endPoint
catch me
disp( getReport( me, 'extended', 'hyperlinks', 'on' ) )
f1(i,j) = NaN;
f2(i,j) = NaN;
disp('Found an error-----------------------')
end
댓글 수: 0
채택된 답변
Arthur Goldsipe
2019년 9월 3일
Hi,
It's difficult to say for sure whether you can trust the simulation results when you see this warning. I would definitely encourage you to try to understand why you are getting complex numbers. I see this most commonly when a model using exponentiation (such as with Hill kinetics) and a concentration becomes negative. To prevent this warning from occurring, I will sometimes replace terms like x^n with max(0,x)^n.
If you decide you need to programmatically detect when a simulation issues a warning, you can use the lastwarn function. For example, here is how I would modify your sample code to turn any warning that occurs during simulation into an error:
try
%...
lastwarn('', '');
[t,y] = sbiosimulate(m1);
[msg, msgID] = lastwarn;
if ~isempty(msgID) % or check for a specific warning ID
error(msgID, msg);
end
f1(i,j) = trapz(t,y(:,varNo)); % f1 AUC
f2(i,j) = y(end,varNo); % f2 endPoint
catch me
disp( getReport( me, 'extended', 'hyperlinks', 'on' ) )
f1(i,j) = NaN;
f2(i,j) = NaN;
disp('Found an error-----------------------')
end
댓글 수: 0
추가 답변 (0개)
커뮤니티
더 많은 답변 보기: SimBiology Community
참고 항목
카테고리
Help Center 및 File Exchange에서 Perform Sensitivity Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!