Skip to content
Discussion options

You must be logged in to vote

With linopy you can group expressions and the sum them up.

You only need a grouper object with maps the single expression to their group.
Then create a constraint (variable * factor) and group it.

groups = timesteps.isocalendar().week
calculation.model.add_constraints(
    (calculation.model['Kessel(Q_fu)|switch_on'] * 1).groupby(groups).sum() <= 1
)

The following groupers are directly available through pd.Datetimeindex:

import pandas as pd

timesteps = pd.date_range('2020-01-01', periods=4000, freq='2h')

print(timesteps.hour)       # Hour component (0-23)
print(timesteps.day)        # Day of month (1-31)
print(timesteps.month)      # Month (1-12)
print(timesteps.year)       # Year
print(t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by FBumann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants