void IzhikevichBranch::update(nest::Time const & origin, const nest::long_t from, const nest::long_t to) { assert(to >= 0 && (nest::delay) from < nest::Scheduler::get_min_delay()); assert(from < to); nest::long_t current_steps = origin.get_steps(); for (nest::long_t lag = from; lag < to; ++lag) { /***** Solve ODE over timestep *****/ B_.current_regime->step_ode(); /***** Transition handling *****/ // Get multiplicity incoming events for the current lag and reset multiplicity of outgoing events refresh_events(lag); Transition_* transition; int simultaneous_transition_count = 0; double prev_t = origin.get_ms(); while ((transition = B_.current_regime->transition(origin, lag))) { // Check for a transition (i.e. the output of current_regime->transition is not NULL) and record it in the 'transition' variable. double t = transition->time_occurred(origin, lag); // Get the exact time the transition occurred. if (t == prev_t) ++simultaneous_transition_count; else simultaneous_transition_count = 0; if (simultaneous_transition_count > MAX_SIMULTANEOUS_TRANSITIONS) throw ExceededMaximumSimultaneousTransitions("IzhikevichBranch", simultaneous_transition_count, t); bool discontinuous = transition->body(t) || (transition->get_target_regime() != B_.current_regime); B_.current_regime = transition->get_target_regime(); B_.current_regime->set_triggers(t); if (discontinuous) B_.current_regime->init_solver(); // Reset the solver if the transition contains state assignments or switches to a new regime. } /***** Send output events for each event send port *****/ // FIXME: Need to specify different output ports in a way that can be read by the receiving nodes // Output events if (B_.num_spike_events) { set_spiketime(nest::Time::step(origin.get_steps()+lag+1)); nest::SpikeEvent se; se.set_multiplicity(B_.num_spike_events); network()->send(*this, se, lag); } /***** Get analog port values *****/ B_.Isyn_value = B_.Isyn_analog_port.get_value(lag); /***** Record data *****/ B_.logger_.record_data(current_steps + lag); } }
void mynest::poisson_generator_periodic::update(nest::Time const & T, const long from, const long to) { assert(to >= 0 && (nest::delay) from < nest::kernel().connection_manager.get_min_delay()); assert(from < to); if (( P_.rate_first_ <= 0 ) && ( P_.rate_second_ <= 0 )) return; // Change rate periodically long period=(long) T.get_ms() % (long) V_.period_; if (period == (long) P_.period_first_) { V_.poisson_dev_.set_lambda(nest::Time::get_resolution().get_ms() *P_.rate_second_* 1e-3); } if (period == 0) { V_.poisson_dev_.set_lambda(nest::Time::get_resolution().get_ms() *P_.rate_first_* 1e-3); } // cout << (long) V_.period_ % (long) T.get_ms() << endl; for ( long lag = from ; lag < to ; ++lag ) { if ( !device_.is_active( T + nest::Time::step(lag) ) ) continue; // no spike at this lag nest::DSSpikeEvent se; nest::kernel().event_delivery_manager.send(*this, se, lag); } }
double IzhikevichBranch::subthreshold_regimeOnCondition0::time_occurred(nest::Time const& origin, const nest::long_t& lag) { return origin.get_ms() + lag * nest::Time::get_resolution().get_ms(); }