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 コミュニティ
参考
カテゴリ
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!