{ "cells": [ { "cell_type": "markdown", "id": "82599211", "metadata": {}, "source": [ "# What-If Scenario Tweaks\n", "\n", "Demonstrate simple parameter tweaks (e.g., downtime probability) and compare KPI impacts." ] }, { "cell_type": "code", "execution_count": 1, "id": "1c3ff8d9", "metadata": { "execution": { "iopub.execute_input": "2026-10-05T12:56:59.365991Z", "iopub.status.busy": "2026-10-05T12:56:59.365870Z", "iopub.status.idle": "2026-10-05T12:57:02.475754Z", "shell.execute_reply": "2026-10-05T12:57:02.474901Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Base downtime probability: 0.12\n" ] } ], "source": [ "import sys\n", "from pathlib import Path\n", "\n", "PROJECT_ROOT = Path.cwd().resolve()\n", "while PROJECT_ROOT != PROJECT_ROOT.parent and not (PROJECT_ROOT / \"pyproject.toml\").exists():\n", " PROJECT_ROOT = PROJECT_ROOT.parent\n", "if not (PROJECT_ROOT / \"pyproject.toml\").exists():\n", " raise RuntimeError(\n", " \"Notebook must be executed within a FHOPS checkout (pyproject.toml not found).\"\n", " )\n", "if str(PROJECT_ROOT) not in sys.path:\n", " sys.path.insert(0, str(PROJECT_ROOT))\n", "\n", "from docs.examples.analytics import utils\n", "\n", "SCENARIO = PROJECT_ROOT / \"examples/synthetic/medium/scenario.yaml\"\n", "ASSIGNMENTS = PROJECT_ROOT / \"docs/examples/analytics/data/scaling_medium_sa_assignments.csv\"\n", "\n", "base_tables, base_sampling = utils.run_stochastic_summary(SCENARIO, ASSIGNMENTS, tier=\"medium\")\n", "print(\"Base downtime probability:\", base_sampling.downtime.probability)" ] }, { "cell_type": "markdown", "id": "9be49fbf", "metadata": {}, "source": [ "### Adjusted Sampling\n", "\n", "Increase downtime probability and observe KPI deltas." ] }, { "cell_type": "code", "execution_count": 2, "id": "81ca832b", "metadata": { "execution": { "iopub.execute_input": "2026-10-05T12:57:02.477432Z", "iopub.status.busy": "2026-10-05T12:57:02.477272Z", "iopub.status.idle": "2026-10-05T12:57:02.663684Z", "shell.execute_reply": "2026-10-05T12:57:02.662668Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Base mean production: 29.42\n", "Adjusted mean production: 29.42\n" ] } ], "source": [ "custom_sampling = base_sampling.model_copy()\n", "custom_sampling.downtime.probability = 0.3\n", "custom_tables, _ = utils.run_stochastic_summary(\n", " SCENARIO, ASSIGNMENTS, sampling_config=custom_sampling\n", ")\n", "\n", "base_prod = base_tables.shift.groupby(\"sample_id\")[\"production_units\"].sum().mean()\n", "custom_prod = custom_tables.shift.groupby(\"sample_id\")[\"production_units\"].sum().mean()\n", "print(f\"Base mean production: {base_prod:.2f}\")\n", "print(f\"Adjusted mean production: {custom_prod:.2f}\")" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.16" } }, "nbformat": 4, "nbformat_minor": 5 }