Start Simulation
Initializes and starts a new discrete event simulation with the provided configuration.
Request Body
Number of teller windows available to serve customers simultaneously.
Configuration for customer arrival patterns.
Lambda parameter for arrival rate (customers per time unit).
arrival_dist
string
default:"exponential"
Probability distribution for arrival intervals. Options: exponential
Probability weights for priority levels [HIGH, MEDIUM, LOW]. Must sum to 1.0.
Configuration for customer service time patterns.
Mean service time in seconds (mu parameter).
service_dist
string
default:"exponential"
Probability distribution for service times. Options: exponential
Standard deviation for service time distribution (when applicable).
Maximum simulation time in seconds. Default is 28800 (8 hours).
Maximum number of customers that can wait in queue simultaneously.
Response
Status of the response: success or error
Unique identifier for the started simulation (UUID format).
Current simulation status: RUNNING
Example Request
curl -X POST http://localhost:5000/api/simulation/start \
-H "Content-Type: application/json" \
-d '{
"num_tellers": 3,
"arrival_config": {
"arrival_rate": 1.5,
"arrival_dist": "exponential",
"priority_weights": [0.15, 0.35, 0.5]
},
"service_config": {
"service_mean": 4.0,
"service_dist": "exponential",
"service_stddev": 1.0
},
"max_simulation_time": 14400,
"max_queue_capacity": 50
}'
Example Response
{
"status": "success",
"data": {
"simulation_id": "a3f2c1b5",
"status": "RUNNING",
"message": "Simulation started successfully"
}
}
Only one simulation can run at a time. Starting a new simulation will fail if another is already active.
Pause Simulation
Pauses the currently running simulation, preserving all state for later resumption.
Response
Status of the response: success or error
Identifier of the paused simulation.
Current simulation status: PAUSED
Simulation clock time when paused (in seconds).
Example Request
curl -X POST http://localhost:5000/api/simulation/pause
Example Response
{
"status": "success",
"data": {
"simulation_id": "a3f2c1b5",
"status": "PAUSED",
"current_time": 1250.45
}
}
This endpoint requires an active simulation. Calling it when no simulation is running will return an error.
Stop Simulation
Stops the currently running or paused simulation and finalizes all metrics.
Response
Status of the response: success or error
Identifier of the stopped simulation.
Final simulation status: FINISHED
Simulation clock time when stopped (in seconds).
Example Request
curl -X POST http://localhost:5000/api/simulation/stop
Example Response
{
"status": "success",
"data": {
"simulation_id": "a3f2c1b5",
"status": "FINISHED",
"final_time": 14400.0
}
}
Get Simulation State
Retrieves the current state snapshot of the simulation, including status, time, and active entities.
Response
Status of the response: success or error
Unique identifier of the simulation.
Current status: IDLE, RUNNING, PAUSED, or FINISHED
Current simulation time in seconds.
Array of Teller objects representing all teller windows. Number of customers currently waiting in queue.
Array of Customer objects currently in queue. Number of future events scheduled in the event queue.
Example Request
curl http://localhost:5000/api/simulation/state
Example Response
{
"status": "success",
"data": {
"simulation_id": "a3f2c1b5",
"status": "RUNNING",
"clock": 3247.82,
"config": {
"num_tellers": 3,
"arrival_config": {
"arrival_rate": 1.5,
"arrival_dist": "exponential",
"priority_weights": [0.15, 0.35, 0.5]
},
"service_config": {
"service_mean": 4.0,
"service_dist": "exponential",
"service_stddev": 1.0
},
"max_simulation_time": 14400,
"max_queue_capacity": 50
},
"tellers": [
{
"id": "T-1",
"status": "BUSY",
"current_customer": {
"id": "c7f3a1b2",
"priority": 2,
"transaction_type": "DEPOSIT"
},
"sessions_served": 45
},
{
"id": "T-2",
"status": "IDLE",
"current_customer": null,
"sessions_served": 42
},
{
"id": "T-3",
"status": "BUSY",
"current_customer": {
"id": "d8e4b3c1",
"priority": 1,
"transaction_type": "WITHDRAWAL"
},
"sessions_served": 48
}
],
"waiting_queue_length": 7,
"waiting_queue": [
{
"id": "e9f5c4d2",
"arrival_time": 3245.12,
"service_time": 3.8,
"priority": 1,
"transaction_type": "PAYMENT",
"status": "WAITING"
}
],
"event_queue_size": 15
}
}
The state endpoint provides a real-time snapshot. For high-frequency monitoring, consider implementing a polling mechanism with appropriate intervals.