From c5f9dbefe5c96f66a4c5a35f8d9f803970860601 Mon Sep 17 00:00:00 2001 From: "Erick C. Jones Jr." <44578073+yamierick@users.noreply.github.com> Date: Tue, 27 Oct 2026 09:04:35 -0500 Subject: [PATCH] 02: the simplex tableau by hand, and a barrier method through the middle Folder 02 has been empty since the library was built, while both IE 3315 and IE 5301 spend two lectures on bases and the simplex method (decks 04 and 05) and IE 5301 adds interior point (deck 03, barrierShort.ipynb). simplex_by_hand.ipynb uses the course's own tableau example (deck 05): max 40x1 + 50x2, x1 + 2x2 <= 40, 4x1 + 3x2 <= 120. It enumerates all six bases (four feasible corners), then pivots the tableau by hand, each pivot written out as three row operations: (0, 0) -> (0, 20) -> (24, 8), z 1360, exactly the slides' path. Row 0's final entries under the slacks (16 and 6) equal Gurobi's duals; the notebook asks the reader to notice rather than saying so. No ties anywhere in the tableau, so the path is the problem's and is compared corner by corner. interior_point.ipynb replaces barrierShort.ipynb, which ran on a random instance redrawn every run, so none of its numbers could be quoted. Same LP: one equality-constrained Newton step written out (gradient, Hessian, KKT system, decrement), the backtracking line search, centering, then the central path as t grows from T0 = 0.001 by MU = 2. 32 centerings, 65 Newton steps; the path starts near the middle at (10.3, 7.3) and curves in to (24, 8). A figure draws it against the simplex's corners (line style and marker, plus a Figure line). Gurobi's barrier with crossover off is the cross-check. orteach.simplex: standard_form (refuses anything but max with <= rows and b >= 0, the case the tableau starts from), basic_solutions, tableau_path (Dantzig's rule, lowest index on ties), barrier_path. The agreement assertions compare all six bases and the path (40 comparisons), and every barrier iterate (132), to AGREEMENT_RTOL; the barrier's end against the simplex, and Gurobi's, to CROSS_METHOD_RTOL (6.8e-10 and 4.7e-12). The slides' exercise, Wyndor, ships as lp_wyndor.csv and its path is tested. Gate: 214 passed; 22 notebooks and 16 seeds clean; ruff clean. Co-Authored-By: Claude Opus 5.5 --- CITATION.cff | 2 +- CLAUDE.md | 2 +- README.md | 5 +- data/raw/lp_simplex_40_50.csv | 4 + data/raw/lp_wyndor.csv | 5 + notebooks/02_simplex_and_bases/README.md | 17 + .../02_simplex_and_bases/interior_point.ipynb | 627 ++++++++++++++++ .../simplex_by_hand.ipynb | 669 ++++++++++++++++++ src/orteach/simplex.py | 145 ++++ tests/test_simplex.py | 80 +++ tools/seeds/seed_barrier.py | 317 +++++++++ tools/seeds/seed_simplex.py | 320 +++++++++ 12 files changed, 2189 insertions(+), 4 deletions(-) create mode 100644 data/raw/lp_simplex_40_50.csv create mode 100644 data/raw/lp_wyndor.csv create mode 100644 notebooks/02_simplex_and_bases/README.md create mode 100644 notebooks/02_simplex_and_bases/interior_point.ipynb create mode 100644 notebooks/02_simplex_and_bases/simplex_by_hand.ipynb create mode 100644 src/orteach/simplex.py create mode 100644 tests/test_simplex.py create mode 100644 tools/seeds/seed_barrier.py create mode 100644 tools/seeds/seed_simplex.py diff --git a/CITATION.cff b/CITATION.cff index d1bda7d..23ea44e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: "If you use this teaching material, or the models in it, please cite it as below." title: "Teaching notebooks for IE 3315, IE 5301 and REE 4301" abstract: >- - Twenty executed teaching notebooks and an accompanying Python package, + Twenty-two executed teaching notebooks and an accompanying Python package, organised by subject across three courses in industrial engineering and energy systems modelling. Each notebook builds its model by hand and then asserts agreement with the packaged implementation, so the two cannot drift apart diff --git a/CLAUDE.md b/CLAUDE.md index c291c30..a3cd5bf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -136,7 +136,7 @@ They belong with the repository. Moved twice so far: to `C:\dev\` on 2026-09-05, ## Status, measured 2026-09-05 -Twenty notebooks (seventeen as of 2026-09-05) across twelve subjects (`02` empty on purpose), sixteen package modules, thirty- +Twenty-two notebooks (seventeen as of 2026-09-05) across thirteen subjects (`02` added 2026-10-27), sixteen package modules, thirty- odd tables in `data/raw/`, 170 tests, and `tools/check_notebooks.py`. README.md has the table. **What to run before believing anything:** `python -m pytest tests/ -q`, diff --git a/README.md b/README.md index 9d339ee..d251e5f 100644 --- a/README.md +++ b/README.md @@ -125,13 +125,14 @@ ahead of LP formulation, which is backwards. ## What is here, measured 2026-09-05 -Twenty teaching notebooks in twelve subjects, each with its package module, its tables and its -tests. `02_simplex_and_bases` is empty on purpose. Every notebook ships executed, ends in the +Twenty-two teaching notebooks in thirteen subjects, each with its package module, its tables and +its tests. Every notebook ships executed, ends in the agreement assertion, and passes `tools/check_notebooks.py`. | folder | notebooks | package | |---|---|---| | 01 | `diet`, `goal_programming` | `diet`, `goal_programming` | +| 02 | `simplex_by_hand`, `interior_point` | `simplex` | | 03 | `primal_and_dual` | `duality` | | 04 | `transportation`, `assignment` | `transportation`, `assignment` | | 05 | `facility_location` | `facility_location` | diff --git a/data/raw/lp_simplex_40_50.csv b/data/raw/lp_simplex_40_50.csv new file mode 100644 index 0000000..ca5f47c --- /dev/null +++ b/data/raw/lp_simplex_40_50.csv @@ -0,0 +1,4 @@ +row,x1,x2,sense,rhs +objective,40,50,max, +c1,1,2,<=,40 +c2,4,3,<=,120 diff --git a/data/raw/lp_wyndor.csv b/data/raw/lp_wyndor.csv new file mode 100644 index 0000000..a3a7aa2 --- /dev/null +++ b/data/raw/lp_wyndor.csv @@ -0,0 +1,5 @@ +row,x1,x2,sense,rhs +objective,3,5,max, +plant1,1,0,<=,4 +plant2,0,2,<=,12 +plant3,3,2,<=,18 diff --git a/notebooks/02_simplex_and_bases/README.md b/notebooks/02_simplex_and_bases/README.md new file mode 100644 index 0000000..e117671 --- /dev/null +++ b/notebooks/02_simplex_and_bases/README.md @@ -0,0 +1,17 @@ +# 02 — Simplex and bases + +Both notebooks solve IE 3315's tableau example (deck 05): maximise 40x1 + 50x2 subject to +x1 + 2x2 <= 40 and 4x1 + 3x2 <= 120, table `lp_simplex_40_50.csv`. Package: `orteach.simplex`. + +`simplex_by_hand.ipynb` — every basis (six, four of them feasible corners), then the tableau +pivoted by hand from (0, 0) through (0, 20) to (24, 8), as the slides do it. Row 0's final +entries under the slacks are the duals, which the notebook asks the reader to notice. + +`interior_point.ipynb` — a log-barrier method on the same LP: one equality-constrained Newton step +written out, the line search, centering, then the central path as t grows. It replaces +`barrierShort.ipynb` (IE 5301 folder), which ran on a random instance redrawn every run, so no +number in it could be quoted; here the instance is fixed and the path can be drawn against the +simplex's corners. + +The slides' exercise, Wyndor (max 3x1 + 5x2, three plants), is `lp_wyndor.csv`; the tests pin its +simplex path, (0, 0) to (0, 6) to (2, 6). diff --git a/notebooks/02_simplex_and_bases/interior_point.ipynb b/notebooks/02_simplex_and_bases/interior_point.ipynb new file mode 100644 index 0000000..8221483 --- /dev/null +++ b/notebooks/02_simplex_and_bases/interior_point.ipynb @@ -0,0 +1,627 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d7429c1f", + "metadata": {}, + "source": [ + "# Through the middle: a barrier method for the same LP\n", + "\n", + "`simplex_by_hand.ipynb` walked the edges of the feasible region from corner to corner. A barrier\n", + "(interior-point) method never touches an edge until the very end. It replaces the hard constraints\n", + "$x \\ge 0$ with a penalty that grows without limit near them, solves that smooth problem, then\n", + "weakens the penalty a little and solves again. The solutions trace a curve through the interior,\n", + "the **central path**, that ends at the optimal corner.\n", + "\n", + "Same LP: maximise $40x_1 + 50x_2$ with $x_1 + 2x_2 \\le 40$ and $4x_1 + 3x_2 \\le 120$." + ] + }, + { + "cell_type": "markdown", + "id": "c814f04a", + "metadata": {}, + "source": [ + "## Setup: where the package lives\n", + "\n", + "This notebook builds the method by hand and then checks it against `orteach`, the package in\n", + "`src/`. Run from a clone of the repository, `../../src` is right there. On Colab there is no clone\n", + "until this cell makes one, and no `gurobipy` until it installs it. Nothing here needs a secret." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d7d60f9", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:21.741592Z", + "iopub.status.busy": "2026-10-27T14:03:21.741418Z", + "iopub.status.idle": "2026-10-27T14:03:21.753558Z", + "shell.execute_reply": "2026-10-27T14:03:21.753057Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "package: src\\orteach\n" + ] + } + ], + "source": [ + "import os, subprocess, sys\n", + "\n", + "REPO_URL = \"https://github.com/sear-labs/teaching-code\"\n", + "REF = \"v1.0.0\" # the release this notebook ships in: Colab clones THIS\n", + "\n", + "try:\n", + " import google.colab # noqa: F401 - succeeds only on Colab\n", + " ON_COLAB = True\n", + "except ImportError:\n", + " ON_COLAB = False\n", + "\n", + "if ON_COLAB:\n", + " if not os.path.isdir(\"/content/teaching-code\"):\n", + " subprocess.run([\"git\", \"clone\", \"--quiet\", \"--depth\", \"1\", \"--branch\", REF, REPO_URL, \"/content/teaching-code\"], check=True)\n", + " os.chdir(\"/content/teaching-code/notebooks/02_simplex_and_bases\")\n", + " subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", \"gurobipy>=11,<14\"], check=True)\n", + "\n", + "sys.path.insert(0, os.path.abspath(os.path.join(\"..\", \"..\", \"src\")))\n", + "try:\n", + " import orteach # noqa: F401\n", + "except ImportError:\n", + " raise SystemExit(\"orteach not found: run this notebook from its own folder inside the repository, \"\n", + " \"so that ../../src exists.\")\n", + "root = os.path.abspath(os.path.join(\"..\", \"..\"))\n", + "print(\"package:\", os.path.relpath(os.path.dirname(orteach.__file__), root))" + ] + }, + { + "cell_type": "markdown", + "id": "9b46c6ee", + "metadata": {}, + "source": [ + "## Licence setup\n", + "\n", + "Only the cross-check at the end uses a solver. Nothing here needs a key: `pip install gurobipy`\n", + "ships a size-limited licence and this model is tiny. The environment starts silent, so no licence\n", + "number lands in an output cell." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "d757547c", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:21.755860Z", + "iopub.status.busy": "2026-10-27T14:03:21.755680Z", + "iopub.status.idle": "2026-10-27T14:03:21.807315Z", + "shell.execute_reply": "2026-10-27T14:03:21.806790Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "licence: local gurobi.lic\n" + ] + } + ], + "source": [ + "import gurobipy as gp\n", + "from gurobipy import GRB\n", + "\n", + "env = gp.Env(empty=True)\n", + "env.setParam(\"OutputFlag\", 0) # start silent: the licence banner, and its licence number, stay out of the outputs\n", + "try:\n", + " from google.colab import userdata\n", + " try:\n", + " env.setParam(\"WLSACCESSID\", userdata.get(\"GRB_WLSACCESSID\"))\n", + " env.setParam(\"WLSSECRET\", userdata.get(\"GRB_WLSSECRET\"))\n", + " env.setParam(\"LICENSEID\", int(userdata.get(\"GRB_LICENSEID\")))\n", + " licence = \"Colab Secrets (WLS)\"\n", + " except (userdata.SecretNotFoundError, userdata.NotebookAccessError):\n", + " licence = \"the size-limited licence pip ships\" # no key needed; see the note above\n", + "except ImportError:\n", + " licence = \"local gurobi.lic\"\n", + "env.start()\n", + "print(\"licence:\", licence)" + ] + }, + { + "cell_type": "markdown", + "id": "79440eeb", + "metadata": {}, + "source": [ + "## Standard form, and a point strictly inside\n", + "\n", + "The same four columns as the tableau notebook: $x_1, x_2$ and one slack per row, with $Ax = b$.\n", + "A barrier method has to start strictly inside, every variable positive. Take $x_1 = x_2 = 1$; the\n", + "slacks follow from the equations." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "1249df88", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:21.809434Z", + "iopub.status.busy": "2026-10-27T14:03:21.809219Z", + "iopub.status.idle": "2026-10-27T14:03:22.027460Z", + "shell.execute_reply": "2026-10-27T14:03:22.026969Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "start {'x1': 1.0, 'x2': 1.0, 's1': 37.0, 's2': 113.0} all positive: True A x - b = [0. 0.]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "from orteach import tolerance\n", + "from orteach.duality import load_lp\n", + "\n", + "lp = load_lp(\"lp_simplex_40_50.csv\")\n", + "names = [\"x1\", \"x2\", \"s1\", \"s2\"]\n", + "A = np.array([[lp.A[\"c1\", \"x1\"], lp.A[\"c1\", \"x2\"], 1.0, 0.0],\n", + " [lp.A[\"c2\", \"x1\"], lp.A[\"c2\", \"x2\"], 0.0, 1.0]])\n", + "b = np.array([lp.b[\"c1\"], lp.b[\"c2\"]])\n", + "c = np.array([lp.c[\"x1\"], lp.c[\"x2\"], 0.0, 0.0])\n", + "\n", + "X0 = {\"x1\": 1.0, \"x2\": 1.0}\n", + "x = np.array([X0[\"x1\"], X0[\"x2\"], b[0] - A[0, :2] @ [1.0, 1.0], b[1] - A[1, :2] @ [1.0, 1.0]])\n", + "print(\"start\", dict(zip(names, x.tolist())), \" all positive:\", bool((x > 0).all()), \" A x - b =\", A @ x - b)" + ] + }, + { + "cell_type": "markdown", + "id": "cb0ee94d", + "metadata": {}, + "source": [ + "## The barrier problem\n", + "\n", + "Maximising $c^\\top x$ is minimising $-c^\\top x$. Add $-\\sum_i \\log x_i$, which is small in the\n", + "middle and rises without bound as any $x_i$ approaches zero, and weigh the original objective by a\n", + "number $t$:\n", + "\n", + "$$\\min_x\\; f_t(x) = -t\\,c^\\top x - \\sum_i \\log x_i \\quad\\text{subject to}\\quad Ax = b.$$\n", + "\n", + "Small $t$: the log term dominates and the minimiser sits deep inside. Large $t$: the objective\n", + "dominates and the minimiser approaches the optimal corner. `T0` is where the path starts and `MU`\n", + "how much $t$ grows each time; both are knobs." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "1a82b8f3", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.029561Z", + "iopub.status.busy": "2026-10-27T14:03:22.029361Z", + "iopub.status.idle": "2026-10-27T14:03:22.032951Z", + "shell.execute_reply": "2026-10-27T14:03:22.032486Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t = 0.001 f_t(start) = -8.4283\n" + ] + } + ], + "source": [ + "T0 = 0.001\n", + "MU = 2.0\n", + "t = T0\n", + "\n", + "f_now = -t * c @ x - np.log(x).sum()\n", + "print(f\"t = {t} f_t(start) = {f_now:.4f}\")" + ] + }, + { + "cell_type": "markdown", + "id": "38da2f58", + "metadata": {}, + "source": [ + "## One Newton step\n", + "\n", + "Newton's method for a smooth problem with equality constraints: build the gradient $g$ and the\n", + "Hessian $H$ of $f_t$, then solve one linear system for a step $\\Delta x$ that keeps $A\\Delta x = 0$\n", + "(so the equations stay satisfied):\n", + "\n", + "$$\\begin{bmatrix} H & A^\\top \\\\ A & 0 \\end{bmatrix}\\begin{bmatrix}\\Delta x\\\\ w\\end{bmatrix} =\n", + "\\begin{bmatrix} -g \\\\ 0\\end{bmatrix}, \\qquad g = -t\\,c - 1/x, \\qquad H = \\mathrm{diag}(1/x^2).$$\n", + "\n", + "The Newton decrement $\\lambda^2 = \\Delta x^\\top H \\Delta x$ says how far from the minimiser this\n", + "point is; half of it estimates how much $f_t$ can still fall. Predict before running: at the\n", + "start, far from the centre, will the decrement be large or small, and what should $A\\Delta x$ be?" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b627b138", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.034996Z", + "iopub.status.busy": "2026-10-27T14:03:22.034825Z", + "iopub.status.idle": "2026-10-27T14:03:22.040676Z", + "shell.execute_reply": "2026-10-27T14:03:22.040195Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "step [ 0.9733 0.9636 -2.9005 -6.784 ] A @ step = [0. 0.] decrement^2 / 2 = 0.9428\n" + ] + } + ], + "source": [ + "g = -t * c - 1.0 / x\n", + "H = np.diag(1.0 / x ** 2)\n", + "K = np.block([[H, A.T], [A, np.zeros((2, 2))]])\n", + "dx = np.linalg.solve(K, np.concatenate([-g, np.zeros(2)]))[:4]\n", + "lam2 = float(dx @ H @ dx)\n", + "print(\"step\", dx.round(4), \" A @ step =\", (A @ dx).round(12), \" decrement^2 / 2 =\", round(lam2 / 2, 4))" + ] + }, + { + "cell_type": "markdown", + "id": "3835b2e8", + "metadata": {}, + "source": [ + "A full Newton step can overshoot past zero, where the logarithm does not exist. So halve the step\n", + "until the new point is strictly inside and $f_t$ has dropped by at least a quarter of what the\n", + "decrement predicts; that fraction, `ARMIJO`, is a knob of the line search. Predict before running:\n", + "will the first, full step survive?" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "3835d937", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.042663Z", + "iopub.status.busy": "2026-10-27T14:03:22.042494Z", + "iopub.status.idle": "2026-10-27T14:03:22.046349Z", + "shell.execute_reply": "2026-10-27T14:03:22.045886Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ARMIJO 0.25: step length accepted 1.0\n" + ] + } + ], + "source": [ + "ARMIJO = 0.25\n", + "step = 1.0\n", + "f_x = -t * c @ x - np.log(x).sum()\n", + "while (x + step * dx <= 0).any() or (-t * c @ (x + step * dx) - np.log(x + step * dx).sum()) > f_x - ARMIJO * step * lam2:\n", + " step *= 0.5\n", + "print(f\"ARMIJO {ARMIJO}: step length accepted {step}\")" + ] + }, + { + "cell_type": "markdown", + "id": "970e2d94", + "metadata": {}, + "source": [ + "## Centering, then the path\n", + "\n", + "Repeat that step until the decrement is negligible: that point is on the central path for this $t$.\n", + "Then multiply $t$ by `MU` and center again. The duality gap of a central point is at most (number of\n", + "variables) / $t$, so stop once that bound is below `CROSS_METHOD_RTOL`. The two loops repeat the same\n", + "lines; nothing is decided inside them that was not decided above." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "2e8f2882", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.048332Z", + "iopub.status.busy": "2026-10-27T14:03:22.048162Z", + "iopub.status.idle": "2026-10-27T14:03:22.060723Z", + "shell.execute_reply": "2026-10-27T14:03:22.060254Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "32 centerings, 65 Newton steps, final t = 2.15e+06\n", + "first centered point {'x1': 10.299, 'x2': 7.347, 's1': 15.008, 's2': 56.765}\n", + "last point {'x1': 24.0, 'x2': 8.0, 's1': 0.0, 's2': 0.0} objective 1359.999999\n" + ] + } + ], + "source": [ + "hand_path = [x.copy()]\n", + "newton_steps = 0\n", + "while len(x) / t > tolerance.CROSS_METHOD_RTOL:\n", + " for _ in range(50):\n", + " g = -t * c - 1.0 / x\n", + " H = np.diag(1.0 / x ** 2)\n", + " K = np.block([[H, A.T], [A, np.zeros((2, 2))]])\n", + " dx = np.linalg.solve(K, np.concatenate([-g, np.zeros(2)]))[:4]\n", + " lam2 = float(dx @ H @ dx)\n", + " if lam2 / 2 < tolerance.LINALG_ATOL:\n", + " break\n", + " step = 1.0\n", + " f_x = -t * c @ x - np.log(x).sum()\n", + " while (x + step * dx <= 0).any() or (-t * c @ (x + step * dx) - np.log(x + step * dx).sum()) > f_x - ARMIJO * step * lam2:\n", + " step *= 0.5\n", + " x = x + step * dx\n", + " newton_steps += 1\n", + " hand_path.append(x.copy())\n", + " t *= MU\n", + "\n", + "final = hand_path[-1]\n", + "print(f\"{len(hand_path) - 1} centerings, {newton_steps} Newton steps, final t = {t / MU:.3g}\")\n", + "print(\"first centered point\", dict(zip(names, hand_path[1].round(3).tolist())))\n", + "print(\"last point \", dict(zip(names, final.round(6).tolist())), f\" objective {c @ final:.6f}\")" + ] + }, + { + "cell_type": "markdown", + "id": "bfa72be9", + "metadata": {}, + "source": [ + "## The picture\n", + "\n", + "The feasible region, the simplex's corners, and the barrier's iterates. Predict the shape of the\n", + "path before you look: straight at the optimum, or curving?" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "09c0b140", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.062734Z", + "iopub.status.busy": "2026-10-27T14:03:22.062561Z", + "iopub.status.idle": "2026-10-27T14:03:22.877412Z", + "shell.execute_reply": "2026-10-27T14:03:22.876846Z" + } + }, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiEAAAGCCAYAAAA2dxNaAAAAOnRF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Q1V6tWrp9jY2ChGRkZKrly5lG7duim+vr5qx052CR0TQFm1apVumfR6znzu2KTX86ZHjx667x8bGxulTp06ugJEUdQ9XzSKoijJf71FCCGEECI+aRMihBBCCFVIESKEEEIIVUgRIoQQQghVSBEihBBCCFVIESKEEEIIVUgRIoQQQghVSBEihBBCCFVIESKEEEIIVUgRIoQQQghVSBEihEiV/Pz86NixI4ULF0ar1eLq6qp2JCFEIkkRIoRIlSIiIrCxsWH06NE4OjqqHUcI8RWkCBFC6KXnz59jZ2fHzz//rJv3zz//YGxszIEDB8iTJw/z58+na9euWFtbq5hUCPG1DNUOIIQQCbGxsWHlypW0aNGCevXqUaRIETp37ky/fv2oV6+e2vGEEElAihAhhN5q1KgRvXv3plOnTpQrVw5TU1OmTZumdiwhRBKR2zFCCL02a9YsoqOj+f3339mwYQOmpqZqRxJCJBEpQoQQeu3evXs8efKE2NhYHjx4oHYcIUQSktsxQgi9FRkZSadOnWjXrh1FihShZ8+eXLlyhWzZsqkdTQiRBKQIEULordGjRxMQEICnpycWFhbs27ePnj178ueffwLg7e0NQHBwMM+fP8fb2xtjY2OKFSumYmohxJfSKIqiqB1CCCHe5+XlxXfffceRI0eoWrUqAL6+vpQqVQoPDw9++uknNBrNB+vlzp2b+/fvp3BaIcTXkCJECCGEEKqQhqlCCCGEUIUUIUIIIYRQhRQhQgghhFCFFCFCCCGEUIUUIUIIIYRQhRQhQgghhFCFFCFCCCGEUIUUIUIIIYRQhRQhQgghhFCFFCFCCCGEUIUUIUIIIYRQxf8BNEdiYpSuEZ4AAAAASUVORK5CYII=", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Figure: inside the four-sided region, the simplex goes from (0, 0) up to (0, 20) and across to (24, 8); the barrier starts at (1, 1), jumps to (10.3, 7.3) near the middle, and curves in to (24, 8) without touching an edge until the end.\n" + ] + } + ], + "source": [ + "import matplotlib.pyplot as plt\n", + "\n", + "region = np.array([[0, 0], [0, 20], [24, 8], [30, 0], [0, 0]]) # the four feasible corners\n", + "path_xy = np.array([[p[0], p[1]] for p in hand_path])\n", + "plt.figure(figsize=(6, 4.2))\n", + "plt.plot(region[:, 0], region[:, 1], \"k-\", lw=1.5, label=\"feasible region\")\n", + "plt.plot([0, 0, 24], [0, 20, 8], \"s--\", color=\"#7A4E2D\", ms=8, mfc=\"white\", label=\"simplex: corner to corner\")\n", + "plt.plot(path_xy[:, 0], path_xy[:, 1], \"o-\", color=\"#1F4E79\", ms=4, label=\"barrier: central path\")\n", + "plt.xlabel(\"x1\")\n", + "plt.ylabel(\"x2\")\n", + "plt.legend(loc=\"upper right\", fontsize=8)\n", + "plt.show()\n", + "print(f\"Figure: inside the four-sided region, the simplex goes from (0, 0) up to (0, 20) and across to \"\n", + " f\"(24, 8); the barrier starts at (1, 1), jumps to ({path_xy[1, 0]:.1f}, {path_xy[1, 1]:.1f}) near the \"\n", + " f\"middle, and curves in to (24, 8) without touching an edge until the end.\")" + ] + }, + { + "cell_type": "markdown", + "id": "6b941574", + "metadata": {}, + "source": [ + "## A solver's barrier, for comparison\n", + "\n", + "Gurobi's barrier (`Method=2`) normally finishes with a *crossover* to the exact corner. Turn\n", + "crossover off and it reports where its own interior path stopped. Predict: how close to the\n", + "corner will that be?" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "fe7aab38", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.879987Z", + "iopub.status.busy": "2026-10-27T14:03:22.879596Z", + "iopub.status.idle": "2026-10-27T14:03:22.891028Z", + "shell.execute_reply": "2026-10-27T14:03:22.890508Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Gurobi barrier, no crossover: x1 24.000000 x2 8.000000 z 1360.000000 iterations 5\n" + ] + } + ], + "source": [ + "m = gp.Model(\"barrier check\", env=env)\n", + "m.Params.Method = 2\n", + "m.Params.Crossover = 0\n", + "xg = m.addVars(lp.variables, name=\"x\")\n", + "m.addConstrs((lp.row_expr(r, xg) <= lp.b[r] for r in lp.rows), name=\"row\")\n", + "m.setObjective(gp.quicksum(lp.c[j] * xg[j] for j in lp.variables), GRB.MAXIMIZE)\n", + "m.optimize()\n", + "gurobi_z = m.ObjVal\n", + "print(f\"Gurobi barrier, no crossover: x1 {xg['x1'].X:.6f} x2 {xg['x2'].X:.6f} z {gurobi_z:.6f}\"\n", + " f\" iterations {m.BarIterCount}\")" + ] + }, + { + "cell_type": "markdown", + "id": "a091cf28", + "metadata": {}, + "source": [ + "---\n", + "\n", + "# Now the streamlined version\n", + "\n", + "The same method, once, in `orteach.simplex.barrier_path` (with `T0` and `MU` passed in, so the check\n", + "covers them), and the simplex's last corner from `tableau_path` to compare the ends." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "268f13f5", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.893269Z", + "iopub.status.busy": "2026-10-27T14:03:22.893102Z", + "iopub.status.idle": "2026-10-27T14:03:22.906788Z", + "shell.execute_reply": "2026-10-27T14:03:22.906188Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "package: 32 centerings, last point (24.000000, 8.000000)\n", + "simplex optimum (24.0000, 8.0000) z 1360.0000\n" + ] + } + ], + "source": [ + "from orteach import simplex as sx\n", + "from orteach.tolerance import AGREEMENT_RTOL, CROSS_METHOD_RTOL, rel_diff\n", + "\n", + "pkg_path = sx.barrier_path(lp, X0, t0=T0, mu=MU)\n", + "simplex_end = sx.tableau_path(lp)[-1]\n", + "print(f\"package: {len(pkg_path) - 1} centerings, last point ({pkg_path[-1]['x1']:.6f}, {pkg_path[-1]['x2']:.6f})\")\n", + "print(f\"simplex optimum ({simplex_end.x['x1']:.4f}, {simplex_end.x['x2']:.4f}) z {simplex_end.objective:.4f}\")" + ] + }, + { + "cell_type": "markdown", + "id": "1d223823", + "metadata": {}, + "source": [ + "## The agreement assertion\n", + "\n", + "Every iterate, hand-built against the package, to `AGREEMENT_RTOL`: same method, same knobs, same\n", + "arithmetic. Then the two cross-method claims, each to `CROSS_METHOD_RTOL` because a barrier stops\n", + "near the corner rather than on it: the barrier's end against the simplex optimum, and Gurobi's." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "2f114dcb", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:22.909118Z", + "iopub.status.busy": "2026-10-27T14:03:22.908952Z", + "iopub.status.idle": "2026-10-27T14:03:22.915288Z", + "shell.execute_reply": "2026-10-27T14:03:22.914695Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "132 iterate comparisons\n", + "notebook and package agree to 0.0e+00\n", + " barrier end vs simplex 1359.999999 vs 1360.000000 rel 6.8e-10\n", + " Gurobi barrier vs simplex 1360.000000 vs 1360.000000 rel 4.7e-12\n" + ] + } + ], + "source": [ + "assert len(pkg_path) == len(hand_path), \"different number of centerings\"\n", + "checks = []\n", + "for k, (h, p) in enumerate(zip(hand_path, pkg_path)):\n", + " for j, name in enumerate(names):\n", + " checks.append((f\"iterate {k} {name}\", h[j], p[list(p)[j]]))\n", + "worst = max(rel_diff(h, k) for _, h, k in checks)\n", + "print(f\"{len(checks)} iterate comparisons\")\n", + "assert worst < AGREEMENT_RTOL, f\"notebook and package disagree by {worst:.2e}\"\n", + "print(f\"notebook and package agree to {worst:.1e}\")\n", + "\n", + "ends = [(\"barrier end vs simplex\", c @ final, simplex_end.objective), (\"Gurobi barrier vs simplex\", gurobi_z, simplex_end.objective)]\n", + "for name, a, b_ in ends:\n", + " print(f\" {name:28} {a:.6f} vs {b_:.6f} rel {rel_diff(a, b_):.1e}\")\n", + "assert max(rel_diff(a, b_) for _, a, b_ in ends) < CROSS_METHOD_RTOL, \"the methods end in different places\"" + ] + }, + { + "cell_type": "markdown", + "id": "005351d7", + "metadata": {}, + "source": [ + "---\n", + "\n", + "## Where to take this next\n", + "\n", + "- Set `MU` to 10 and re-run. How many centerings now, how many Newton steps, and what happens to\n", + " the picture?\n", + "- Start at $x_1 = 25,\\ x_2 = 1$. Is that inside? What does the path do?\n", + "- Print the gap bound (number of variables over $t$) next to the true gap ($1360 - c^\\top x$) at\n", + " each centering. How loose is the bound?" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.13.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/02_simplex_and_bases/simplex_by_hand.ipynb b/notebooks/02_simplex_and_bases/simplex_by_hand.ipynb new file mode 100644 index 0000000..5b69bf3 --- /dev/null +++ b/notebooks/02_simplex_and_bases/simplex_by_hand.ipynb @@ -0,0 +1,669 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "43c21b02", + "metadata": {}, + "source": [ + "# Corners, bases and the simplex tableau, by hand\n", + "\n", + "A linear program's optimum sits at a corner of its feasible region. That is a picture with two\n", + "variables and a theorem with many, and the simplex method is how the theorem gets used: walk from\n", + "corner to neighbouring corner, never downhill, until no neighbour is better.\n", + "\n", + "This notebook does it on the course's tableau example, by hand, with numpy doing only the\n", + "arithmetic. First every corner, feasible or not; then the walk, one pivot at a time." + ] + }, + { + "cell_type": "markdown", + "id": "958e0cff", + "metadata": {}, + "source": [ + "## Setup: where the package lives\n", + "\n", + "This notebook builds everything by hand and then checks it against `orteach`, the package in\n", + "`src/`. Run from a clone of the repository, `../../src` is right there. On Colab there is no clone\n", + "until this cell makes one, and no `gurobipy` until it installs it. Nothing here needs a secret." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "23ad9279", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.501917Z", + "iopub.status.busy": "2026-10-27T14:03:10.501694Z", + "iopub.status.idle": "2026-10-27T14:03:10.516257Z", + "shell.execute_reply": "2026-10-27T14:03:10.515763Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "package: src\\orteach\n" + ] + } + ], + "source": [ + "import os, subprocess, sys\n", + "\n", + "REPO_URL = \"https://github.com/sear-labs/teaching-code\"\n", + "REF = \"v1.0.0\" # the release this notebook ships in: Colab clones THIS\n", + "\n", + "try:\n", + " import google.colab # noqa: F401 - succeeds only on Colab\n", + " ON_COLAB = True\n", + "except ImportError:\n", + " ON_COLAB = False\n", + "\n", + "if ON_COLAB:\n", + " if not os.path.isdir(\"/content/teaching-code\"):\n", + " subprocess.run([\"git\", \"clone\", \"--quiet\", \"--depth\", \"1\", \"--branch\", REF, REPO_URL, \"/content/teaching-code\"], check=True)\n", + " os.chdir(\"/content/teaching-code/notebooks/02_simplex_and_bases\")\n", + " subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", \"gurobipy>=11,<14\"], check=True)\n", + "\n", + "sys.path.insert(0, os.path.abspath(os.path.join(\"..\", \"..\", \"src\")))\n", + "try:\n", + " import orteach # noqa: F401\n", + "except ImportError:\n", + " raise SystemExit(\"orteach not found: run this notebook from its own folder inside the repository, \"\n", + " \"so that ../../src exists.\")\n", + "root = os.path.abspath(os.path.join(\"..\", \"..\"))\n", + "print(\"package:\", os.path.relpath(os.path.dirname(orteach.__file__), root))" + ] + }, + { + "cell_type": "markdown", + "id": "c490b532", + "metadata": {}, + "source": [ + "## Licence setup\n", + "\n", + "Only the cross-check at the end uses a solver. Nothing here needs a key: `pip install gurobipy`\n", + "ships a size-limited licence and this model is tiny. The environment starts silent, so no licence\n", + "number lands in an output cell." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "b7dc4276", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.518565Z", + "iopub.status.busy": "2026-10-27T14:03:10.518360Z", + "iopub.status.idle": "2026-10-27T14:03:10.574522Z", + "shell.execute_reply": "2026-10-27T14:03:10.574106Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "licence: local gurobi.lic\n" + ] + } + ], + "source": [ + "import gurobipy as gp\n", + "from gurobipy import GRB\n", + "\n", + "env = gp.Env(empty=True)\n", + "env.setParam(\"OutputFlag\", 0) # start silent: the licence banner, and its licence number, stay out of the outputs\n", + "try:\n", + " from google.colab import userdata\n", + " try:\n", + " env.setParam(\"WLSACCESSID\", userdata.get(\"GRB_WLSACCESSID\"))\n", + " env.setParam(\"WLSSECRET\", userdata.get(\"GRB_WLSSECRET\"))\n", + " env.setParam(\"LICENSEID\", int(userdata.get(\"GRB_LICENSEID\")))\n", + " licence = \"Colab Secrets (WLS)\"\n", + " except (userdata.SecretNotFoundError, userdata.NotebookAccessError):\n", + " licence = \"the size-limited licence pip ships\" # no key needed; see the note above\n", + "except ImportError:\n", + " licence = \"local gurobi.lic\"\n", + "env.start()\n", + "print(\"licence:\", licence)" + ] + }, + { + "cell_type": "markdown", + "id": "c0e77084", + "metadata": {}, + "source": [ + "## The LP, and its standard form\n", + "\n", + "Two products, two resources: maximise $40x_1 + 50x_2$ subject to $x_1 + 2x_2 \\le 40$ and\n", + "$4x_1 + 3x_2 \\le 120$. It is a table in `data/raw/`, read by the same loader the duality notebook\n", + "uses.\n", + "\n", + "The simplex method works on equations, so each `<=` row gets a slack variable, $s_1$ and $s_2$:\n", + "how much of that resource is left over. Two equations, four unknowns." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "470faa0d", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.576666Z", + "iopub.status.busy": "2026-10-27T14:03:10.576459Z", + "iopub.status.idle": "2026-10-27T14:03:10.799943Z", + "shell.execute_reply": "2026-10-27T14:03:10.799441Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A =\n", + " [[1. 2. 1. 0.]\n", + " [4. 3. 0. 1.]] \n", + "b = [ 40. 120.] \n", + "c = [40. 50. 0. 0.]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "from orteach.duality import load_lp\n", + "\n", + "lp = load_lp(\"lp_simplex_40_50.csv\")\n", + "names = [\"x1\", \"x2\", \"s1\", \"s2\"]\n", + "A = np.array([[lp.A[\"c1\", \"x1\"], lp.A[\"c1\", \"x2\"], 1.0, 0.0],\n", + " [lp.A[\"c2\", \"x1\"], lp.A[\"c2\", \"x2\"], 0.0, 1.0]])\n", + "b = np.array([lp.b[\"c1\"], lp.b[\"c2\"]])\n", + "c = np.array([lp.c[\"x1\"], lp.c[\"x2\"], 0.0, 0.0])\n", + "print(\"A =\\n\", A, \"\\nb =\", b, \"\\nc =\", c)" + ] + }, + { + "cell_type": "markdown", + "id": "7966de65", + "metadata": {}, + "source": [ + "## Every corner is a choice of basis\n", + "\n", + "Pick two of the four columns to be **basic**, set the other two to zero, and solve the two\n", + "equations for the basic pair. Every corner of the feasible region is one such choice. The converse\n", + "fails: some choices give a point with a negative variable, which is a corner of the lines but not of\n", + "the region.\n", + "\n", + "There are $\\binom{4}{2} = 6$ choices. Predict before running: how many are feasible, and which is\n", + "best?" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "307cf399", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.802184Z", + "iopub.status.busy": "2026-10-27T14:03:10.801970Z", + "iopub.status.idle": "2026-10-27T14:03:10.808855Z", + "shell.execute_reply": "2026-10-27T14:03:10.808355Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "basic x1 x2 s1 s2 feasible objective\n", + "x1, x2 24.00 8.00 0.00 0.00 True 1360.00\n", + "x1, s1 30.00 0.00 10.00 0.00 True 1200.00\n", + "x1, s2 40.00 0.00 0.00 -40.00 False 1600.00\n", + "x2, s1 0.00 40.00 -40.00 0.00 False 2000.00\n", + "x2, s2 0.00 20.00 0.00 60.00 True 1000.00\n", + "s1, s2 0.00 0.00 40.00 120.00 True 0.00\n" + ] + } + ], + "source": [ + "from itertools import combinations\n", + "\n", + "corners = []\n", + "for basis in combinations(range(4), 2): # the same three lines for every choice\n", + " x = np.zeros(4)\n", + " x[list(basis)] = np.linalg.solve(A[:, basis], b)\n", + " corners.append((basis, x, bool((x >= 0).all()), float(c @ x)))\n", + "\n", + "print(f\"{'basic':12} {'x1':>7} {'x2':>7} {'s1':>7} {'s2':>7} feasible objective\")\n", + "for basis, x, ok, z in corners:\n", + " print(f\"{names[basis[0]] + ', ' + names[basis[1]]:12} \" + \" \".join(f\"{v:7.2f}\" for v in x) + f\" {ok!s:8} {z:9.2f}\")" + ] + }, + { + "cell_type": "markdown", + "id": "60532e12", + "metadata": {}, + "source": [ + "Enumerating is fine for six. With 50 variables and 30 constraints there are 80 columns and\n", + "$\binom{80}{30}$ choices, about $9 \times 10^{21}$.\n", + "The simplex method visits a handful of them, always moving to a neighbour that is no worse.\n", + "\n", + "## The tableau\n", + "\n", + "The objective becomes a row too: $z - 40x_1 - 50x_2 = 0$. Row 0 is that equation, rows 1 and 2\n", + "are the constraints, the last column is the right-hand side. The slacks are the starting basis,\n", + "which is the corner at the origin." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "06e3f4d6", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.810764Z", + "iopub.status.busy": "2026-10-27T14:03:10.810590Z", + "iopub.status.idle": "2026-10-27T14:03:10.814863Z", + "shell.execute_reply": "2026-10-27T14:03:10.814393Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " x1 x2 s1 s2 rhs\n", + "z -40.00 -50.00 0.00 0.00 0.00\n", + "s1 1.00 2.00 1.00 0.00 40.00\n", + "s2 4.00 3.00 0.00 1.00 120.00\n" + ] + } + ], + "source": [ + "T = np.zeros((3, 5))\n", + "T[0, :4] = -c + 0.0 # + 0.0: a printed -0.00 becomes 0.00\n", + "T[1:, :4] = A\n", + "T[1:, 4] = b\n", + "basis = [2, 3] # s1, s2\n", + "\n", + "print(\" x1 x2 s1 s2 rhs\")\n", + "for label, row in zip([\"z\"] + [names[j] for j in basis], T):\n", + " print(f\"{label:4}\" + \"\".join(f\"{v:8.2f}\" for v in row))" + ] + }, + { + "cell_type": "markdown", + "id": "f95d548c", + "metadata": {}, + "source": [ + "## First pivot\n", + "\n", + "**Entering:** a negative number in row 0 means raising that variable raises $z$. Take the most\n", + "negative. **Leaving:** raise the entering variable until some basic variable hits zero; the ratio\n", + "of right-hand side to the entering column, over rows where that column is positive, says which\n", + "hits zero first. Predict both before running." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "42784d6d", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.816954Z", + "iopub.status.busy": "2026-10-27T14:03:10.816781Z", + "iopub.status.idle": "2026-10-27T14:03:10.820992Z", + "shell.execute_reply": "2026-10-27T14:03:10.820474Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "entering x2 ratios [20.0, 40.0] leaving s1\n" + ] + } + ], + "source": [ + "enter = int(np.argmin(T[0, :4]))\n", + "ratios = [T[i, 4] / T[i, enter] if T[i, enter] > 0 else np.inf for i in (1, 2)]\n", + "leave_row = 1 + int(np.argmin(ratios))\n", + "print(\"entering\", names[enter], \" ratios\", [round(float(r), 2) for r in ratios], \" leaving\", names[basis[leave_row - 1]])" + ] + }, + { + "cell_type": "markdown", + "id": "bea1c017", + "metadata": {}, + "source": [ + "The pivot itself is three row operations: scale the leaving row so the entering column holds a 1\n", + "there, then subtract multiples of it to clear that column from the other two rows. Written out." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "76802255", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.822972Z", + "iopub.status.busy": "2026-10-27T14:03:10.822802Z", + "iopub.status.idle": "2026-10-27T14:03:10.827874Z", + "shell.execute_reply": "2026-10-27T14:03:10.827383Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " x1 x2 s1 s2 rhs\n", + "z -15.00 0.00 25.00 0.00 1000.00\n", + "x2 0.50 1.00 0.50 0.00 20.00\n", + "s2 2.50 0.00 -1.50 1.00 60.00\n", + "\n", + "now at {'x1': 0.0, 'x2': 20.0, 's1': 0.0, 's2': 60.0} z = 1000.0\n" + ] + } + ], + "source": [ + "T[leave_row] = T[leave_row] / T[leave_row, enter]\n", + "T[0] = T[0] - T[0, enter] * T[leave_row]\n", + "other = 3 - leave_row # the constraint row that did not leave\n", + "T[other] = T[other] - T[other, enter] * T[leave_row]\n", + "basis[leave_row - 1] = enter\n", + "\n", + "print(\" x1 x2 s1 s2 rhs\")\n", + "for label, row in zip([\"z\"] + [names[j] for j in basis], T):\n", + " print(f\"{label:4}\" + \"\".join(f\"{v:8.2f}\" for v in row))\n", + "corner_1 = np.zeros(4)\n", + "corner_1[basis] = T[1:, 4]\n", + "print(\"\\nnow at\", dict(zip(names, corner_1.round(4).tolist())), \" z =\", T[0, 4])" + ] + }, + { + "cell_type": "markdown", + "id": "71a9a495", + "metadata": {}, + "source": [ + "Which corner from the enumeration is this? Is row 0 free of negative numbers yet?\n", + "\n", + "## Second pivot\n", + "\n", + "The same two choices, on the new tableau. Predict which variable enters and which leaves." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "23f3c388", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.829858Z", + "iopub.status.busy": "2026-10-27T14:03:10.829690Z", + "iopub.status.idle": "2026-10-27T14:03:10.835114Z", + "shell.execute_reply": "2026-10-27T14:03:10.834784Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "entering x1 ratios [40.0, 24.0] leaving s2\n", + "\n", + " x1 x2 s1 s2 rhs\n", + "z 0.00 0.00 16.00 6.00 1360.00\n", + "x2 0.00 1.00 0.80 -0.20 8.00\n", + "x1 1.00 0.00 -0.60 0.40 24.00\n", + "\n", + "now at {'x1': 24.0, 'x2': 8.0, 's1': 0.0, 's2': 0.0} z = 1360.0\n" + ] + } + ], + "source": [ + "enter = int(np.argmin(T[0, :4]))\n", + "ratios = [T[i, 4] / T[i, enter] if T[i, enter] > 0 else np.inf for i in (1, 2)]\n", + "leave_row = 1 + int(np.argmin(ratios))\n", + "print(\"entering\", names[enter], \" ratios\", [round(float(r), 2) for r in ratios], \" leaving\", names[basis[leave_row - 1]])\n", + "\n", + "T[leave_row] = T[leave_row] / T[leave_row, enter]\n", + "T[0] = T[0] - T[0, enter] * T[leave_row]\n", + "other = 3 - leave_row\n", + "T[other] = T[other] - T[other, enter] * T[leave_row]\n", + "basis[leave_row - 1] = enter\n", + "\n", + "print(\"\\n x1 x2 s1 s2 rhs\")\n", + "for label, row in zip([\"z\"] + [names[j] for j in basis], T):\n", + " print(f\"{label:4}\" + \"\".join(f\"{v:8.2f}\" for v in row))\n", + "corner_2 = np.zeros(4)\n", + "corner_2[basis] = T[1:, 4]\n", + "print(\"\\nnow at\", dict(zip(names, corner_2.round(4).tolist())), \" z =\", T[0, 4])" + ] + }, + { + "cell_type": "markdown", + "id": "9365b32a", + "metadata": {}, + "source": [ + "## Stop\n", + "\n", + "No negative number is left in row 0, so no neighbouring corner is better: this corner is optimal.\n", + "Row 0 also holds two more numbers under the slacks. Compare them with the duals the duality\n", + "notebook in `03` reads off a solver: what do they price?" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e1b5e8da", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.837057Z", + "iopub.status.busy": "2026-10-27T14:03:10.836887Z", + "iopub.status.idle": "2026-10-27T14:03:10.841361Z", + "shell.execute_reply": "2026-10-27T14:03:10.840861Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "row 0 nonnegative: True\n", + "path (x1, x2, z): [(0.0, 0.0, 0.0), (0.0, 20.0, 1000.0), (24.0, 8.0, 1360.0)]\n", + "row 0 under s1, s2: [16. 6.]\n" + ] + } + ], + "source": [ + "print(\"row 0 nonnegative:\", bool((T[0, :4] >= 0).all()))\n", + "hand_path = [(0.0, 0.0, 0.0), (float(corner_1[0]), float(corner_1[1]), float(c @ corner_1)),\n", + " (float(corner_2[0]), float(corner_2[1]), float(c @ corner_2))]\n", + "print(\"path (x1, x2, z):\", [tuple(round(v, 4) for v in p) for p in hand_path])\n", + "print(\"row 0 under s1, s2:\", T[0, 2:4])" + ] + }, + { + "cell_type": "markdown", + "id": "d598f419", + "metadata": {}, + "source": [ + "## A solver, for comparison\n", + "\n", + "Gurobi's own simplex (`Method=0`) on the same table. Predict whether it reports the same corner,\n", + "and whether the duals match row 0." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "15eedcce", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.843448Z", + "iopub.status.busy": "2026-10-27T14:03:10.843282Z", + "iopub.status.idle": "2026-10-27T14:03:10.848851Z", + "shell.execute_reply": "2026-10-27T14:03:10.848367Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Gurobi: x1 24.0000 x2 8.0000 z 1360.0000 duals {'c1': 16.0, 'c2': 6.0}\n" + ] + } + ], + "source": [ + "m = gp.Model(\"simplex check\", env=env)\n", + "m.Params.Method = 0\n", + "xg = m.addVars(lp.variables, name=\"x\")\n", + "rows = {r: m.addConstr(lp.row_expr(r, xg) <= lp.b[r], name=r) for r in lp.rows}\n", + "m.setObjective(gp.quicksum(lp.c[j] * xg[j] for j in lp.variables), GRB.MAXIMIZE)\n", + "m.optimize()\n", + "gurobi_z = m.ObjVal\n", + "print(f\"Gurobi: x1 {xg['x1'].X:.4f} x2 {xg['x2'].X:.4f} z {gurobi_z:.4f} duals\", {r: round(rows[r].Pi, 4) for r in lp.rows})" + ] + }, + { + "cell_type": "markdown", + "id": "dacb6b73", + "metadata": {}, + "source": [ + "---\n", + "\n", + "# Now the streamlined version\n", + "\n", + "The enumeration and the pivots, once each, in `orteach.simplex`: `basic_solutions` returns every\n", + "choice of basis, and `tableau_path` the corners the simplex visits, with the same rules used here\n", + "(most negative entry in row 0 enters; smallest ratio leaves; lowest index on a tie)." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "082bbd22", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.850772Z", + "iopub.status.busy": "2026-10-27T14:03:10.850605Z", + "iopub.status.idle": "2026-10-27T14:03:10.858094Z", + "shell.execute_reply": "2026-10-27T14:03:10.857590Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6 bases, 4 feasible\n", + "path: [(0.0, 0.0, 0.0), (0.0, 20.0, 1000.0), (24.0, 8.0, 1360.0)]\n" + ] + } + ], + "source": [ + "from orteach import simplex as sx\n", + "from orteach.tolerance import AGREEMENT_RTOL, rel_diff\n", + "\n", + "pkg_corners = sx.basic_solutions(lp)\n", + "pkg_path = sx.tableau_path(lp)\n", + "print(len(pkg_corners), \"bases,\", sum(k.feasible for k in pkg_corners), \"feasible\")\n", + "print(\"path:\", [(round(float(k.x[\"x1\"]), 4), round(float(k.x[\"x2\"]), 4), round(k.objective, 4)) for k in pkg_path])" + ] + }, + { + "cell_type": "markdown", + "id": "a2edaf1e", + "metadata": {}, + "source": [ + "## The agreement assertion\n", + "\n", + "The six bases (each point, its feasibility and its objective), the path walked, and the optimum\n", + "against Gurobi's. With no ties anywhere in this tableau, the path is the problem's and not a\n", + "tie-break's, so it is compared corner by corner." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "d083fcc1", + "metadata": { + "execution": { + "iopub.execute_input": "2026-10-27T14:03:10.860168Z", + "iopub.status.busy": "2026-10-27T14:03:10.859998Z", + "iopub.status.idle": "2026-10-27T14:03:10.865774Z", + "shell.execute_reply": "2026-10-27T14:03:10.865309Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "40 comparisons, plus feasibility of every basis\n", + "notebook and package agree to 0.0e+00\n" + ] + } + ], + "source": [ + "checks = []\n", + "assert len(pkg_corners) == len(corners), \"different number of bases\"\n", + "for (basis_h, x_h, ok_h, z_h), k in zip(corners, pkg_corners):\n", + " assert ok_h == k.feasible, \"feasibility differs at \" + str(k.basis)\n", + " for j, name in enumerate(names):\n", + " checks.append((f\"{k.basis} {name}\", x_h[j], k.x[list(k.x)[j]]))\n", + " checks.append((f\"{k.basis} z\", z_h, k.objective))\n", + "assert len(pkg_path) == len(hand_path), \"different number of pivots\"\n", + "for (x1, x2, z), k in zip(hand_path, pkg_path):\n", + " checks += [(\"path x1\", x1, k.x[\"x1\"]), (\"path x2\", x2, k.x[\"x2\"]), (\"path z\", z, k.objective)]\n", + "checks.append((\"optimum vs Gurobi\", hand_path[-1][2], gurobi_z))\n", + "\n", + "worst = max(rel_diff(h, k) for _, h, k in checks)\n", + "print(f\"{len(checks)} comparisons, plus feasibility of every basis\")\n", + "assert worst < AGREEMENT_RTOL, f\"notebook and package disagree by {worst:.2e}\"\n", + "print(f\"notebook and package agree to {worst:.1e}\")" + ] + }, + { + "cell_type": "markdown", + "id": "b6346e6c", + "metadata": {}, + "source": [ + "---\n", + "\n", + "## Where to take this next\n", + "\n", + "- The slides' exercise is `lp_wyndor.csv` (max $3x_1 + 5x_2$, three plants). Load it and pivot it\n", + " by hand: the tableau has one more row, so each pivot clears two other rows, not one.\n", + "- Change the objective to $40x_1 + 80x_2$. Row 0 at the optimum now has a zero under a nonbasic\n", + " variable. What does that zero mean about the set of optimal solutions?\n", + "- `interior_point.ipynb` in this folder solves the same LP without visiting any corner at all." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.13.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/orteach/simplex.py b/src/orteach/simplex.py new file mode 100644 index 0000000..fa27c35 --- /dev/null +++ b/src/orteach/simplex.py @@ -0,0 +1,145 @@ +"""The simplex method on a tableau, and a barrier method through the interior, written once. + +The teaching notebooks in ``notebooks/02_simplex_and_bases/`` build both by hand on IE 3315's +tableau example (``data/raw/lp_simplex_40_50.csv``: max 40x1 + 50x2, x1 + 2x2 <= 40, +4x1 + 3x2 <= 120). This module is what their agreement assertions compare against. + +Only a ``max`` LP with ``<=`` rows and non-negative right-hand sides is taken, which is the case +the course's tableau starts from: the slacks are then a feasible starting basis. Anything else +is refused rather than half-handled. + + standard_form [A | I] x = b with one slack per row, and the objective padded with zeros + basic_solutions every choice of m basic columns: the corners, feasible or not + tableau_path the corners the simplex method visits, Dantzig's rule, lowest index on ties + barrier_path the central path: Newton centering on -t c.x - sum log x, t multiplied by MU +""" +from __future__ import annotations + +from dataclasses import dataclass +from itertools import combinations + +import numpy as np + +from . import tolerance +from .duality import LP + + +@dataclass +class StandardForm: + names: list # original variables, then one slack per row ("s_") + A: np.ndarray # m x (n + m) + b: np.ndarray + c: np.ndarray # objective over all n + m columns (zeros on the slacks) + n_original: int + + +def standard_form(lp: LP) -> StandardForm: + if lp.objective != "max" or any(lp.sense[r] != "<=" for r in lp.rows) or any(lp.b[r] < 0 for r in lp.rows): + raise ValueError("simplex.standard_form takes a max LP with <= rows and b >= 0 only, " + "so the slacks are a feasible first basis") + A = np.array([[lp.A.get((r, j), 0.0) for j in lp.variables] for r in lp.rows]) + m, n = A.shape + return StandardForm(list(lp.variables) + ["s_" + r for r in lp.rows], + np.hstack([A, np.eye(m)]), np.array([lp.b[r] for r in lp.rows], dtype=float), + np.concatenate([[lp.c[j] for j in lp.variables], np.zeros(m)]), n) + + +@dataclass +class Corner: + basis: tuple # names of the basic columns + x: dict # name -> value, every column + feasible: bool + objective: float + + +def basic_solutions(lp: LP) -> list: + """All C(n + m, m) choices of basic columns. A singular choice is skipped: no corner.""" + sf = standard_form(lp) + m = sf.A.shape[0] + out = [] + for cols in combinations(range(len(sf.names)), m): + B = sf.A[:, cols] + if abs(np.linalg.det(B)) < tolerance.LINALG_ATOL: + continue + x = np.zeros(len(sf.names)) + x[list(cols)] = np.linalg.solve(B, sf.b) + out.append(Corner(tuple(sf.names[j] for j in cols), dict(zip(sf.names, x)), + bool((x >= -tolerance.FEASIBILITY_ATOL).all()), float(sf.c @ x))) + return out + + +def tableau_path(lp: LP) -> list: + """The corners the tableau simplex visits from the all-slack basis, as Corner objects. + Entering: most negative reduced cost (lowest index on a tie). Leaving: smallest ratio + (lowest index on a tie).""" + sf = standard_form(lp) + m, N = sf.A.shape + T = np.zeros((m + 1, N + 1)) # row 0 is the objective row z - c.x = 0 + T[0, :N], T[1:, :N], T[1:, N] = -sf.c, sf.A, sf.b + basis = list(range(sf.n_original, N)) + path = [] + for _ in range(100): + x = np.zeros(N) + x[basis] = T[1:, N] + path.append(Corner(tuple(sf.names[j] for j in basis), dict(zip(sf.names, x)), True, float(T[0, N]))) + enter = int(np.argmin(T[0, :N])) + if T[0, enter] >= -tolerance.LINALG_ATOL: + return path + col = T[1:, enter] + ratios = [T[i + 1, N] / col[i] if col[i] > tolerance.LINALG_ATOL else np.inf for i in range(m)] + leave = int(np.argmin(ratios)) + if not np.isfinite(ratios[leave]): + raise ValueError("unbounded: no row limits %s" % sf.names[enter]) + T[leave + 1] /= T[leave + 1, enter] + for i in range(m + 1): + if i != leave + 1: + T[i] -= T[i, enter] * T[leave + 1] + basis[leave] = enter + raise RuntimeError("tableau simplex did not stop in 100 pivots") + + +# ------------------------------------------------------------------------------- the barrier +MU = 10.0 # how much t grows between centerings +NEWTON_MAX = 50 # Newton steps allowed per centering (it needs a handful) + + +def _newton_step(sf: StandardForm, x: np.ndarray, t: float) -> tuple[np.ndarray, float]: + """One equality-constrained Newton direction for -t c.x - sum log x on A x = b, and the + Newton decrement squared.""" + m, N = sf.A.shape + g = -t * sf.c - 1.0 / x + H = np.diag(1.0 / x ** 2) + K = np.block([[H, sf.A.T], [sf.A, np.zeros((m, m))]]) + dx = np.linalg.solve(K, np.concatenate([-g, np.zeros(m)]))[:N] + return dx, float(dx @ H @ dx) + + +def barrier_path(lp: LP, x0: dict, t0: float = 1.0, mu: float = MU, gap: float = None) -> list: + """Central-path iterates (one per centering) from the strictly interior point x0, given in the + ORIGINAL variables (the slacks follow from A x + s = b). Stops when the duality-gap bound + (n + m) / t falls below `gap` (default CROSS_METHOD_RTOL, an absolute bound on how far the + objective can be from optimal).""" + sf = standard_form(lp) + x = np.concatenate([[x0[j] for j in lp.variables], sf.b - sf.A[:, :sf.n_original] @ [x0[j] for j in lp.variables]]) + if (x <= 0).any(): + raise ValueError("x0 must be strictly inside: every variable and every slack positive") + N = len(x) + t = t0 + target = gap if gap is not None else tolerance.CROSS_METHOD_RTOL + path = [dict(zip(sf.names, x))] + + def f(z): + return -t * sf.c @ z - np.log(z).sum() + + while N / t > target: + for _ in range(NEWTON_MAX): + dx, lam2 = _newton_step(sf, x, t) + if lam2 / 2 < tolerance.LINALG_ATOL: + break + step = 1.0 + while (x + step * dx <= 0).any() or f(x + step * dx) > f(x) - 0.25 * step * lam2: + step *= 0.5 + x = x + step * dx + path.append(dict(zip(sf.names, x))) + t *= mu + return path diff --git a/tests/test_simplex.py b/tests/test_simplex.py new file mode 100644 index 0000000..53e68e5 --- /dev/null +++ b/tests/test_simplex.py @@ -0,0 +1,80 @@ +"""The tableau simplex and the barrier method (notebooks/02_simplex_and_bases/), pinned. + +The tableau example is IE 3315's own (deck 05): max 40x1 + 50x2, x1 + 2x2 <= 40, 4x1 + 3x2 <= 120, +which the slides solve from (0, 0) through (0, 20) to (24, 8), value 1360. The invariants: the +simplex never decreases the objective and visits only feasible corners; every barrier iterate is +strictly inside and satisfies A x = b; and the two methods end at the same optimum. +""" +import os +import sys + +import gurobipy as gp +import numpy as np +import pytest + +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname( + os.path.abspath(__file__))), "src")) + +from orteach import simplex as sx # noqa: E402 +from orteach.duality import load_lp, with_row # noqa: E402 +from orteach.tolerance import CROSS_METHOD_RTOL, FEASIBILITY_ATOL, rel_diff # noqa: E402 + + +@pytest.fixture(scope="module") +def lp(): + return load_lp("lp_simplex_40_50.csv") + + +def test_six_bases_four_corners_and_the_best_is_24_8(lp): + corners = sx.basic_solutions(lp) + assert len(corners) == 6 and sum(c.feasible for c in corners) == 4 + best = max((c for c in corners if c.feasible), key=lambda c: c.objective) + assert (best.x["x1"], best.x["x2"], best.objective) == pytest.approx((24, 8, 1360)) + for c in corners: + if not c.feasible: + assert min(c.x.values()) < 0 + + +def test_the_tableau_takes_the_slides_path(lp): + path = sx.tableau_path(lp) + assert [(round(c.x["x1"], 9), round(c.x["x2"], 9)) for c in path] == [(0, 0), (0, 20), (24, 8)] + assert [c.objective for c in path] == pytest.approx([0, 1000, 1360]) + + +def test_wyndor_the_slides_exercise(lp): + path = sx.tableau_path(load_lp("lp_wyndor.csv")) + assert [(round(c.x["x1"], 9), round(c.x["x2"], 9)) for c in path] == [(0, 0), (0, 6), (2, 6)] + assert path[-1].objective == pytest.approx(36) + + +def test_gurobi_agrees_with_the_tableau(lp): + with gp.Model() as m: + m.Params.OutputFlag = 0 + x = m.addVars(lp.variables) + m.addConstrs(lp.row_expr(r, x) <= lp.b[r] for r in lp.rows) + m.setObjective(gp.quicksum(lp.c[j] * x[j] for j in lp.variables), gp.GRB.MAXIMIZE) + m.optimize() + assert rel_diff(m.ObjVal, sx.tableau_path(lp)[-1].objective) < CROSS_METHOD_RTOL + + +def test_only_the_case_the_tableau_starts_from_is_taken(lp): + with pytest.raises(ValueError, match="max LP"): + sx.standard_form(with_row(lp, "floor", {"x1": 1.0}, ">=", 1.0)) + + +def test_every_barrier_iterate_is_inside_and_the_objective_climbs(lp): + sf = sx.standard_form(lp) + path = sx.barrier_path(lp, {"x1": 1.0, "x2": 1.0}, t0=0.001, mu=2.0) + zs = [] + for p in path: + x = np.array([p[n] for n in sf.names]) + assert (x > 0).all() + assert np.abs(sf.A @ x - sf.b).max() < FEASIBILITY_ATOL + zs.append(float(sf.c @ x)) + assert all(b >= a - FEASIBILITY_ATOL for a, b in zip(zs[1:], zs[2:])), zs # after the first centering + assert rel_diff(zs[-1], 1360) < CROSS_METHOD_RTOL + + +def test_a_start_outside_is_refused(lp): + with pytest.raises(ValueError, match="strictly inside"): + sx.barrier_path(lp, {"x1": 40.0, "x2": 1.0}) diff --git a/tools/seeds/seed_barrier.py b/tools/seeds/seed_barrier.py new file mode 100644 index 0000000..90377df --- /dev/null +++ b/tools/seeds/seed_barrier.py @@ -0,0 +1,317 @@ +"""Seed for the interior-point (barrier) notebook (02). Writes the notebook without outputs; execute it afterwards (README.md here).""" +import json +import os + +REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +OUT = os.path.join(REPO, "notebooks", "02_simplex_and_bases", "interior_point.ipynb") +cells = [] + + +def md(t): + cells.append({"cell_type": "markdown", "metadata": {}, "source": t.strip("\n").splitlines(keepends=True)}) + + +def code(t): + cells.append({"cell_type": "code", "execution_count": None, "metadata": {}, "outputs": [], + "source": t.strip("\n").splitlines(keepends=True)}) + + +md(r""" +# Through the middle: a barrier method for the same LP + +`simplex_by_hand.ipynb` walked the edges of the feasible region from corner to corner. A barrier +(interior-point) method never touches an edge until the very end. It replaces the hard constraints +$x \ge 0$ with a penalty that grows without limit near them, solves that smooth problem, then +weakens the penalty a little and solves again. The solutions trace a curve through the interior, +the **central path**, that ends at the optimal corner. + +Same LP: maximise $40x_1 + 50x_2$ with $x_1 + 2x_2 \le 40$ and $4x_1 + 3x_2 \le 120$. +""") + +md(r""" +## Setup: where the package lives + +This notebook builds the method by hand and then checks it against `orteach`, the package in +`src/`. Run from a clone of the repository, `../../src` is right there. On Colab there is no clone +until this cell makes one, and no `gurobipy` until it installs it. Nothing here needs a secret. +""") +code(r''' +import os, subprocess, sys + +REPO_URL = "https://github.com/sear-labs/teaching-code" +REF = "v1.0.0" # the release this notebook ships in: Colab clones THIS + +try: + import google.colab # noqa: F401 - succeeds only on Colab + ON_COLAB = True +except ImportError: + ON_COLAB = False + +if ON_COLAB: + if not os.path.isdir("/content/teaching-code"): + subprocess.run(["git", "clone", "--quiet", "--depth", "1", "--branch", REF, REPO_URL, "/content/teaching-code"], check=True) + os.chdir("/content/teaching-code/notebooks/02_simplex_and_bases") + subprocess.run([sys.executable, "-m", "pip", "install", "--quiet", "gurobipy>=11,<14"], check=True) + +sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "src"))) +try: + import orteach # noqa: F401 +except ImportError: + raise SystemExit("orteach not found: run this notebook from its own folder inside the repository, " + "so that ../../src exists.") +root = os.path.abspath(os.path.join("..", "..")) +print("package:", os.path.relpath(os.path.dirname(orteach.__file__), root)) +''') + +md(r""" +## Licence setup + +Only the cross-check at the end uses a solver. Nothing here needs a key: `pip install gurobipy` +ships a size-limited licence and this model is tiny. The environment starts silent, so no licence +number lands in an output cell. +""") +code(r''' +import gurobipy as gp +from gurobipy import GRB + +env = gp.Env(empty=True) +env.setParam("OutputFlag", 0) # start silent: the licence banner, and its licence number, stay out of the outputs +try: + from google.colab import userdata + try: + env.setParam("WLSACCESSID", userdata.get("GRB_WLSACCESSID")) + env.setParam("WLSSECRET", userdata.get("GRB_WLSSECRET")) + env.setParam("LICENSEID", int(userdata.get("GRB_LICENSEID"))) + licence = "Colab Secrets (WLS)" + except (userdata.SecretNotFoundError, userdata.NotebookAccessError): + licence = "the size-limited licence pip ships" # no key needed; see the note above +except ImportError: + licence = "local gurobi.lic" +env.start() +print("licence:", licence) +''') + +md(r""" +## Standard form, and a point strictly inside + +The same four columns as the tableau notebook: $x_1, x_2$ and one slack per row, with $Ax = b$. +A barrier method has to start strictly inside, every variable positive. Take $x_1 = x_2 = 1$; the +slacks follow from the equations. +""") +code(r''' +import numpy as np +from orteach import tolerance +from orteach.duality import load_lp + +lp = load_lp("lp_simplex_40_50.csv") +names = ["x1", "x2", "s1", "s2"] +A = np.array([[lp.A["c1", "x1"], lp.A["c1", "x2"], 1.0, 0.0], + [lp.A["c2", "x1"], lp.A["c2", "x2"], 0.0, 1.0]]) +b = np.array([lp.b["c1"], lp.b["c2"]]) +c = np.array([lp.c["x1"], lp.c["x2"], 0.0, 0.0]) + +X0 = {"x1": 1.0, "x2": 1.0} +x = np.array([X0["x1"], X0["x2"], b[0] - A[0, :2] @ [1.0, 1.0], b[1] - A[1, :2] @ [1.0, 1.0]]) +print("start", dict(zip(names, x.tolist())), " all positive:", bool((x > 0).all()), " A x - b =", A @ x - b) +''') + +md(r""" +## The barrier problem + +Maximising $c^\top x$ is minimising $-c^\top x$. Add $-\sum_i \log x_i$, which is small in the +middle and rises without bound as any $x_i$ approaches zero, and weigh the original objective by a +number $t$: + +$$\min_x\; f_t(x) = -t\,c^\top x - \sum_i \log x_i \quad\text{subject to}\quad Ax = b.$$ + +Small $t$: the log term dominates and the minimiser sits deep inside. Large $t$: the objective +dominates and the minimiser approaches the optimal corner. `T0` is where the path starts and `MU` +how much $t$ grows each time; both are knobs. +""") +code(r''' +T0 = 0.001 +MU = 2.0 +t = T0 + +f_now = -t * c @ x - np.log(x).sum() +print(f"t = {t} f_t(start) = {f_now:.4f}") +''') + +md(r""" +## One Newton step + +Newton's method for a smooth problem with equality constraints: build the gradient $g$ and the +Hessian $H$ of $f_t$, then solve one linear system for a step $\Delta x$ that keeps $A\Delta x = 0$ +(so the equations stay satisfied): + +$$\begin{bmatrix} H & A^\top \\ A & 0 \end{bmatrix}\begin{bmatrix}\Delta x\\ w\end{bmatrix} = +\begin{bmatrix} -g \\ 0\end{bmatrix}, \qquad g = -t\,c - 1/x, \qquad H = \mathrm{diag}(1/x^2).$$ + +The Newton decrement $\lambda^2 = \Delta x^\top H \Delta x$ says how far from the minimiser this +point is; half of it estimates how much $f_t$ can still fall. Predict before running: at the +start, far from the centre, will the decrement be large or small, and what should $A\Delta x$ be? +""") +code(r''' +g = -t * c - 1.0 / x +H = np.diag(1.0 / x ** 2) +K = np.block([[H, A.T], [A, np.zeros((2, 2))]]) +dx = np.linalg.solve(K, np.concatenate([-g, np.zeros(2)]))[:4] +lam2 = float(dx @ H @ dx) +print("step", dx.round(4), " A @ step =", (A @ dx).round(12), " decrement^2 / 2 =", round(lam2 / 2, 4)) +''') + +md(r""" +A full Newton step can overshoot past zero, where the logarithm does not exist. So halve the step +until the new point is strictly inside and $f_t$ has dropped by at least a quarter of what the +decrement predicts; that fraction, `ARMIJO`, is a knob of the line search. Predict before running: +will the first, full step survive? +""") +code(r''' +ARMIJO = 0.25 +step = 1.0 +f_x = -t * c @ x - np.log(x).sum() +while (x + step * dx <= 0).any() or (-t * c @ (x + step * dx) - np.log(x + step * dx).sum()) > f_x - ARMIJO * step * lam2: + step *= 0.5 +print(f"ARMIJO {ARMIJO}: step length accepted {step}") +''') + +md(r""" +## Centering, then the path + +Repeat that step until the decrement is negligible: that point is on the central path for this $t$. +Then multiply $t$ by `MU` and center again. The duality gap of a central point is at most (number of +variables) / $t$, so stop once that bound is below `CROSS_METHOD_RTOL`. The two loops repeat the same +lines; nothing is decided inside them that was not decided above. +""") +code(r''' +hand_path = [x.copy()] +newton_steps = 0 +while len(x) / t > tolerance.CROSS_METHOD_RTOL: + for _ in range(50): + g = -t * c - 1.0 / x + H = np.diag(1.0 / x ** 2) + K = np.block([[H, A.T], [A, np.zeros((2, 2))]]) + dx = np.linalg.solve(K, np.concatenate([-g, np.zeros(2)]))[:4] + lam2 = float(dx @ H @ dx) + if lam2 / 2 < tolerance.LINALG_ATOL: + break + step = 1.0 + f_x = -t * c @ x - np.log(x).sum() + while (x + step * dx <= 0).any() or (-t * c @ (x + step * dx) - np.log(x + step * dx).sum()) > f_x - ARMIJO * step * lam2: + step *= 0.5 + x = x + step * dx + newton_steps += 1 + hand_path.append(x.copy()) + t *= MU + +final = hand_path[-1] +print(f"{len(hand_path) - 1} centerings, {newton_steps} Newton steps, final t = {t / MU:.3g}") +print("first centered point", dict(zip(names, hand_path[1].round(3).tolist()))) +print("last point ", dict(zip(names, final.round(6).tolist())), f" objective {c @ final:.6f}") +''') + +md(r""" +## The picture + +The feasible region, the simplex's corners, and the barrier's iterates. Predict the shape of the +path before you look: straight at the optimum, or curving? +""") +code(r''' +import matplotlib.pyplot as plt + +region = np.array([[0, 0], [0, 20], [24, 8], [30, 0], [0, 0]]) # the four feasible corners +path_xy = np.array([[p[0], p[1]] for p in hand_path]) +plt.figure(figsize=(6, 4.2)) +plt.plot(region[:, 0], region[:, 1], "k-", lw=1.5, label="feasible region") +plt.plot([0, 0, 24], [0, 20, 8], "s--", color="#7A4E2D", ms=8, mfc="white", label="simplex: corner to corner") +plt.plot(path_xy[:, 0], path_xy[:, 1], "o-", color="#1F4E79", ms=4, label="barrier: central path") +plt.xlabel("x1") +plt.ylabel("x2") +plt.legend(loc="upper right", fontsize=8) +plt.show() +print(f"Figure: inside the four-sided region, the simplex goes from (0, 0) up to (0, 20) and across to " + f"(24, 8); the barrier starts at (1, 1), jumps to ({path_xy[1, 0]:.1f}, {path_xy[1, 1]:.1f}) near the " + f"middle, and curves in to (24, 8) without touching an edge until the end.") +''') + +md(r""" +## A solver's barrier, for comparison + +Gurobi's barrier (`Method=2`) normally finishes with a *crossover* to the exact corner. Turn +crossover off and it reports where its own interior path stopped. Predict: how close to the +corner will that be? +""") +code(r''' +m = gp.Model("barrier check", env=env) +m.Params.Method = 2 +m.Params.Crossover = 0 +xg = m.addVars(lp.variables, name="x") +m.addConstrs((lp.row_expr(r, xg) <= lp.b[r] for r in lp.rows), name="row") +m.setObjective(gp.quicksum(lp.c[j] * xg[j] for j in lp.variables), GRB.MAXIMIZE) +m.optimize() +gurobi_z = m.ObjVal +print(f"Gurobi barrier, no crossover: x1 {xg['x1'].X:.6f} x2 {xg['x2'].X:.6f} z {gurobi_z:.6f}" + f" iterations {m.BarIterCount}") +''') + +md(r""" +--- + +# Now the streamlined version + +The same method, once, in `orteach.simplex.barrier_path` (with `T0` and `MU` passed in, so the check +covers them), and the simplex's last corner from `tableau_path` to compare the ends. +""") +code(r''' +from orteach import simplex as sx +from orteach.tolerance import AGREEMENT_RTOL, CROSS_METHOD_RTOL, rel_diff + +pkg_path = sx.barrier_path(lp, X0, t0=T0, mu=MU) +simplex_end = sx.tableau_path(lp)[-1] +print(f"package: {len(pkg_path) - 1} centerings, last point ({pkg_path[-1]['x1']:.6f}, {pkg_path[-1]['x2']:.6f})") +print(f"simplex optimum ({simplex_end.x['x1']:.4f}, {simplex_end.x['x2']:.4f}) z {simplex_end.objective:.4f}") +''') + +md(r""" +## The agreement assertion + +Every iterate, hand-built against the package, to `AGREEMENT_RTOL`: same method, same knobs, same +arithmetic. Then the two cross-method claims, each to `CROSS_METHOD_RTOL` because a barrier stops +near the corner rather than on it: the barrier's end against the simplex optimum, and Gurobi's. +""") +code(r''' +assert len(pkg_path) == len(hand_path), "different number of centerings" +checks = [] +for k, (h, p) in enumerate(zip(hand_path, pkg_path)): + for j, name in enumerate(names): + checks.append((f"iterate {k} {name}", h[j], p[list(p)[j]])) +worst = max(rel_diff(h, k) for _, h, k in checks) +print(f"{len(checks)} iterate comparisons") +assert worst < AGREEMENT_RTOL, f"notebook and package disagree by {worst:.2e}" +print(f"notebook and package agree to {worst:.1e}") + +ends = [("barrier end vs simplex", c @ final, simplex_end.objective), ("Gurobi barrier vs simplex", gurobi_z, simplex_end.objective)] +for name, a, b_ in ends: + print(f" {name:28} {a:.6f} vs {b_:.6f} rel {rel_diff(a, b_):.1e}") +assert max(rel_diff(a, b_) for _, a, b_ in ends) < CROSS_METHOD_RTOL, "the methods end in different places" +''') + +md(r""" +--- + +## Where to take this next + +- Set `MU` to 10 and re-run. How many centerings now, how many Newton steps, and what happens to + the picture? +- Start at $x_1 = 25,\ x_2 = 1$. Is that inside? What does the path do? +- Print the gap bound (number of variables over $t$) next to the true gap ($1360 - c^\top x$) at + each centering. How loose is the bound? +""") + +nb = {"cells": cells, "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, + "language_info": {"name": "python", "version": "3.13"}}, "nbformat": 4, "nbformat_minor": 5} +os.makedirs(os.path.dirname(OUT), exist_ok=True) +with open(OUT, "w", encoding="utf-8") as f: + json.dump(nb, f, indent=1, ensure_ascii=False) + f.write("\n") +print("wrote %s (%d cells)" % (OUT, len(cells))) diff --git a/tools/seeds/seed_simplex.py b/tools/seeds/seed_simplex.py new file mode 100644 index 0000000..6083f86 --- /dev/null +++ b/tools/seeds/seed_simplex.py @@ -0,0 +1,320 @@ +"""Seed for the tableau simplex notebook (02). Writes the notebook without outputs; execute it afterwards (README.md here).""" +import json +import os + +REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +OUT = os.path.join(REPO, "notebooks", "02_simplex_and_bases", "simplex_by_hand.ipynb") +cells = [] + + +def md(t): + cells.append({"cell_type": "markdown", "metadata": {}, "source": t.strip("\n").splitlines(keepends=True)}) + + +def code(t): + cells.append({"cell_type": "code", "execution_count": None, "metadata": {}, "outputs": [], + "source": t.strip("\n").splitlines(keepends=True)}) + + +md(r""" +# Corners, bases and the simplex tableau, by hand + +A linear program's optimum sits at a corner of its feasible region. That is a picture with two +variables and a theorem with many, and the simplex method is how the theorem gets used: walk from +corner to neighbouring corner, never downhill, until no neighbour is better. + +This notebook does it on the course's tableau example, by hand, with numpy doing only the +arithmetic. First every corner, feasible or not; then the walk, one pivot at a time. +""") + +md(r""" +## Setup: where the package lives + +This notebook builds everything by hand and then checks it against `orteach`, the package in +`src/`. Run from a clone of the repository, `../../src` is right there. On Colab there is no clone +until this cell makes one, and no `gurobipy` until it installs it. Nothing here needs a secret. +""") +code(r''' +import os, subprocess, sys + +REPO_URL = "https://github.com/sear-labs/teaching-code" +REF = "v1.0.0" # the release this notebook ships in: Colab clones THIS + +try: + import google.colab # noqa: F401 - succeeds only on Colab + ON_COLAB = True +except ImportError: + ON_COLAB = False + +if ON_COLAB: + if not os.path.isdir("/content/teaching-code"): + subprocess.run(["git", "clone", "--quiet", "--depth", "1", "--branch", REF, REPO_URL, "/content/teaching-code"], check=True) + os.chdir("/content/teaching-code/notebooks/02_simplex_and_bases") + subprocess.run([sys.executable, "-m", "pip", "install", "--quiet", "gurobipy>=11,<14"], check=True) + +sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "src"))) +try: + import orteach # noqa: F401 +except ImportError: + raise SystemExit("orteach not found: run this notebook from its own folder inside the repository, " + "so that ../../src exists.") +root = os.path.abspath(os.path.join("..", "..")) +print("package:", os.path.relpath(os.path.dirname(orteach.__file__), root)) +''') + +md(r""" +## Licence setup + +Only the cross-check at the end uses a solver. Nothing here needs a key: `pip install gurobipy` +ships a size-limited licence and this model is tiny. The environment starts silent, so no licence +number lands in an output cell. +""") +code(r''' +import gurobipy as gp +from gurobipy import GRB + +env = gp.Env(empty=True) +env.setParam("OutputFlag", 0) # start silent: the licence banner, and its licence number, stay out of the outputs +try: + from google.colab import userdata + try: + env.setParam("WLSACCESSID", userdata.get("GRB_WLSACCESSID")) + env.setParam("WLSSECRET", userdata.get("GRB_WLSSECRET")) + env.setParam("LICENSEID", int(userdata.get("GRB_LICENSEID"))) + licence = "Colab Secrets (WLS)" + except (userdata.SecretNotFoundError, userdata.NotebookAccessError): + licence = "the size-limited licence pip ships" # no key needed; see the note above +except ImportError: + licence = "local gurobi.lic" +env.start() +print("licence:", licence) +''') + +md(r""" +## The LP, and its standard form + +Two products, two resources: maximise $40x_1 + 50x_2$ subject to $x_1 + 2x_2 \le 40$ and +$4x_1 + 3x_2 \le 120$. It is a table in `data/raw/`, read by the same loader the duality notebook +uses. + +The simplex method works on equations, so each `<=` row gets a slack variable, $s_1$ and $s_2$: +how much of that resource is left over. Two equations, four unknowns. +""") +code(r''' +import numpy as np +from orteach.duality import load_lp + +lp = load_lp("lp_simplex_40_50.csv") +names = ["x1", "x2", "s1", "s2"] +A = np.array([[lp.A["c1", "x1"], lp.A["c1", "x2"], 1.0, 0.0], + [lp.A["c2", "x1"], lp.A["c2", "x2"], 0.0, 1.0]]) +b = np.array([lp.b["c1"], lp.b["c2"]]) +c = np.array([lp.c["x1"], lp.c["x2"], 0.0, 0.0]) +print("A =\n", A, "\nb =", b, "\nc =", c) +''') + +md(r""" +## Every corner is a choice of basis + +Pick two of the four columns to be **basic**, set the other two to zero, and solve the two +equations for the basic pair. Every corner of the feasible region is one such choice. The converse +fails: some choices give a point with a negative variable, which is a corner of the lines but not of +the region. + +There are $\binom{4}{2} = 6$ choices. Predict before running: how many are feasible, and which is +best? +""") +code(r''' +from itertools import combinations + +corners = [] +for basis in combinations(range(4), 2): # the same three lines for every choice + x = np.zeros(4) + x[list(basis)] = np.linalg.solve(A[:, basis], b) + corners.append((basis, x, bool((x >= 0).all()), float(c @ x))) + +print(f"{'basic':12} {'x1':>7} {'x2':>7} {'s1':>7} {'s2':>7} feasible objective") +for basis, x, ok, z in corners: + print(f"{names[basis[0]] + ', ' + names[basis[1]]:12} " + " ".join(f"{v:7.2f}" for v in x) + f" {ok!s:8} {z:9.2f}") +''') + +md(r""" +Enumerating is fine for six. With 50 variables and 30 constraints there are 80 columns and +$inom{80}{30}$ choices, about $9 imes 10^{21}$. +The simplex method visits a handful of them, always moving to a neighbour that is no worse. + +## The tableau + +The objective becomes a row too: $z - 40x_1 - 50x_2 = 0$. Row 0 is that equation, rows 1 and 2 +are the constraints, the last column is the right-hand side. The slacks are the starting basis, +which is the corner at the origin. +""") +code(r''' +T = np.zeros((3, 5)) +T[0, :4] = -c + 0.0 # + 0.0: a printed -0.00 becomes 0.00 +T[1:, :4] = A +T[1:, 4] = b +basis = [2, 3] # s1, s2 + +print(" x1 x2 s1 s2 rhs") +for label, row in zip(["z"] + [names[j] for j in basis], T): + print(f"{label:4}" + "".join(f"{v:8.2f}" for v in row)) +''') + +md(r""" +## First pivot + +**Entering:** a negative number in row 0 means raising that variable raises $z$. Take the most +negative. **Leaving:** raise the entering variable until some basic variable hits zero; the ratio +of right-hand side to the entering column, over rows where that column is positive, says which +hits zero first. Predict both before running. +""") +code(r''' +enter = int(np.argmin(T[0, :4])) +ratios = [T[i, 4] / T[i, enter] if T[i, enter] > 0 else np.inf for i in (1, 2)] +leave_row = 1 + int(np.argmin(ratios)) +print("entering", names[enter], " ratios", [round(float(r), 2) for r in ratios], " leaving", names[basis[leave_row - 1]]) +''') + +md(r""" +The pivot itself is three row operations: scale the leaving row so the entering column holds a 1 +there, then subtract multiples of it to clear that column from the other two rows. Written out. +""") +code(r''' +T[leave_row] = T[leave_row] / T[leave_row, enter] +T[0] = T[0] - T[0, enter] * T[leave_row] +other = 3 - leave_row # the constraint row that did not leave +T[other] = T[other] - T[other, enter] * T[leave_row] +basis[leave_row - 1] = enter + +print(" x1 x2 s1 s2 rhs") +for label, row in zip(["z"] + [names[j] for j in basis], T): + print(f"{label:4}" + "".join(f"{v:8.2f}" for v in row)) +corner_1 = np.zeros(4) +corner_1[basis] = T[1:, 4] +print("\nnow at", dict(zip(names, corner_1.round(4).tolist())), " z =", T[0, 4]) +''') + +md(r""" +Which corner from the enumeration is this? Is row 0 free of negative numbers yet? + +## Second pivot + +The same two choices, on the new tableau. Predict which variable enters and which leaves. +""") +code(r''' +enter = int(np.argmin(T[0, :4])) +ratios = [T[i, 4] / T[i, enter] if T[i, enter] > 0 else np.inf for i in (1, 2)] +leave_row = 1 + int(np.argmin(ratios)) +print("entering", names[enter], " ratios", [round(float(r), 2) for r in ratios], " leaving", names[basis[leave_row - 1]]) + +T[leave_row] = T[leave_row] / T[leave_row, enter] +T[0] = T[0] - T[0, enter] * T[leave_row] +other = 3 - leave_row +T[other] = T[other] - T[other, enter] * T[leave_row] +basis[leave_row - 1] = enter + +print("\n x1 x2 s1 s2 rhs") +for label, row in zip(["z"] + [names[j] for j in basis], T): + print(f"{label:4}" + "".join(f"{v:8.2f}" for v in row)) +corner_2 = np.zeros(4) +corner_2[basis] = T[1:, 4] +print("\nnow at", dict(zip(names, corner_2.round(4).tolist())), " z =", T[0, 4]) +''') + +md(r""" +## Stop + +No negative number is left in row 0, so no neighbouring corner is better: this corner is optimal. +Row 0 also holds two more numbers under the slacks. Compare them with the duals the duality +notebook in `03` reads off a solver: what do they price? +""") +code(r''' +print("row 0 nonnegative:", bool((T[0, :4] >= 0).all())) +hand_path = [(0.0, 0.0, 0.0), (float(corner_1[0]), float(corner_1[1]), float(c @ corner_1)), + (float(corner_2[0]), float(corner_2[1]), float(c @ corner_2))] +print("path (x1, x2, z):", [tuple(round(v, 4) for v in p) for p in hand_path]) +print("row 0 under s1, s2:", T[0, 2:4]) +''') + +md(r""" +## A solver, for comparison + +Gurobi's own simplex (`Method=0`) on the same table. Predict whether it reports the same corner, +and whether the duals match row 0. +""") +code(r''' +m = gp.Model("simplex check", env=env) +m.Params.Method = 0 +xg = m.addVars(lp.variables, name="x") +rows = {r: m.addConstr(lp.row_expr(r, xg) <= lp.b[r], name=r) for r in lp.rows} +m.setObjective(gp.quicksum(lp.c[j] * xg[j] for j in lp.variables), GRB.MAXIMIZE) +m.optimize() +gurobi_z = m.ObjVal +print(f"Gurobi: x1 {xg['x1'].X:.4f} x2 {xg['x2'].X:.4f} z {gurobi_z:.4f} duals", {r: round(rows[r].Pi, 4) for r in lp.rows}) +''') + +md(r""" +--- + +# Now the streamlined version + +The enumeration and the pivots, once each, in `orteach.simplex`: `basic_solutions` returns every +choice of basis, and `tableau_path` the corners the simplex visits, with the same rules used here +(most negative entry in row 0 enters; smallest ratio leaves; lowest index on a tie). +""") +code(r''' +from orteach import simplex as sx +from orteach.tolerance import AGREEMENT_RTOL, rel_diff + +pkg_corners = sx.basic_solutions(lp) +pkg_path = sx.tableau_path(lp) +print(len(pkg_corners), "bases,", sum(k.feasible for k in pkg_corners), "feasible") +print("path:", [(round(float(k.x["x1"]), 4), round(float(k.x["x2"]), 4), round(k.objective, 4)) for k in pkg_path]) +''') + +md(r""" +## The agreement assertion + +The six bases (each point, its feasibility and its objective), the path walked, and the optimum +against Gurobi's. With no ties anywhere in this tableau, the path is the problem's and not a +tie-break's, so it is compared corner by corner. +""") +code(r''' +checks = [] +assert len(pkg_corners) == len(corners), "different number of bases" +for (basis_h, x_h, ok_h, z_h), k in zip(corners, pkg_corners): + assert ok_h == k.feasible, "feasibility differs at " + str(k.basis) + for j, name in enumerate(names): + checks.append((f"{k.basis} {name}", x_h[j], k.x[list(k.x)[j]])) + checks.append((f"{k.basis} z", z_h, k.objective)) +assert len(pkg_path) == len(hand_path), "different number of pivots" +for (x1, x2, z), k in zip(hand_path, pkg_path): + checks += [("path x1", x1, k.x["x1"]), ("path x2", x2, k.x["x2"]), ("path z", z, k.objective)] +checks.append(("optimum vs Gurobi", hand_path[-1][2], gurobi_z)) + +worst = max(rel_diff(h, k) for _, h, k in checks) +print(f"{len(checks)} comparisons, plus feasibility of every basis") +assert worst < AGREEMENT_RTOL, f"notebook and package disagree by {worst:.2e}" +print(f"notebook and package agree to {worst:.1e}") +''') + +md(r""" +--- + +## Where to take this next + +- The slides' exercise is `lp_wyndor.csv` (max $3x_1 + 5x_2$, three plants). Load it and pivot it + by hand: the tableau has one more row, so each pivot clears two other rows, not one. +- Change the objective to $40x_1 + 80x_2$. Row 0 at the optimum now has a zero under a nonbasic + variable. What does that zero mean about the set of optimal solutions? +- `interior_point.ipynb` in this folder solves the same LP without visiting any corner at all. +""") + +nb = {"cells": cells, "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, + "language_info": {"name": "python", "version": "3.13"}}, "nbformat": 4, "nbformat_minor": 5} +os.makedirs(os.path.dirname(OUT), exist_ok=True) +with open(OUT, "w", encoding="utf-8") as f: + json.dump(nb, f, indent=1, ensure_ascii=False) + f.write("\n") +print("wrote %s (%d cells)" % (OUT, len(cells)))