Problem of m travelling salesmen (TSP) in Sage. [Linear programming] [closed]

asked 2019-06-03 22:24:32 +0200

anonymous user


updated 2019-06-04 15:37:55 +0200

I have to solve problem of m TSP's by linear programming. Distances are euclidean, so one of good solutions is when only one salesman visits all the cities. This is the solution i get when running that program (start city is city number 8, so it is 7th in sage cause we count from 0):

This is link to my program in Cocalc [comments are in Polish]:

  • (

After running this, i get solution with 1 salesman. However, if in two constraint in for I change <=2 to ==2; that change requires putting 2 salesmen on the battlefield. However, my program still does solution with only one. Why? In another worksheet I did also with 3, and also I got only 1 salesman when doing ==3 instaed of <=3 in constraints. I program in Cocalc, not in SageMath installed on PC.

By the way, that forum has extremely annoying captcha - I spent 10 minutes doing it, bcs it always was saying that i picked wrong images....

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by tmonteil
close date 2019-06-04 17:27:16.401168


Yes, i see. Ive just made new link.

MaciejFicek gravatar imageMaciejFicek ( 2019-06-04 15:38:17 +0200 )edit

Ok, it seems like i solved my problem. I should have written 'a!=coords[7]" instead of 'a!=7' etc. Now i have 2 salesmen or more if I want :)

MaciejFicek gravatar imageMaciejFicek ( 2019-06-04 16:32:09 +0200 )edit