How to handle warnings in SimBiology within series of simulations?

3 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Arthur Goldsipe
Arthur Goldsipe el 3 de Sept. de 2019
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

Más respuestas (0)

Comunidades de usuarios

Más respuestas en  SimBiology Community

Categorías

Más información sobre Scan Parameter Ranges en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by