Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an MVar-backed extension array #49

Open
simonbowly opened this issue Oct 23, 2022 · 1 comment
Open

Implement an MVar-backed extension array #49

simonbowly opened this issue Oct 23, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@simonbowly
Copy link
Member

The pieces are all there for this in gurobipy v10 and since everything would be a 1D operations performance should be very good. We would only enable the extension for gurobipy>=10, and would likely want a way to disable it in case unsupported pandas operations come up.

A tricky part would be name generation:

  • For variables, we get this for free from .addVars, but .addMVar can only create names for dense numeric indexes, so names would need to be created by gurobipy-pandas (not difficult, but possibly slow)
  • For constraints, we already create the names in gurobipy-pandas, but I'm not sure that there is a supported way to feed a list of names when creating MConstrs and MQConstrs.
@simonbowly simonbowly added enhancement New feature or request question Further information is requested labels Oct 23, 2022
@simonbowly
Copy link
Member Author

Put a rough implementation together on the extension-dtype branch. From 6848bc9, with gurobipy 10.0.0b1 (benchmark script creates 300k variables and 100k linear constraints):

> python bench.py 
Gurobi 10.0.0 (beta1) - expires 2022-11-21

===== Without Extension =====
                   x                  y                  z                     c                      lhs sense  rhs
0  <gurobi.Var x[0]>  <gurobi.Var y[0]>  <gurobi.Var z[0]>  <gurobi.Constr c[0]>  x[0] + y[0] + -1.0 z[0]     <  0.0
1  <gurobi.Var x[1]>  <gurobi.Var y[1]>  <gurobi.Var z[1]>  <gurobi.Constr c[1]>  x[1] + y[1] + -1.0 z[1]     <  0.0

===== With Extension =====
                   x                  y                  z                   c                      lhs sense  rhs
0  <gurobi.Var x[0]>  <gurobi.Var y[0]>  <gurobi.Var z[0]>  <gurobi.Constr R0>  x[0] + y[0] + -1.0 z[0]     < -0.0
1  <gurobi.Var x[1]>  <gurobi.Var y[1]>  <gurobi.Var z[1]>  <gurobi.Constr R1>  x[1] + y[1] + -1.0 z[1]     < -0.0

===== Create 100000 linear constraints =====
Without Extension: 4.58
With Extension:    1.13

As noted above, we get default constraint names. But the 4x speedup looks promising already (and no, the time spent generating names is not significant in the test).

@simonbowly simonbowly removed the question Further information is requested label Oct 27, 2022
@simonbowly simonbowly self-assigned this Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant