Hungarian Algorithm with Unbalanced Matrix
Awaiting user inputI have an unbalanced matrix and I have added a dummy column,
I have run the code like below, but with these constraints, I didn't get the expected result
Where I need each station (ST) will definitely get 1 person (P) with the lowest value, it's okay if the person didn't get any station.
ST1 ST2 ST3 D
P1 5 3 2 3
P2 6 2 1 9
P3 3 1 6 2
P4 8 4 5 2
#Defining the Variable
X = {}
for i in I:
for j in J:
X[i,j] = m.addVar(vtype= GRB.BINARY)
#Objective Function
m.setObjective(quicksum(durmin[i][j]*X[i,j] for i in I for j in J), GRB.MINIMIZE)
#Constraint-1
for i in I:
m.addConstr(quicksum(X[i,j] for j in J) <= 1)
#Constraint-2
for j in J:
m.addConstr(quicksum(X[i,j] for i in I) >= 1)
0
-
Official comment
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?. -
Could you please elaborate more on the task you are trying to achieve?
What are the sets \(I\) and \(J\)? What is \(\texttt{durmin}\)? What is the expected result? Why would you need to add a dummy column? Is it to guarantee uniqueness of the solution?
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments