From cf9a69c227dced01874be7cc121ba38453a85c31 Mon Sep 17 00:00:00 2001 From: Ali Sinan Saglam Date: Thu, 20 Dec 2018 12:36:41 -0500 Subject: [PATCH] Changed how the t_start value is ensured to be equal to the last end point (if given) using a tolerance of 1e-15. This fixes an issue where the t_start value and the end point are the same but "==" operator returns false due to machine precision error and the simulation fails to run. --- bng2/Perl2/BNGAction.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bng2/Perl2/BNGAction.pm b/bng2/Perl2/BNGAction.pm index 29cc3be8..a294c5da 100644 --- a/bng2/Perl2/BNGAction.pm +++ b/bng2/Perl2/BNGAction.pm @@ -421,13 +421,14 @@ sub simulate # Set start time for trajectory my $t_start; + my $tol=1e-15; if ( defined $params->{t_start} ) { $t_start = $params->{t_start}; # if this is a continuation, check that model time equals t_start if ($continue) { - unless ( defined($model->Time) and ($model->Time == $t_start) ) + unless ( defined($model->Time) and (abs($model->Time - $t_start) < $tol) ) { return "t_start must equal current model time for continuation."; } } }