{ "cells": [ { "cell_type": "markdown", "id": "31dfbc3e", "metadata": {}, "source": [ "# Stochastic Robustness Explorer\n", "\n", "Analyse stochastic playback ensembles for the synthetic medium bundle using preset sampling configurations." ] }, { "cell_type": "code", "execution_count": 1, "id": "8a93a5a4", "metadata": { "execution": { "iopub.execute_input": "2026-10-05T12:56:54.209515Z", "iopub.status.busy": "2026-10-05T12:56:54.209379Z", "iopub.status.idle": "2026-10-05T12:56:57.142656Z", "shell.execute_reply": "2026-10-05T12:56:57.141884Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Samples: 12\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dayshift_idmachine_idmachine_rolesample_idproduction_unitstotal_hoursidle_hoursmobilisation_costsequencing_violationsblackout_conflictsavailable_hoursutilisation_ratiodowntime_hoursdowntime_eventsweather_severity_total
01S1M2forwarder014.5898.00.00.0008.01.00.000.1
12S1M2forwarder06.4848.00.00.0008.01.00.000.6
28S1M1harvester015.0348.00.00.0008.01.00.000.0
31S1M1harvester19.2518.00.00.0000.0NaN0.000.0
42S1M2forwarder116.2108.00.00.0008.01.00.000.0
\n", "
" ], "text/plain": [ " day shift_id machine_id machine_role sample_id production_units \\\n", "0 1 S1 M2 forwarder 0 14.589 \n", "1 2 S1 M2 forwarder 0 6.484 \n", "2 8 S1 M1 harvester 0 15.034 \n", "3 1 S1 M1 harvester 1 9.251 \n", "4 2 S1 M2 forwarder 1 16.210 \n", "\n", " total_hours idle_hours mobilisation_cost sequencing_violations \\\n", "0 8.0 0.0 0.0 0 \n", "1 8.0 0.0 0.0 0 \n", "2 8.0 0.0 0.0 0 \n", "3 8.0 0.0 0.0 0 \n", "4 8.0 0.0 0.0 0 \n", "\n", " blackout_conflicts available_hours utilisation_ratio downtime_hours \\\n", "0 0 8.0 1.0 0.0 \n", "1 0 8.0 1.0 0.0 \n", "2 0 8.0 1.0 0.0 \n", "3 0 0.0 NaN 0.0 \n", "4 0 8.0 1.0 0.0 \n", "\n", " downtime_events weather_severity_total \n", "0 0 0.1 \n", "1 0 0.6 \n", "2 0 0.0 \n", "3 0 0.0 \n", "4 0 0.0 " ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "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 = (\n", " PROJECT_ROOT / \"docs/examples/analytics/data/scaling_medium_sa_assignments.csv\"\n", ") # update with fresh assignments if desired\n", "\n", "(tables, sampling_config) = utils.run_stochastic_summary(SCENARIO, ASSIGNMENTS, tier=\"medium\")\n", "print(f\"Samples: {sampling_config.samples}\")\n", "tables.shift.head()" ] }, { "cell_type": "markdown", "id": "bde45154", "metadata": {}, "source": [ "### Production Distribution\n", "\n", "Inspect the distribution of production across ensemble samples." ] }, { "cell_type": "code", "execution_count": 2, "id": "137462ef", "metadata": { "execution": { "iopub.execute_input": "2026-10-05T12:56:57.144399Z", "iopub.status.busy": "2026-10-05T12:56:57.144209Z", "iopub.status.idle": "2026-10-05T12:56:57.161225Z", "shell.execute_reply": "2026-10-05T12:56:57.160415Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "utils.plot_distribution(\n", " tables.shift.groupby(\"sample_id\")[\"production_units\"].sum(),\n", " title=\"Production Distribution\",\n", " xlabel=\"Production Units\",\n", ")" ] } ], "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 }