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

asked 2019-06-03 15:24:32 -0500

anonymous user

Anonymous

updated 2019-06-04 08:37:55 -0500

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]:

  • https://share.cocalc.com/share/88eb1fdd-546a-48ea-80b3-c63b047adfa8/kopiasage.ipynb?viewer=share (https://share.cocalc.com/share/88eb1f...)

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 10:27:16.401168

Comments

Yes, i see. Ive just made new link.

MaciejFicek gravatar imageMaciejFicek ( 2019-06-04 08:38:17 -0500 )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 09:32:09 -0500 )edit