83 double getEventTime()
const {
return m_tEvent; }
84 double getInternalTimeLeft()
const {
return m_Tdiff; }
87 double solveForRealTimeInterval(
const State *pState,
double t0);
91 void subtractInternalTimeInterval(
const State *pState,
double t1);
95 bool isInitialized()
const {
return !(m_Tdiff < 0); }
97 bool needsEventTimeCalculation()
const {
return (m_tEvent < 0); }
98 void setNeedEventTimeCalculation() { m_tEvent = -12345; }
147 virtual double solveForRealTimeInterval(
const State *pState,
double Tdiff,
double t0);
153 bool m_willBeRemoved;
155 static bool s_checkInverse;
159 inline double EventBase::solveForRealTimeInterval(
const State *pState,
double t0)
161 if (!needsEventTimeCalculation())
163 double dt = m_tEvent - t0;
168 double dt = solveForRealTimeInterval(pState, m_Tdiff, t0);
175 double diff = std::abs(tmpDT - m_Tdiff);
178 std::cerr <<
"ERROR: mismatch 1 between solveForRealTimeInterval and calculateInternalTimeInterval" << std::endl;
185 assert(m_tEvent >= 0);
187 #ifdef EVENTBASE_ALWAYS_CHECK_NANTIME
188 if (m_tEvent != m_tEvent)
189 pState->setAbortAlgorithm(
"NaN detected in internal event time calculation");
190 #endif // EVENTBASE_ALWAYS_CHECK_NANTIME
197 inline void EventBase::subtractInternalTimeInterval(
const State *pState,
double t1)
199 assert(m_Tdiff >= 0);
200 assert(m_tLastCalc >= 0);
207 double dt = t1 - m_tLastCalc;
208 double tmpDt = solveForRealTimeInterval(pState, dT, m_tLastCalc);
209 double diff = std::abs(tmpDt - dt);
212 std::cerr <<
"ERROR: mismatch 2 between solveForRealTimeInterval and calculateInternalTimeInterval" << std::endl;
224 #ifdef EVENTBASE_ALWAYS_CHECK_NANTIME
225 if (m_Tdiff != m_Tdiff)
226 pState->setAbortAlgorithm(
"NaN detected in internal event time calculation");
227 #endif // EVENTBASE_ALWAYS_CHECK_NANTIME
230 if (!(m_Tdiff > -1e-15))
231 std::cerr <<
"New m_Tdiff is " << m_Tdiff << std::endl;
233 assert(m_Tdiff > -1e-15);
237 setNeedEventTimeCalculation();
240 #endif // EVENTBASE_H
Type to return true/false with error description.
Definition: booltype.h:25
This is a base class describing the simulation state of an mNRM algorithm.
Definition: algorithm.h:23
void setWillBeRemoved(bool f)
When an event has fired, by default a new internal fire time will be calculated; setting this flag av...
Definition: eventbase.h:106
bool willBeRemoved() const
Check if the event has been marked for deletion, can avoid a call to the random number generator to c...
Definition: eventbase.h:102
static bool_t setCheckInverse(bool check)
In case the program is compiled in debug mode, setting this flag will enable double checking of the m...
Definition: eventbase.cpp:62
virtual double calculateInternalTimeInterval(const State *pState, double t0, double dt)
This function should map the real world time interval onto an internal time interval and return it...
Definition: eventbase.cpp:47
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:16
This class contains the core algorithm (as shown on the main page of the documentation) to execute th...
Definition: algorithm.h:81
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:55
virtual void fire(Algorithm *pAlgorithm, State *pState, double t)
This function will be called when the event fires, so this should most likely be re-implemented in yo...
Definition: eventbase.cpp:57
virtual double getNewInternalTimeDifference(GslRandomNumberGenerator *pRndGen, const State *pState)
This function will be called to generate a new internal time difference.
Definition: eventbase.cpp:33