Help implementing a weird model notation
AnsweredHey guys, I recently came across this model notation and I am having a hard time understanding and implementing it in Gurobi.
[\\sum_{i,t:i.GG=1\wedge i.O=b}^{}x_{jit}\ge5 \forall j,b\]
How do I "understand" the sum? Do the equations have to be fulfilled for both inidzes or only for t?
My try looks like this:
for j in J:
for b in B:
model.addConstr(gp.quicksum(x[j,i,t] for t in T if GG[i] == 1 and O[i] == b for i in I if GG[I] == 1 and O[I] == b) <= 5)
0
-
Official comment
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 Lorenz,
The logical operator \(\wedge\) represents conjunction, i.e., the and condition. So, the expression \(\sum_{i,t:i.GG=1\wedge i.O=b}\) means summing over i,t such that i.CG=1 and i.O=b. There are no checks for the index t in this condition.
The constraint \[\sum_{i,t:i.GG=1\wedge i.O=b}x_{jit} \geq 5 \quad \forall j,b \] can be modelled as
m.addConstrs((gp.quicksum(x[j,i,t] for i in I for t in T if GG[i] == 1 and O[i] == b) >= 5 for j in J for b in B), name="test")
Best regards,
Simran0
Post is closed for comments.
Comments
2 comments