19 #define EVENTBASE_CHECK_INVERSE
76 virtual void fire(
State *pState,
double t);
84 double getEventTime()
const {
return m_tEvent; }
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; }
100 bool willBeRemoved()
const {
return m_willBeRemoved; }
101 void setWillBeRemoved(
bool f) { m_willBeRemoved = f; }
138 virtual double solveForRealTimeInterval(
const State *pState,
double Tdiff,
double t0);
144 bool m_willBeRemoved;
147 inline double EventBase::solveForRealTimeInterval(
const State *pState,
double t0)
149 if (!needsEventTimeCalculation())
151 double dt = m_tEvent - t0;
156 double dt = solveForRealTimeInterval(pState, m_Tdiff, t0);
159 #ifdef EVENTBASE_CHECK_INVERSE
161 double diff = std::abs(tmpDT - m_Tdiff);
164 std::cerr <<
"ERROR: mismatch 1 between solveForRealTimeInterval and calculateInternalTimeInterval" << std::endl;
167 #endif // EVENTBASE_CHECK_INVERSE
170 assert(m_tEvent >= 0);
177 inline void EventBase::subtractInternalTimeInterval(
const State *pState,
double t1)
179 assert(m_Tdiff >= 0);
180 assert(m_tLastCalc >= 0);
184 #ifdef EVENTBASE_CHECK_INVERSE
185 double dt = t1 - m_tLastCalc;
186 double tmpDt = solveForRealTimeInterval(pState, dT, m_tLastCalc);
187 double diff = std::abs(tmpDt - dt);
190 std::cerr <<
"ERROR: mismatch 2 between solveForRealTimeInterval and calculateInternalTimeInterval" << std::endl;
193 #endif // EVENTBASE_CHECK_INVERSE
202 if (!(m_Tdiff > -1e-15))
203 std::cerr <<
"New m_Tdiff is " << m_Tdiff << std::endl;
205 assert(m_Tdiff > -1e-15);
209 setNeedEventTimeCalculation();
213 #endif // EVENTBASE_H
This class both describes the simulation state and contains the core algorithm (as shown on the main ...
Definition: state.h:40
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:42
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:15
virtual void fire(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:52
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:60
virtual double getNewInternalTimeDifference(GslRandomNumberGenerator *pRndGen, const State *pState)
This function will be called to generate a new internal time difference.
Definition: eventbase.cpp:28