Simulator

class acnportal.acnsim.simulator.Simulator(network, scheduler, events, start, period=1, signals=None, store_schedule_history=False, verbose=True)

Central class of the acnsim package.

The Simulator class is the central place where everything about a particular simulation is stored including the network, scheduling algorithm, and events. It is also where timekeeping is done and orchestrates calling the scheduling algorithm, sending pilots to the network, and updating the energy delivered to each EV.

Parameters:
  • network (ChargingNetwork) – The charging network which the simulation will use.
  • scheduler (BaseAlgorithm) – The scheduling algorithm used in the simulation.
  • events (EventQueue) – Queue of events which will occur in the simulation.
  • start (datetime) – Date and time of the first period of the simulation.
  • period (int) – Length of each time interval in the simulation in minutes. Default: 1
  • signals (Dict[str, ..]) –
  • store_schedule_history (bool) – If True, store the scheduler output each time it is run. Note this can use lots of memory for long simulations.
charging_rates_as_df()

Return the charging rates as a pandas DataFrame, with EVSE id as columns and iteration as index.

Returns:
A DataFrame containing the charging rates
of the simulation. Columns are EVSE id, and the index is the iteration.
Return type:pandas.DataFrame
get_active_evs()

Return all EVs which are plugged in and not fully charged at the current time.

Wrapper for self.network.active_evs. See its documentation for more details.

Returns:List of all EVs which are plugged in but not fully charged at the current time.
Return type:List[EV]
index_of_evse(station_id)

Return the numerical index of the EVSE given by station_id in the (ordered) dictionary of EVSEs.

pilot_signals_as_df()

Return the pilot signals as a pandas DataFrame

Returns:
A DataFrame containing the pilot signals
of the simulation. Columns are EVSE id, and the index is the iteration.
Return type:pandas.DataFrame
run()

Run the simulation until the event queue is empty.

The run function is the heart of the simulator. It triggers all actions and keeps the simulator moving forward. Its actions are (in order):

  1. Get current events from the event queue and execute them.
  2. If necessary run the scheduling algorithm.
  3. Send pilot signals to the network.
  4. Receive back actual charging rates from the network and store the results.
Returns:None
update_scheduler(new_scheduler)

Updates a Simulator’s schedule.

exception acnportal.acnsim.simulator.InvalidScheduleError

Raised when the schedule passed to the simulator is invalid.