Skip to content

Speed up constant * Expr#1185

Open
Zeroto521 wants to merge 8 commits intoscipopt:masterfrom
Zeroto521:expr/__mul__
Open

Speed up constant * Expr#1185
Zeroto521 wants to merge 8 commits intoscipopt:masterfrom
Zeroto521:expr/__mul__

Conversation

@Zeroto521
Copy link
Contributor

As the title. This pr is 1.47x faster than the master branch.

  • Optimized before: 6.5767 seconds
  • Optimized after: 4.4400 seconds
from timeit import timeit

from pyscipopt import Model


m = Model()

n = 1000
x = m.addMatrixVar(n)
e = x.sum()

number = 100_000
cost = timeit(lambda: e * -1.5, number=number)
print(
    f"Cost of multiplying an expression with a number over {number} runs: {cost:.4f} seconds"
)

Loading
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.

3 participants