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)
#Constraint1
for i in I:
m.addConstr(quicksum(X[i,j] for j in J) <= 1)
#Constraint2
for j in J:
m.addConstr(quicksum(X[i,j] for i in I) >= 1)
0

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
Please sign in to leave a comment.
Comments
1 comment