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.

Optimize LinExpr multiplication by one or zero

See original GitHub issue

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:closed
  • Created 3 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
h-g-scommented, May 15, 2020

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.

0reactions
bonellicommented, May 23, 2020

release 1.9.0 resolve this issue for me, I’d close it

Read more comments on GitHub >

github_iconTop 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 >

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