Skip to main content

Monte Carlo Service (Python)

This document describes the FastAPI application serving as a microservice for running Monte Carlo simulations for S&OP scenarios.

Overview

This FastAPI application provides an API to run Monte Carlo simulations. It's designed to be a flexible service that can be used by other services in the ChainAlign ecosystem to assess the probabilistic risk of S&OP plans.

Key Functionalities Exposed:

  • Receiving plan inputs, external context, and the number of iterations.
  • Running a Monte Carlo simulation using NumPy.
  • Returning the simulation results.

Technology Stack:

  • FastAPI: For creating the web server and API endpoints.
  • NumPy: The core library for numerical operations.

API Endpoints

POST /simulate

Runs a Monte Carlo simulation.

Request Body:

{
"planInputs": {},
"externalContext": {},
"iterations": 10000
}

Responses:

  • 200 OK: A JSON object with the simulation results.
  • 422 Unprocessable Entity: If the request body is invalid.
  • 500 Internal Server Error: If the simulation fails.