Indicator day of week
進行中Hi 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
-
正式なコメント
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
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
投稿コメントは受け付けていません。
コメント
3件のコメント