reset password
Author Message
rabbott
Posts: 1649
Posted 16:51 Apr 26, 2020 |

You can now ask that the paths you generate with the two path generator algorithms (greedy and minimum spanning tree) be printed when they are generated.

Rather than try to explain it here, look at the gen_initial_population method, line 288 in ga_tsp.py

As written the system chooses randomly among a random path, a greedy path, or a minimum spanning tree path. (Stubs for the last two exist, but for now they both call random_path. Part of the assignment is for you to write those methods. 

The bottom half of gen_initial_population does the display. It constructs a list of links that include the links for the generated path along with the links for a minimum spanning tree, if that was the approach used for that Individual. It sends those links to draw_links in sim_engine.py. It also sends the (initially empty) set from World.links that is used to display links. draw_links adds the links from the list of links in its first argument one by one to the World.links set. Between each addition, it draws the world, including the links added so far. It also sleeps for about 2/3 seconds between displays. The effect is that the links in the list appear on the screen one by one.

As written, the minimum spanning tree links are shown double-width and in green; the path links are shown in red. (I have written a minimum spanning tree function that you can use.) Feel free to change those arbitrary conventions in your version.

I suggest that you download the entire current version of PyLog to get the required code. (The code that you have already written should fit the stubs as before.)

If you run into problems, post a question on the Forum. (Why do I even bother to suggest this?!)