Traveling Salesman Problem Without Return

18 Ansichten (letzte 30 Tage)
Jake Smith
Jake Smith am 17 Jan. 2019
Kommentiert: Walter Roberson am 24 Jul. 2021
I've been looking at the traveling salesman problem with the code provided by MATLAB here:
While I understand most of the content, I'm wondering if there is a variation that can be implemented that doesn't form a complete loop after the subtours have been removed, but is still optimized for distance.
In other words, what can be changed in the existing code so there is no return to a "start" point after the last point has been reached?
  1 Kommentar
Walter Roberson
Walter Roberson am 17 Jan. 2019
That is a bit tricky in linear programming. You would be trying to program the conditions that:
  • exactly one object has an in-degree of 0
  • all other objects have an in-degree of exactly 1
  • exactly one object has an out-degree of 0
  • all other objects have an out-degree of exactly 1
You can give constraints such as the sum of the in-degree over all nodes is (nodes-1) and you can give constraints such as the in-degree of each node is exactly 1, but ... hmmm...
You can add constraints that the in-degree of each node is either 0 or 1 (>=0 and <=1) , and that the out-degree of each node is either 0 or 1, and you can add constraints that the sum of the in degrees is (nodes-1) and the sum of the out degrees is (nodes-1) .
But at the moment, there would still seem to be the loophole that it could end up creating a tour of all but one of the nodes and leaving that other node isolated. The in-degree of all of the nodes in the tour would be 1, and the out-degree of all of the nodes in the tour would be 1, and the in-degree of the isolated node would be 0, and the out-degree of the isolated node would be 0, and the total in-degree would be (nodes-1) and the total out-degree would be (nodes-1). The equality and inequality constraints would be satisfied. Ah, but if you forced the total degree for each node to be >= 1 and <= 2 then that would eliminate this possibility and by the pigeon-hole principle you would have to get a path instead of a tour.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Iuliu Ardelean
Iuliu Ardelean am 15 Jul. 2021
Bearbeitet: Iuliu Ardelean am 16 Jul. 2021
Hi
If you know your start and end points, and your graph is not directed:
start_idx = 1; % make node 1 start point
end_idx = 2; % make node 2 end point
constr2trips = optimconstr(nStops,1);
for stop = 1:nStops
whichIdxs = outedges(G,stop); % Identify trips associated with the stop
constr2trips(stop) = sum(trips(whichIdxs)) == 2;
end
whichIdxs = outedges(G, start_idx);
constr2trips(start_idx) = sum(trips(whichIdxs)) == 1;
whichIdxs = outedges(G, end_idx);
constr2trips(end_idx) = sum(trips(whichIdxs)) == 1;
tsp.Constraints.constr2trips = constr2trips;
  2 Kommentare
Iuliu Ardelean
Iuliu Ardelean am 23 Jul. 2021
Bearbeitet: Iuliu Ardelean am 23 Jul. 2021
If your graph is directed, some modifications are necessary.
You will need to create a digraph.
Then, for constraints, set inedges and outedges of each point to either 0 or 1, very similar to the not directed graph example above.
Walter Roberson
Walter Roberson am 24 Jul. 2021
See my description https://www.mathworks.com/matlabcentral/answers/440292-traveling-salesman-problem-without-return#comment_661629 of why setting in-degree and out-degree by themselves are not enough.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by