8. Simulation Manager (simman)

The Simulation Manager is the controller in the ChargEval. The purpose of the Simulation Manager is to watch for the inserts into the database table analysis_record. A record is inserted into this table whenever a user submits a charging station deployment scenario for analysis. The Simulation Manager receives the insert notification through the database trigger notify_new_order() with the payload including the analysis_id etc. and queues the analysis request for execution. The Simulation Manager process is shown in Fig. 8.1.

Simulation Manager Process Flowchart

Fig. 8.1 Simulation Manager Process Flowchart

Simulation Manager and the sub-processes (in R and GAMA) all read the input data from the database and write the output to it. analysis_id is passed between processes and all the relevant records from the database can be looked up using the analysis_id. Since the notification processing is handled asynchronously and; trip generation and agent-based simulation happen in their own dedicated instances, the simulation manager is always ready to receive new requests and queue them.

Note

If no limits are placed on the number of tripgen and eviabm instances, then theoretically infinite simulations requests can be handled in parallel, and the database then is the bottleneck.

8.1. Implementation Details

The Simulation Manager is written in NodeJS as it supports asynchronous processes. The code is hosted here. The NodeJS library Bull is used for implementing the queueing. Bull utilizes Redis as backend for storing the jobs in queue and their states. The queue can be monitored using an instance of Bull Board which tells us the status of the current queue, jobs being processed, waiting etc.