
This is an extra lab for those of you who like classic challenges. It's not that hard but it has more complexity than we have been dealing with in the class so far. You asked for it (and you know who you are).
There is this guy named Phil and his job is restocking Slim Jims in a display at gas stations. The problem is really about how to minimize his travels to all the different gas stations and give him back a route that will optimize this.
So. Generate a random set of gas stations which have distances between them. Let's consider a problem space with 3 nodes.
| A | B | C | |
|---|---|---|---|
| A | 0 | 7 | 6 |
| B | 7 | 0 | 21 |
| C | 6 | 21 | 0 |
The problem is to figure out what is the best route so that Phil restocks all the displays in A, B, and C, without having to visit any one twice with the minimum miles.
For your problem:
Allow the user to input the number of stations as parameter 1.
Find the optimal route and output the total miles.
Use random numbers to generate the distances between the points (you may want to use a seed to test).
Limit the number of cities to about 20 and most likely use brach/bound approach.
This can also be solved with Simulated Annealing.
Consider that the rate of growth of rats is