Skip to content

Rewrite Linear Programming lecture: SciPy-only + duality#771

Merged
jstac merged 1 commit into
mainfrom
rewrite-lp-intro-scipy-dual
Jun 16, 2026
Merged

Rewrite Linear Programming lecture: SciPy-only + duality#771
jstac merged 1 commit into
mainfrom
rewrite-lp-intro-scipy-dual

Conversation

@jstac

@jstac jstac commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Closes #514.

Full rewrite of the Linear Programming lecture (lp_intro), addressing the editorial suggestions in #514.

What changed

Tooling

  • Drop OR-Tools (GLOP) entirely. Everything is now solved with scipy.optimize.linprog (HiGHS), removing the ortools pip install and the parallel two-solver presentation that confused the narrative.

Structure / flow

  • Pose both examples up front. Example 1 (production) is solved graphically, framed explicitly as "we can do this because it's 2-D."
  • Example 2 (investment) is then introduced as a five-variable problem that can't be graphed — motivating a systematic method.
  • Introduce the standard form and matrix formulation.
  • Solve both examples with SciPy. Example 1's solve now explicitly confirms the graphical answer.
  • New Duality section.

Duality (the main gap in the old lecture)
The Overview always promised a primal/dual pairing, but the dual was never developed. Now it is:

  • Derive the dual of the production problem via an "outside investor buying the firm's resources" story.
  • Give the general canonical primal/dual pair.
  • Solve the dual with linprog and observe strong duality (both optimal values = 27.5).
  • State weak and strong duality.
  • Interpret the dual solution (0.625, 0.4375) as shadow prices, and verify the material shadow price by perturbation (relaxing the material constraint 30→31 raises revenue by exactly 0.625).
  • Note that linprog reports shadow prices directly via .ineqlin.marginals.

Other

  • Add a short note on why decision variables are real-valued rather than integer (convex feasible set → tractable).
  • Rewrite both exercise solutions using linprog.

Verification

All code cells were executed via jupytext --to py and run successfully; every numerical result quoted in the prose matches the solver output (production 27.5, investment 141018.24, dual 27.5 / shadow prices (0.625, 0.4375), exercises 23.33 and 297.5).

🤖 Generated with Claude Code

Full rewrite of the Linear Programming lecture addressing the editorial
suggestions in #514.

- Drop OR-Tools (GLOP) entirely; solve everything with scipy.optimize.linprog
  (HiGHS), removing the ortools dependency and the dual-solver presentation.
- Restructure the flow: pose both examples first (Example 1 solved
  graphically, motivating the need for a systematic method on the
  higher-dimensional Example 2), then introduce standard form, then solve
  both with SciPy.
- Add a Duality section: derive the dual of the production problem,
  state weak/strong duality, interpret the dual variables as shadow
  prices, and verify the material shadow price by perturbation.
- Note why we use real-valued (vs integer) decision variables.
- Rewrite both exercise solutions using linprog.

All code cells verified to execute via jupytext.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 16, 2026

Copy link
Copy Markdown

Deploy Preview for taupe-gaufre-c4e660 ready!

Name Link
🔨 Latest commit e14c3c6
🔍 Latest deploy log https://app.netlify.com/projects/taupe-gaufre-c4e660/deploys/6a30abf160896e0008d822be
😎 Deploy Preview https://deploy-preview-771--taupe-gaufre-c4e660.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request June 16, 2026 01:58 Inactive
@jstac jstac merged commit c1e7c63 into main Jun 16, 2026
7 checks passed
@jstac jstac deleted the rewrite-lp-intro-scipy-dual branch June 16, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lp_intro] Editorial Suggestions

1 participant