Timeline

Definition of main Timeline class.

This module defines the Timeline class, which provides an interface for the simulation kernel and drives event execution. All entities are required to have an attached timeline for simulation.

class src.kernel.timeline.Timeline(stop_time=inf, formalism='ket_vector', truncation=1)

Class for a simulation timeline.

Timeline holds entities, which are configured before the simulation. Before the start of simulation, the timeline must initialize all controlled entities. The initialization of entities may schedule events. The timeline pushes these events to its event list. The timeline starts simulation by popping the top event in the event list repeatedly. The time of popped event becomes current simulation time of the timeline. The process of popped event is executed. The simulation stops if the timestamp on popped event is equal or larger than the stop time, or if the eventlist is empty.

To monitor the progress of simulation, the Timeline.show_progress attribute can be modified to show/hide a progress bar.

events

the event list of timeline.

Type:

EventList

entities

the entity list of timeline used for initialization.

Type:

List[Entity]

time

current simulation time (picoseconds).

Type:

int

stop_time

the stop (simulation) time of the simulation.

Type:

int

schedule_counter

the counter of scheduled events

Type:

int

run_counter

the counter of executed events

Type:

int

is_running

records if the simulation has stopped executing events.

Type:

bool

show_progress

show/hide the progress bar of simulation.

Type:

bool

quantum_manager

quantum state manager.

Type:

QuantumManager

init() None

Method to initialize all simulated entities.

now() int

Returns current simulation time.

progress_bar()

Method to draw progress bar.

Progress bar will display the execution time of simulation, as well as the current simulation time.

run() None

Main simulation method.

The run method begins simulation of events. Events are continuously popped and executed, until the simulation time limit is reached or events are exhausted. A progress bar may also be displayed, if the show_progress flag is set.

schedule(event: Event) None

Method to schedule an event.

seed(seed: int) None

Sets random seed for simulation.

stop() None

Method to stop simulation.

update_event_time(event: Event, time: int) None

Method to change execution time of an event.

Parameters:
  • event (Event) – event to reschedule.

  • time (int) – new simulation time (should be >= current time).