Modeling problem about using variable value for indexing and conditional summation
回答済みDear all,
Please have a look at the example below. This is not programmatically correct, but I want to show the idea and get your thoughts on implementing it in Gurobi.
start_time = {n: t for n, t in the schedule.items()} # dictionary containing action start times at various nodes
tx = m.addVars(nodes, lb=0) # Decision variable takes the duration of activity at each node
cx = m.addVars(time_horizon, vtype=GRB.BINARY) # An activity takes place at time t
Now I want to write a constraint for cx. Nodes is the set of all nodes.
for j in nodes:
start = time[j]
for t in range(start, start + tx[j]):
m.addConstr[cx[t] == 1]
Of course, this does not work because I cannot have a variable for index subsetting like this. But do you have any idea as to how I can make it work? A pseudo-example might be super helpful. Thank you.
0
-
I solved this problem based on the answer given in Adding Consecutive Shifts COnstraint – Gurobi Help Center.
0
サインインしてコメントを残してください。
コメント
1件のコメント