Sample output for A* assignment =============================== PART A: Navigation around campus When using the file map.txt and asking for the best path from "rat" to "rhodes_tower", your program should report something like this: -------------------------------------- Visiting state rat, g=0.0, h=2.8284271247461903, f=2.8284271247461903 Adding library, g=6.0, h=2.0, f=8.0 to the frontier. Adding ohlendorf, g=5.0, h=2.0, f=7.0 to the frontier. Visiting state ohlendorf, g=5.0, h=2.0, f=7.0 Adding rhodes_tower, g=9.0, h=0.0, f=9.0 to the frontier. Visiting state library, g=6.0, h=2.0, f=8.0 Updating path cost for rhodes_tower on the frontier. old was rhodes_tower, g=9.0, h=0.0, f=9.0, new is rhodes_tower, g=8.0, h=0.0, f=8.0 Visiting state rhodes_tower, g=8.0, h=0.0, f=8.0 Goal found. Path cost is 8.0 Path is: rat -> library -> rhodes_tower Number of states expanded: 3 -------------------------------------- You do not need to print all of the status updates as the algorithm is working (as the sample output does above). It's just there to help you debug your program. All that's necessary is the part at the very end: the path cost, the actual best path, and the number of states expanded. Using map2.txt, and asing for the best path from "i" to "a" should yield: ----------------------- Visiting state i, g=0.0, h=4.47213595499958, f=4.47213595499958 Adding f, g=3.0, h=6.324555320336759, f=9.32455532033676 to the frontier. Adding g, g=3.0, h=6.4031242374328485, f=9.403124237432849 to the frontier. Adding d, g=6.0, h=3.0, f=9.0 to the frontier. Adding h, g=2.0, h=4.242640687119285, f=6.242640687119285 to the frontier. Visiting state h, g=2.0, h=4.242640687119285, f=6.242640687119285 Updating path cost for d on the frontier. old was d, g=6.0, h=3.0, f=9.0, new is d, g=5.0, h=3.0, f=8.0 Visiting state d, g=5.0, h=3.0, f=8.0 Adding e, g=12.0, h=5.0990195135927845, f=17.099019513592786 to the frontier. Adding b, g=8.0, h=1.4142135623730951, f=9.414213562373096 to the frontier. Adding c, g=11.0, h=2.23606797749979, f=13.23606797749979 to the frontier. Adding a, g=11.0, h=0.0, f=11.0 to the frontier. Visiting state f, g=3.0, h=6.324555320336759, f=9.32455532033676 Updating path cost for e on the frontier. old was e, g=12.0, h=5.0990195135927845, f=17.099019513592786, new is e, g=9.0, h=5.0990195135927845, f=14.099019513592784 Visiting state g, g=3.0, h=6.4031242374328485, f=9.403124237432849 Visiting state b, g=8.0, h=1.4142135623730951, f=9.414213562373096 Updating path cost for a on the frontier. old was a, g=11.0, h=0.0, f=11.0, new is a, g=10.0, h=0.0, f=10.0 Visiting state a, g=10.0, h=0.0, f=10.0 Goal found. Path cost is 10.0 Path is: i -> h -> d -> b -> a Number of states expanded: 6 ----------------------------------------------- PART B: Best "traveling salesman" tour of campus ------------------------------------------------ For these outputs, I'm not going to give you the intermediate steps of the algorithm as I did above, as that would give away my representation of a "state" and my heuristic. Therefore, the sample runs below always use a heuristic function of h(n) = 0; that is, uniform cost search (Dijkstra's algorithm), so the number of states expanded will be inflated from what (hopefully) your algorithm should be doing. In other words, we know that uniform cost search and A* are both optimal, so they will both get the same answer, but the point is that A* --- using a good heuristic --- should find that answer *faster*, meaning in fewer states expanded. So try to find an (admissible) heuristic that gets that "number of states expanded" number as low as possible, while still being fast! Hint: the heuristic you use can do some calculation of its own that can be more sophisicated than just a distance lookup. You can also do some pre-processing before the A* algorithm begins if you want, if that will help your heuristic. When asked to use map.txt, start at "rat" and find the best tour that visits "rhodes_tower" and "ohlendorf" and returns to "rat", here's what my program did: (remember that the intermediate buildings may be visited in any order, as long as you start and end at the rat). Also note that your algorithm may find a different "best tour" as long as it's the same total path cost! For instance, for the first sample run below, you could just reverse the order of the tour and it would be fine. --------------------------------------- Goal found. Path cost is 17.0 Best tour: [rat, ohlendorf, rhodes_tower, library, rat] Number of states expanded: 11 --------------------------------------- When asked to use map2.txt, start at "i" and find the best tour that visits "i" and returns to "a," my program says: ----------------------------------- Goal found. Path cost is 20.0 Best tour: [i, h, d, b, a, b, d, h, i] Number of states expanded: 13 ----------------------------------- Note that this is the example we did in class, of finding the best *path* from i -> a, and so the best tour just returns on the same path back to a. When asked to use map2.txt, start at "f" and find the best tour that visits "h," "e," and "g" and returns to "f," my program gives: ---------------------------------------- Goal found. Path cost is 26.0 Best tour: [f, g, i, h, d, e, f] Number of states expanded: 53 ---------------------------------------- And for completeness's sake, here's the best tour that starts at "a" and visits every other location: ------------------------------------------------- Goal found. Path cost is 40.0 Best tour: [a, b, d, h, i, g, f, e, d, c, a] Number of states expanded: 547 -------------------------------------------------