Gurobi / gurobipy-pandas

Convenience wrapper for building optimization models from pandas data
https://gurobipy-pandas.readthedocs.io
Apache License 2.0
92 stars 15 forks source link

When assigning attributes of variables in df from data in df, the indices must align exactly #35

Closed rluce closed 1 year ago

rluce commented 2 years ago
simonbowly commented 2 years ago

A good example where this would help users fail fast-and-early in modelling is time-period based models which require correct alignment via pd.Dataframe.shift. We don't want the API trying to guess what's going on, we should expect an exact alignment.

simonbowly commented 2 years ago

Secondly, users can modify a subset of variables by slicing them out, rather than trying to align a partial index, e.g.:

x.loc[4, :].grb.Obj = 3.0
simonbowly commented 1 year ago

Fixed, the user must use a correctly aligned series with no missing values when setting attributes.

Dr-Irv commented 1 year ago

Fixed, the user must use a correctly aligned series with no missing values when setting attributes.

But if you had a Series named s with decision variables, could you do s.ub = 10 to set the upper bounds of all of the variables in the series to 10?

That should be supported, and then it's probably not right to say that you have to use a "correctly aligned series" - better to say "correctly aligned series or constant"

simonbowly commented 1 year ago

Yes, setting all attributes to a constant is already possible. This issue refers specifically to the case when users are assigning to attributes using a series.