TSP (JobSolveStatus.INFEASIBLE_SOLUTION: 3)
Well I'm trying to code de travelling salesman prolem but when a get to the solution part my code prints "JobSolveStatus.INFEASIBLE_SOLUTION: 3" I don't know what's happening, but I leave my code below My df are 20 cities and I'm using cities from Mexico import pandas as pd df = pd.read_excel(open('Mydataframe.xlx','rb'),sheet_name='Hoja1', converters={'n°':int}, index_col=[0]) df df["Coordenadas"]="" df import googlemaps gmaps_key=googlemaps.Client(key="My Api Key") for n in range(len(df)): geocode_resultado=gmaps_key.geocode(df.iloc[n][0]) try: lat=geocode_resultado[0]["geometry"]["location"]["lat"] lon=geocode_resultado[0]["geometry"]["location"]["lng"] df.set_value(n,"Coordenadas",(lat,lon)) except: lat=None lon=None from pandas import ExcelWriter from pandas import ExcelFile write=ExcelWriter('/Users/chico/Desktop/Ahora si lo resuelvo/F.xlsx') df.to_excel(write,'Hoja1', index=False) write.save() df from geopy import distance import numpy as np distancia=[] for n in range(len(df)): for i in range(len(df)): if n!=i: distancia.append(np.round(distance.distance(df.iloc[n][1],df.iloc[i][1]).km, decimals=1)) print(distancia) ciudades=[i for i in range(len(df))] ciudades arcos=[(i,j) for i in ciudades for j in ciudades if i!=j] print(arcos) distancia_arcos={(i,j):distance.distance(df.iloc[i][1],df.iloc[j][1]).km for i,j in arcos} distancia_arcos from docplex.mp.model import Model mdl=Model('TSP-2') x=mdl.binary_var_dict(arcos,name='x') d=mdl.continuous_var_dict(ciudades,name='d') mdl.minimize(mdl.sum(distancia_arcos[i]*x[i] for i in arcos)) for c in ciudades: mdl.add_constraint(mdl.sum(x[(i,j)] for i,j in arcos if i==c)==i,ctname='out_%d'%c) for c in ciudades: mdl.add_constraint(mdl.sum(x[(i,j)] for i,j in arcos if i==c)==i,ctname='in%d'%c) #The rest of the code will be in the comments