Indicator day of week
OngoingHi everyone!
I am using a forecasting model and want to code the following:
mu is a coefficient of I. V is the Day of the week (V: = {Mon, Tue, ..., Sun}). I(Φ(t)=v) is the indicator function and Φ(t) is a function returning the day of the week corresponding to t. So, my question is how I can code I(Φ(t)=v) in Python with the GUROBI package. I wrote the following code, but I am not sure about it.
day_indicator = model.addVar(obj=0, vtype=gp.GRB.BINARY, name="day_indicator")
def Phi(t):
return days_of_week[t % 7]
sum(mu0[beta, v] * day_indicator for v in range(a) if Phi(t) == days_of_week[v])
Thank you in advance!
0

Hi Vida,
I think there is probably a better way of achieving what you want.
sum(mu0[beta, v] * day_indicator for v in range(a) if Phi(t) == days_of_week[v])
Where has t come from here? It is not defined in your code snippet.
 Riley
0 
Hi Riley,
t refers to each period (each day) in the planning horizon, p=20, and beta refers to the product in b=4.
Vida
0
Please sign in to leave a comment.
Comments
2 comments