How to remove a specific set of constraints from a bigger dictionary of constraints
回答済みI have a constraint dictionary and a list of some infeasible arcs (i,j)
Given that the list PD is part of N.
'''
P = [1,2,3,4] #Pick-up nodes
D = [5,6,7,8] # drop-off nodes, the range function doesnot count the last number
PD = P + D
C = [10,11,12,13,14,15,16,17,18,19,20,21] # all transfer nodes
PDC = PD + C
O = [0,9]
N = O + P + D + C
m.addConstrs((quicksum(x[k,i,j] for j in N for k in K) == 1 for i in PD),'basic')
infeasible_arc4 = [(i, j ) for i in PD for j in PD if e[i] + d[i] + t[i,j] > l[j]]
'''
How to tell gurobi not to consider these infeasible arcs when working on the given constraints
I tried to create a variable to store the constraints as follows:
consts_basic = m.addConstrs((quicksum(x[k,i,j] for j in N for k in K) == 1 for i in PD),'basic')
However, this dictionnary can essentially be indexed by one symbol, for example, consts_basic[2].
To elaborate more, I want to tell gurobi to ignore any x[k,i,j] whenever i,j are found in the list infeasible_arc4
-
正式なコメント
This post is more than three 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 why not try our AI Gurobot?. -
Hi Sabrin,
You could define \(\texttt{infeasible_arc4}\) before you add the constraints and then add an \(\texttt{if}\)-statement to the quicksum. This should be similar to \(\texttt{quicksum(x[k,i,j] for j in N for k in K if (i,j) not in infeasible_arc4)}\).
Best regards,
Jaromił0 -
Thank you Jaromil for your prompt response. I used the if - statement incorrectly. Now, I have applied your recommendations. and the model returns to work again. However, I faced another relevant issue please refer to this post.
Thanks a lot,
Sabreen
0
投稿コメントは受け付けていません。
コメント
3件のコメント