bugMCSim simulation sofware - Bugs: bug #57715, Discontinuity time - event missed...

 
 

bug #57715: Discontinuity time - event missed - oops?

Submitter:  None
Submitted:  Fri 31 Jan 2020 09:03:06 PM UTC
   
 
Category:  Sim Severity:  2 - Minor
Priority:  4 Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  fredomatic Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 14 Mar 2020 07:06:40 AM UTC, comment #3: 

Fixed using Alex suggestion. Changed also configure.ac to check for availability of the nextafter function(). No action is taken if the function is not available though. Compilation should fail in that case.

Frederic Yves Bois <fredomatic>
Group administrator
Sat 01 Feb 2020 09:28:18 AM UTC, comment #2: 

Frederic,

Thanks for that. I'll pass on suggestion. We also use R/deSolve from time to time, and that too has an events infrastructure that presents a problem to the user. Recent example pasted below. They seem to be hinting to the user that a workaround, an undesirable one, is in operation.

Alex

Warning messages:
1: In checkevents(events, times, Ynames, dllname, TRUE) :
  Not all event times 'events$times' were in output 'times' so they are automatically included.
2: In checkevents(events, times, Ynames, dllname, TRUE) :
  Some time steps were very close to events - only the event times are used in these cases.

Alex Hogg <hoglet>
Sat 01 Feb 2020 07:53:59 AM UTC, comment #1: 

Thanks. Yes, the way input function values are computed on the fly is prone to that kind of problems. A general fix would be to pre-compute all discontinuities and outputs and merge events close by an epsilon. That's a big task though.
Spikes() in itself is problematic too, and using Events() is better. Can you try to do away with Spikes()? You seem to have an Event at the same time, and at that time the input variable itself takes value 1 (0 elsewhere). So it is in fact a Spike... You can them use it anyway you want to alter your computations.
Frederic

Frederic Yves Bois <fredomatic>
Group administrator
Fri 31 Jan 2020 09:03:06 PM UTC, original submission:  

Frédéric,

This concerns modelu.c, line 286. A model that we're working on, and that makes use of events, produces the diagnostic:

UpdateSpikes: Discontinuity was passed over...

I upgraded the diagnostic output to be more informative:

UpdateSpikes: Discontinuity was passed over:
sim time = 1.90000000000000010
event time = 1.89999999999999990

So, the issue of an event being passed over seems to be caused by comparing two double precision numbers for equality, a perennial source of software bugs. Your "Oops" comment in the source code suggests you thought this was an accident waiting to happen.

I have not tried our model on Linux. We are building MCSim on Windows using mingw. The cc switches are just -O3, and we're linking with GSL.

C99 gives us nextafter() and nextforward(). Using nextafter() seems to offer a fix. See attached, lines 293-308. This corrects the issue for our model but I think a more robust solution is required here.

Alex



Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48318:  modelu.c added by None (24KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by hoglet (Posted a comment)
  • -email is unavailable- added by fredomatic (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-14 fredomatic StatusNone Fixed
        Open/ClosedOpen Closed
    2020-02-01 fredomatic Severity3 - Normal 2 - Minor
        Priority5 - Normal 4
        Assigned toNone fredomatic
    2020-01-31 None Attached File- Added modelu.c, #48318

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code