0

I was solving the TSP and I got this error : "OptimizeWarning: A_eq does not appear to be of full row rank. To improve performance, check the problem formulation for redundant equality constraints. TSP_res = linprog(c=TSP_c, A_eq=TSP_A_eq, b_eq=TSP_b_eq, bounds=bounds, method='simplex')"

These are my constraints : (d being a distance matrix...)

n = len(d)
E = [[i, j] for i in range(n) for j in range(n)]

TSP_A_eq = []

for k in range(n) :
    TSP_A_eq.append([1 if i == k and k != j else 0 for [i, j] in E]) # leaving edges
    TSP_A_eq.append([1 if k == j and i != k else 0 for [i, j] in E]) # entering edges

for i in range(n) :
    TSP_A_eq.append([1 if i == j else 0 for [i,j] in E]) # no edge (i, i)

TSP_c = [d[i][j] for [i, j] in E]
TSP_b_eq = [1] * (2 * n) + [0] * n
bounds = [(0, 1)] * (n * n)

TSP_res = linprog(c=TSP_c, A_eq=TSP_A_eq, b_eq=TSP_b_eq, bounds=bounds, method='simplex')

I tried printing each row in TSP_A_eq. The rank was 20 and the 10 constraints to eliminate (i,i) edges seemed to be all the same. So I deleted the loop, tried changing the loops variable i into k... same solution but still the same warning.

NEWO-o
  • 1
  • 4

0 Answers0