Table of Contents

Class Simulation

Namespace
DotFly
Assembly
DotFly.Engine.dll

A running network: one Brain, one backend, the input/output ports bound to neuron sets, the clock, the recorder and the causal switches. All members are meant to be called from one thread (the caller of Run(TimeSpan)/Advance(int), or the RealtimeDriver's thread) except Write(ReadOnlySpan<float>), Snapshot, the switches and the read-only properties, which are safe from any thread.

public sealed class Simulation : IDisposable, ISpikeSink
Inheritance
Simulation
Implements
Inherited Members

Properties

Backend

The backend (kernel-level access; prefer the engine API).

public ISpikingBackend Backend { get; }

Property Value

ISpikingBackend

Brain

The checkpoint.

public Brain Brain { get; }

Property Value

Brain

Clock

Neural / wall time bookkeeping.

public SimulationClock Clock { get; }

Property Value

SimulationClock

Constants

Per-step constants in use.

public LifStepConstants Constants { get; }

Property Value

LifStepConstants

DtMs

Timestep in ms.

public double DtMs { get; }

Property Value

double

ExternalInput

Causal switch: apply external inputs (Poisson, currents, injections) or ignore them all.

public bool ExternalInput { get; set; }

Property Value

bool

Inputs

Input ports created so far.

public IReadOnlyList<InputPort> Inputs { get; }

Property Value

IReadOnlyList<InputPort>

NeuralTime

Neural time elapsed.

public TimeSpan NeuralTime { get; }

Property Value

TimeSpan

Options

Options this simulation was created with.

public SimulationOptions Options { get; }

Property Value

SimulationOptions

Outputs

Output ports created so far.

public IReadOnlyList<OutputPort> Outputs { get; }

Property Value

IReadOnlyList<OutputPort>

RecurrentTransmission

Causal switch: deliver spikes to their targets (true) or cut all recurrent transmission (false).

public bool RecurrentTransmission { get; set; }

Property Value

bool

Seed

Current seed of the backend.

public ulong Seed { get; }

Property Value

ulong

Silenced

Neurons currently silenced (outgoing synapses zeroed; they still spike).

public IReadOnlyCollection<int> Silenced { get; }

Property Value

IReadOnlyCollection<int>

Step

Steps completed.

public long Step { get; }

Property Value

long

Methods

Advance(int)

Advances by steps steps.

public void Advance(int steps)

Parameters

steps int

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Inject(NeuronSet, TimeSpan)

Schedules an event on every neuron of set at at.

public void Inject(NeuronSet set, TimeSpan at)

Parameters

set NeuronSet
at TimeSpan

Inject(int, TimeSpan)

Schedules one input event of the model's Poisson weight on neuron at neural time at (≥ now).

public void Inject(int neuron, TimeSpan at)

Parameters

neuron int
at TimeSpan

Inject(int, TimeSpan, double)

Schedules a voltage injection of mv on neuron at neural time at (≥ now).

public void Inject(int neuron, TimeSpan at, double mv)

Parameters

neuron int
at TimeSpan
mv double

Input(NeuronSet, InputKind)

Creates an input port over set; values start at 0 (no input).

public InputPort Input(NeuronSet set, InputKind kind)

Parameters

set NeuronSet
kind InputKind

Returns

InputPort

Output(NeuronSet, OutputKind, TimeSpan?)

Creates an output port over set, published every publishEvery (default 20 ms).

public OutputPort Output(NeuronSet set, OutputKind kind, TimeSpan? publishEvery = null)

Parameters

set NeuronSet
kind OutputKind
publishEvery TimeSpan?

Returns

OutputPort

Record(string, RecordFlags)

Starts recording to a .dfs file; dispose the returned recorder (or this simulation) to finish it.

public Recorder Record(string path, RecordFlags what = RecordFlags.All)

Parameters

path string
what RecordFlags

Returns

Recorder

Reset()

Resets the network state and clock to step 0 (same seed ⇒ same run). Ports, silencing and switches are kept.

public void Reset()

Reset(ulong)

Resets the network state and clock to step 0 with a new seed (a fresh trial). Ports, silencing and switches are kept.

public void Reset(ulong seed)

Parameters

seed ulong

Restore(SimulationSnapshot)

Restores a snapshot taken from this simulation (or one with the same checkpoint and options). Scheduled actions and injections are dropped.

public void Restore(SimulationSnapshot snapshot)

Parameters

snapshot SimulationSnapshot

Run(TimeSpan)

Advances by neural of neural time (rounded to whole steps).

public void Run(TimeSpan neural)

Parameters

neural TimeSpan

ScheduleAt(long, Action<Simulation>)

Runs action on the simulation thread just before step step executes (≥ current step).

public void ScheduleAt(long step, Action<Simulation> action)

Parameters

step long
action Action<Simulation>

ScheduleAt(TimeSpan, Action<Simulation>)

Runs action just before the step at neural time at.

public void ScheduleAt(TimeSpan at, Action<Simulation> action)

Parameters

at TimeSpan
action Action<Simulation>

Silence(NeuronSet)

Zeroes the outgoing synapses of the set's neurons (Shiu-style silencing). They still integrate and spike.

public void Silence(NeuronSet set)

Parameters

set NeuronSet

Snapshot()

Captures the dynamic state for later Restore(SimulationSnapshot) (branching experiments, episode resets).

public SimulationSnapshot Snapshot()

Returns

SimulationSnapshot

StepOf(TimeSpan)

Step index of a neural time (rounded to the nearest step).

public long StepOf(TimeSpan neuralTime)

Parameters

neuralTime TimeSpan

Returns

long

Unsilence(NeuronSet)

Restores the outgoing synapses of the set's neurons.

public void Unsilence(NeuronSet set)

Parameters

set NeuronSet

Events

OnSpikes

Called on the simulation thread with each step's spikes.

public event SpikeHandler OnSpikes

Event Type

SpikeHandler