Event-Driven Simulation¶
Event-driven simulation: only update neurons with pending events.
EventDrivenSimulator— Priority queue of spike events. Only neurons with pending input are processed. O(K log N) per spike where K is fan-out. 10,000x speedup vs clock-driven for sparse networks.
Supports: external spike injection, STDP plasticity (trace-based), stats collection (total events, queue peak size).
from sc_neurocore.event_driven import EventDrivenSimulator
sim = EventDrivenSimulator(network)
sim.inject_spikes([(0.0, neuron_id, current)])
sim.run(duration=100.0)
print(f"Events processed: {sim.stats.total_events}")
See Tutorial 65: Event-Driven Simulation.
sc_neurocore.event_driven
¶
Event-driven simulation: only update neurons with pending events. 10,000x speedup for sparse networks vs clock-driven simulation.
EventDrivenSimulator
¶
Event-driven asynchronous SNN simulator.
Parameters¶
n_neurons : int Total neurons. connectivity : list of (source, target, weight, delay) Synaptic connections. threshold : float Spike threshold for LIF neurons. tau_mem : float Membrane time constant (ms). v_rest : float Resting potential. v_reset : float Reset potential after spike. refractory : float Refractory period (ms).
Source code in src/sc_neurocore/event_driven/simulator.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
inject_spikes(events)
¶
Inject external spike events.
Parameters¶
events : list of (time, neuron_id)
Source code in src/sc_neurocore/event_driven/simulator.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
inject_current(events)
¶
Inject current pulses.
Parameters¶
events : list of (time, neuron_id, current)
Source code in src/sc_neurocore/event_driven/simulator.py
124 125 126 127 128 129 130 131 132 133 134 135 | |
run(duration)
¶
Run event-driven simulation.
Parameters¶
duration : float Simulation duration (ms).
Returns¶
(spike_log, stats) spike_log: list of (time, neuron_id) stats: EventStats
Source code in src/sc_neurocore/event_driven/simulator.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
reset()
¶
Reset all state.
Source code in src/sc_neurocore/event_driven/simulator.py
203 204 205 206 207 208 | |
SpikeEvent
dataclass
¶
One spike event in the priority queue.
Source code in src/sc_neurocore/event_driven/simulator.py
29 30 31 32 33 34 35 36 37 | |
EventStats
dataclass
¶
Statistics from an event-driven simulation run.
Source code in src/sc_neurocore/event_driven/simulator.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |