Skip to main content

Start Simulation

Initializes and starts a new discrete event simulation with the provided configuration.

Request Body

num_tellers
integer
default:3
Number of teller windows available to serve customers simultaneously.
arrival_config
object
Configuration for customer arrival patterns.
service_config
object
Configuration for customer service time patterns.
max_simulation_time
float
default:28800
Maximum simulation time in seconds. Default is 28800 (8 hours).
max_queue_capacity
integer
default:100
Maximum number of customers that can wait in queue simultaneously.

Response

status
string
Status of the response: success or error
data
object

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
string
Status of the response: success or error
data
object

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
string
Status of the response: success or error
data
object

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
string
Status of the response: success or error
data
object

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.

Build docs developers (and LLMs) love