Skip to content

Clarify scipy linprog transformation description#742

Open
Zhengyizhe0209-arch wants to merge 2 commits into
QuantEcon:mainfrom
Zhengyizhe0209-arch:patch-2
Open

Clarify scipy linprog transformation description#742
Zhengyizhe0209-arch wants to merge 2 commits into
QuantEcon:mainfrom
Zhengyizhe0209-arch:patch-2

Conversation

@Zhengyizhe0209-arch
Copy link
Copy Markdown

@Zhengyizhe0209-arch Zhengyizhe0209-arch commented May 18, 2026

Addresses the first part of #599.

This PR makes the description of scipy.optimize.linprog more precise by noting that SciPy transforms the problem into standard form internally after presolve.

Clarifies that SciPy transforms the problem into standard form internally after presolve.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for taupe-gaufre-c4e660 ready!

Name Link
🔨 Latest commit 6317207
🔍 Latest deploy log https://app.netlify.com/projects/taupe-gaufre-c4e660/deploys/6a1435c652170c00088eec98
😎 Deploy Preview https://deploy-preview-742--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.

@HumphreyYang
Copy link
Copy Markdown
Member

Many thanks @Zhengyizhe0209-arch! It's a nice PR.

I think the wording should be a bit more specific because the lecture calls linprog without setting method, so SciPy uses the default method='highs'.

In SciPy, highs is an interface to the HiGHS optimization solver, and it automatically chooses between the HiGHS dual simplex solver and the HiGHS interior-point solver.

Because of this, I would avoid saying that SciPy necessarily converts the problem to standard form by adding slack variables before solving, since that description is mainly tied to the legacy linprog methods.

I think this is also the point that is being raised in #599.

A simpler replacement could be:

SciPy accepts inequality constraints in the form $A_{ub} x \leq b_{ub}$, equality constraints in the form $A_{eq} x = b_{eq}$, and variable bounds.

In this lecture, linprog uses SciPy’s default highs method, which calls the HiGHS optimization solver.

The slack value returned by linprog is a one-dimensional NumPy array whose entries measure the difference $b_{ub} - A_{ub}x$ for each inequality constraint.

Another small comment: you noted that this PR addresses #599, but it only tackles the first part of the issue.

It would be nice to address the entire issue in one PR or explicitly state that it addresses the first or second part of the issue to avoid closing it without fully resolving it.

@Zhengyizhe0209-arch
Copy link
Copy Markdown
Author

Many thanks for the detailed explanation and suggestions!

That makes sense. I agree that my current wording is too broad, especially since linprog uses SciPy’s default method='highs' here and therefore calls the HiGHS solver rather than necessarily following the legacy standard-form/slack-variable transformation description.

I will revise the paragraph to avoid implying that SciPy always converts the problem to standard form by adding slack variables before solving. I will use the simpler wording you suggested, focusing on the accepted constraint forms, the default highs method, and the interpretation of the returned slack values.

I will also update the PR description to say that it addresses the first part of #599 rather than the whole issue.

Thanks again for the helpful review!

Clarifies the description of SciPy's default highs method and the returned slack values.
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.

2 participants