• Gurobi Staff

Hi Ibrahim,

You did not specify which terms are variables and which are scalar values so I just assumed that $$I,q,$$ and $$d$$ are all variables.
I think what you need can be achieved via the function addVars() and quicksum() with two $$\texttt{for}$$-loops

import gurobipyfrom gurobipy import *model = Model("test")Nc = [0,1,2,3,4]T = [0,1,2,3]I = model.addVars(Nc, T, name="I")q = model.addVars(Nc, T, name="q")d = model.addVars(Nc, T, name="d")for t in T:    for j in Nc:        model.addConstr( - I[j,t] + I[j,0] + quicksum((q[j,l]-d[j,l]) for l in range(0,t+1)) == 0, "myConstr_"+str(t)+"_"+str(j))                       model.write("test.lp")                        model.dispose()

Note that I used the write() function to write a human readable LP file and with that check whether the constructed constraints are indeed correct.

Best regards,
Jaromił

Hi Dr.Jaromil

I got it, Thanks for your time and effort. I really appreciate it