Optimize LinExpr multiplication by one or zero
See original GitHub issueIssue Description
I’m working on a problem that is mathematically defined with a couple of big sparse binary matrices, I’m using quite a lot of python-mip binary variables and I collected them into numpy tensors to have some syntactic sugar and matrix operations over them.
It’s very nice but very very slow, and it seems to me that with some basic optimization it could perform much better, notably to the LinExpr.__mul__()
function.
Would it be reasonable to have the special cases for multiplication by 1 or 0 to speed up this kind of use?
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
GurobiError: Invalid argument to LinExpr multiplication
The error occurs because you are trying to multiply (and add) a list of values with an optimization variable while constructing a constraint....
Read more >does python multiplicative expression evaluates faster if finds ...
Yes, probably multiply won't actually do the multiplication if an operand is zero, currying a zero from the beginning is better. I answered...
Read more >Classes - Python MIP Documentation - Read the Docs
Creates a new constraint (row). Adds a new constraint to the model, returning its reference. Parameters. lin_expr (mip.LinExpr) – linear expression.
Read more >GurobiError: Invalid argument to LinExpr ... - Google Groups
to Gurobi Optimization. I am using Spyder (Python 2.7). I am getting the following error: GurobiError: Invalid argument to LinExpr ...
Read more >Mixed Integer Linear Programming with Python - Read the Docs
optimization. In the example above, if a feasible solution is available (line 8), variables which have value different from zero are printed ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
a faster LinExpr is the priority but my idea is also to make a available a low level interface to communicate with the solver. With CFFI it is possible to allocate C arrays, which can be directly passed to CBC, for example, this would be a “last resort” for those who want to the maximum performance.
release 1.9.0 resolve this issue for me, I’d close it