001 package aima.search.map; 002 003 /** 004 * Represents a simplified road map of Romania. The initialization method is 005 * declared static. So it can also be used to initialize other specialized 006 * subclasses of {@link ExtendableMap} with road map data from Romania. Location names, 007 * road distances and directions have been extracted from Artificial 008 * Intelligence A Modern Approach (2nd Edition), Figure 3.2, page 63. The 009 * straight-line distances to Bucharest have been taken from Artificial 010 * Intelligence A Modern Approach (2nd Edition), Figure 4.1, page 95. 011 * 012 * @author R. Lunde 013 */ 014 public class SimplifiedRoadMapOfPartOfRomania extends ExtendableMap { 015 016 public SimplifiedRoadMapOfPartOfRomania() { 017 initMap(this); 018 } 019 020 // The different locations in the simplified map of part of Romania 021 public static final String ORADEA = "Oradea"; 022 public static final String ZERIND = "Zerind"; 023 public static final String ARAD = "Arad"; 024 public static final String TIMISOARA = "Timisoara"; 025 public static final String LUGOJ = "Lugoj"; 026 public static final String MEHADIA = "Mehadia"; 027 public static final String DOBRETA = "Dobreta"; 028 public static final String SIBIU = "Sibiu"; 029 public static final String RIMNICU_VILCEA = "RimnicuVilcea"; 030 public static final String CRAIOVA = "Craiova"; 031 public static final String FAGARAS = "Fagaras"; 032 public static final String PITESTI = "Pitesti"; 033 public static final String GIURGIU = "Giurgiu"; 034 public static final String BUCHAREST = "Bucharest"; 035 public static final String NEAMT = "Neamt"; 036 public static final String URZICENI = "Urziceni"; 037 public static final String IASI = "Iasi"; 038 public static final String VASLUI = "Vaslui"; 039 public static final String HIRSOVA = "Hirsova"; 040 public static final String EFORIE = "Eforie"; 041 042 /** 043 * Initializes a map with a simplified road map of Romania. 044 */ 045 public static void initMap(ExtendableMap map) { 046 // mapOfRomania 047 map.clear(); 048 map.addBidirectionalLink(ORADEA, ZERIND, 71.0); 049 map.addBidirectionalLink(ORADEA, SIBIU, 151.0); 050 map.addBidirectionalLink(ZERIND, ARAD, 75.0); 051 map.addBidirectionalLink(ARAD, TIMISOARA, 118.0); 052 map.addBidirectionalLink(ARAD, SIBIU, 140.0); 053 map.addBidirectionalLink(TIMISOARA, LUGOJ, 111.0); 054 map.addBidirectionalLink(LUGOJ, MEHADIA, 70.0); 055 map.addBidirectionalLink(MEHADIA, DOBRETA, 75.0); 056 map.addBidirectionalLink(DOBRETA, CRAIOVA, 120.0); 057 map.addBidirectionalLink(SIBIU, FAGARAS, 99.0); 058 map.addBidirectionalLink(SIBIU, RIMNICU_VILCEA, 80.0); 059 map.addBidirectionalLink(RIMNICU_VILCEA, PITESTI, 97.0); 060 map.addBidirectionalLink(RIMNICU_VILCEA, CRAIOVA, 146.0); 061 map.addBidirectionalLink(CRAIOVA, PITESTI, 138.0); 062 map.addBidirectionalLink(FAGARAS, BUCHAREST, 211.0); 063 map.addBidirectionalLink(PITESTI, BUCHAREST, 101.0); 064 map.addBidirectionalLink(GIURGIU, BUCHAREST, 90.0); 065 map.addBidirectionalLink(BUCHAREST, URZICENI, 85.0); 066 map.addBidirectionalLink(NEAMT, IASI, 87.0); 067 map.addBidirectionalLink(URZICENI, VASLUI, 142.0); 068 map.addBidirectionalLink(URZICENI, HIRSOVA, 98.0); 069 map.addBidirectionalLink(IASI, VASLUI, 92.0); 070 // addBidirectionalLink(VASLUI - already all linked 071 map.addBidirectionalLink(HIRSOVA, EFORIE, 86.0); 072 // addBidirectionalLink(EFORIE - already all linked 073 074 // distances and directions 075 // reference location: Bucharest 076 map.setDistAndDirToRefLocation(ARAD, 366, 117); 077 map.setDistAndDirToRefLocation(BUCHAREST, 0, 360); 078 map.setDistAndDirToRefLocation(CRAIOVA, 160, 74); 079 map.setDistAndDirToRefLocation(DOBRETA, 242, 82); 080 map.setDistAndDirToRefLocation(EFORIE, 161, 282); 081 map.setDistAndDirToRefLocation(FAGARAS, 176, 142); 082 map.setDistAndDirToRefLocation(GIURGIU, 77, 25); 083 map.setDistAndDirToRefLocation(HIRSOVA, 151, 260); 084 map.setDistAndDirToRefLocation(IASI, 226, 202); 085 map.setDistAndDirToRefLocation(LUGOJ, 244, 102); 086 map.setDistAndDirToRefLocation(MEHADIA, 241, 92); 087 map.setDistAndDirToRefLocation(NEAMT, 234, 181); 088 map.setDistAndDirToRefLocation(ORADEA, 380, 131); 089 map.setDistAndDirToRefLocation(PITESTI, 100, 116); 090 map.setDistAndDirToRefLocation(RIMNICU_VILCEA, 193, 115); 091 map.setDistAndDirToRefLocation(SIBIU, 253, 123); 092 map.setDistAndDirToRefLocation(TIMISOARA, 329, 105); 093 map.setDistAndDirToRefLocation(URZICENI, 80, 247); 094 map.setDistAndDirToRefLocation(VASLUI, 199, 222); 095 map.setDistAndDirToRefLocation(ZERIND, 374, 125); 096 } 097 }