Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

Hello, i want to ask you a question. 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 get when running that program (start city is city number 8, so it is 7th in sage cause w count from 0):

This is link to my program in Cocalc [commentaries are in Polish]: (i had to do space in link bcs i dont have forum points at all); ht tps://cocalc.com/share/88eb1fdd-546a-48ea-80b3-c63b047ad

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....

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

Hello, i want to ask you a question. 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 w we count from 0):

This is link to my program in Cocalc [commentaries [comments are in Polish]: (i had to do space in link bcs i dont have forum points at all); ht tps://cocalc.com/share/88eb1fdd-546a-48ea-80b3-c63b047ad

Polish]:

  • https://cocalc.com/share/88eb1fdd-546a-48ea-80b3-c63b047ad

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....

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

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://cocalc.com/share/88eb1fdd-546a-48ea-80b3-c63b047adhttps://share.cocalc.com/share/88eb1fdd-546a-48ea-80b3-c63b047adfa8/kopiasage.ipynb?viewer=share

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....