I am trying to define an if statement that assigns zero to the variables corresponding to the elements in the cost matrix that are zero.
every row in the matrix cost shows the units transferred from A to other nodes and every column shows the units transferred to A
cost = np.array([[0,6,4,3,0],[6,0,2,5,2],[4,2,0,0,7],[3,5,0,0,0],[0,2,7,0,0]])
variable x shows the units that are transfered on each edge
x = cp.Variable((5,5) , nonneg = True)
I have tried defining a constraint based on for loops and if statements but I cannot insert the constraint into the constraint section of the cvxpy.Problem.
every row in the matrix cost shows the units transfered from A to other nodes and every column shows the units transfered to A
cost = np.array([[0,6,4,3,0],[6,0,2,5,2],[4,2,0,0,7],[3,5,0,0,0],[0,2,7,0,0]])
variable x shows the units that are transfered on each edge
x = cp.Variable((5,5) , nonneg = True)
the result would include no errors.
Aucun commentaire:
Enregistrer un commentaire