# How to deal with hourly and annually constraints in Pyomo?

I am wondering whether it is possible to create constraints over years and hours at the same time in Pyomo.

For example, my current time variable is:

model.T = pyo.RangeSet(len(hourly_data.index))


However, this does not allow me to distinguish between hours and years. I do have a timestamp variable, that contains the date and the time. So, I thought perhaps I could do:

model.T2 = pyo.Set(initialize=hourly_data.DateTime)


Now the problem comes on how to manipulate this TimeStamp object. Consider that the parameters are given and the variables are outputs from the solver. Let's first assume that our objective function is a maximisation function. We would like to create the following constraint:

Get the maximum water used, in normal circumstances, if we would like to get the maximum water usage of during all hours, we can do:

model.c_maxWater = pyo.ConstraintList()
for t in model.T:
model.maxWater)


With a penalty in the objective function associated with model.maxWater. The problem becomes what if we want to penalise every year differently, because we have different water costs? I can imagine that our constraint would be somewhat like:

model.c_maxWater = pyo.ConstraintList()
for t in model.T2:

My problem is: how can I associate the t variable with certain years y. One index is hourly (in this case the t and the other is annually (y)?
• I am not sure understand your question as well but, what are you looking for is something like this? $\sum_{t=1}^{t=365}\ waterUsage(t) \leq maxWater(y), \quad \ y\in Y$ Jun 2 at 12:23