question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: LinearOperator for linprog arguments A_ub and A_eq

See original GitHub issue

Is your feature request related to a problem? Please describe.

The estimation of linear quantile regression can be recast as a linear programming problem with equality matrix

n_samples = X.shape[0]
A_eq = np.concatenate(
                [X, -X, np.eye(n_samples), -np.eye(n_samples)], axis=1
            )

where X is the feature matrix (predict will give X @ coef), see https://github.com/scikit-learn/scikit-learn/blob/0d378913be6d7e485b792ea36e9268be31ed52d0/sklearn/linear_model/_quantile.py#L203-L217.

This could help to save computation time and memory.

Describe the solution you’d like.

I’d like be able to pass a scipy.sparse.linalg.LinearOperator to linprog as argument A_ub and A_eq.

Describe alternatives you’ve considered.

No response

Additional context (e.g. screenshots, GIFs)

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jajhallcommented, Dec 13, 2021

Where would the documentation and examples be?

In the scipy docu of linprog. Something like: “There is no need to formulate a linear programming problem in terms of positive variables. The solvers accept general bounds for x and might even be more efficient this way.”

A further doc improvement could be to say, that highs as well as interior-point, in the end, work on csc matrices.

I see what you mean now. Thanks. Been a productive discussion for me, but I think it’s run its course. Cheers Julian

1reaction
jajhallcommented, Dec 9, 2021

No, HiGHS cannot handle anything other than an actual sparse matrix.

It’s conceivable that the simplex solver could be adapted to handle an abstracted linear operator as a means of obtaining columns of the implied constraint matrix, and performing matrix-vector products. However, a square submatrix of the constraint matrix would have to be formed periodically as an actual sparse matrix, so some overhead comparable to supplying the whole matrix in that form would be inevitable unless the whole matrix has overwhelmingly more columns than rows.

Although it’s an interesting challenge, incorporating it would be a lot of work, for which resources are currently unavailable. Thus, whoever wanted it would have to come up with a lot of cash!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MATLAB linprog - Solve linear programming problems
Set Aeq = [] and beq = [] if no equalities exist. Note. If the specified input bounds for a problem are inconsistent,...
Read more >
linprog (Optimization Toolbox)
linprog. Solve a linear programming problem. where f, x, b, beq, lb, and ub are vectors and A and Aeq are matrices. Syntax....
Read more >
scipy.optimize.linprog — SciPy v1.9.3 Manual
Guess values of the decision variables, which will be refined by the optimization algorithm. This argument is currently used only by the 'revised...
Read more >
How can I get integer solutions with scipy.optimize.linprog?
Following is a python module that includes a function LPmi(.) to solve mixed integer linear programs. It employs the Branch and Bound algorithm ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found