基于贪婪最佳优先搜索和模拟退火算法的悉尼智能地图代理

Intelligent Map Agent in Sydney Based on Greedy Best Priority Search and Simulated Annealing Algorithm

Executive Summary

The main objective of this report is to design a map-intelligent agent that solves the path planning and optimization problem for the city of Sydney. The project covers two key functions: finding the optimal train route between two locations selected by the user and solving the traveler's problem of finding the shortest path through all locations in Sydney from a user-provided starting point. This project focuses on geographic information and path planning problems in the city of Sydney and aims to provide a powerful tool for urban transportation and logistics planning.

By employing the Greedy Best First Search (GBFS) algorithm and Simulated Annealing algorithm, this project successfully applies artificial intelligence techniques to provide users with reliable path planning and optimization solutions. GBFS is used to find the optimal train routes, while Simulated Annealing algorithm solves the complex Travelling Salesman Problem, both providing real value to the city's inhabitants and the industry, both of which provide real value.

The significance of this research is that it demonstrates how AI techniques can be applied to solve urban planning and path optimization problems, promising to improve the transportation and logistics system in the city of Sydney. In addition, the project suggests further improvements to enhance the performance and accuracy of the algorithm, providing a strong foundation for future research and development. Overall, this report aims to use AI algorithms to provide practical information and tools on path planning and optimization for urban planners, transport managers and the logistics industry.

Introduction

In the AT1 search problem task, this study focuses on designing a map intelligent agent. The agent should include two main functions. The first function is to search for the most optimized train route between the two locations selected by the user. The second function is to provide the shortest path to traverse all locations in Sydney from the initial location provided by the user.

Two functions of this intelligent agent are necessary. Due to the fact that passengers may need to go to a place during their travels in Sydney, it is necessary for this intelligent route agent to provide the most optimized route to meet the needs of passengers. Here the intelligent agent will use the Greedy Best First Algorithm (GBFS) from the best-first search techniques family to find the shortest train transfer route between a given two locations. Similarly, for some travelers or specific industries such as postal services, salesman and so on, they may need to start from one location and traverse every location in Sydney. This is a classic Traveler Problem (TSP). In order to achieve this function, the intelligent agent will use simulated annealing algorithm to solve the problem.

Data and Resource

To address this issue, 20 locations were selected for visits in Sydney. Then use Google Maps to find the coordinates of these 20 locations. Since Google Maps uses the WGS-84 coordinate system, it needs to be converted to planar coordinates at a uniform scale to get the data in location_coordinates, as follows.

LocationName

LocationX

LocationY

Hornsby

1097

166

Wahroonga

1114

181

Chatswood

1164

245

Eastwood

1086

242

Burwood

1100

317

TownHall

1178

313

BondiJunction

1212

333

Mascot

1162

363

Marrickville

1141

347

Rockdale

1127

385

Auburn

1042

302

Bankstown

1043

352

Revesby

1038

376

Merrylands

1018

283

Parramatta

1031

261

Blacktown

961

222

Fairfield

990

307

Cabramatta

975

333

Liverpool

962

364

Casula

957

382

location_coordinates table

By querying Google Maps, I can obtain the distance between 20 locations in pairs. Then combine this distance with the location to create a matrix “location_matrix” as follows.

LocationName

Hornsby

Wahroonga

Chatswood

Eastwood

Burwood

TownHall

Hornsby

0

4.2

17.7

17.7

27.8

28.9

Wahroonga

4.2

0

11.8

16.1

23.6

25.4

Chatswood

17.7

11.8

0

13.1

17.8

12

Eastwood

17.7

16.1

13.1

0

14

17

Burwood

27.8

23.6

17.8

14

0

11.8

TownHall

28.9

25.4

12

17

11.8

0

BondiJunction

33.7

27.8

16.6

26.1

16.4

5.7

Mascot

38.6

32.7

19

24.3

12.7

6.9

Marrickville

35.9

30.4

18.9

20.8

7.3

9.5

Rockdale

43.5

39.4

26.5

29.2

11.2

12.5

Auburn

26.9

25.4

21.4

12.6

10.4

21

Bankstown

32.2

28.9

24.8

18.1

10.6

23.6

Revesby

36.4

35.6

38

27.2

14.3

24.3

Merrylands

27.6

30.2

25.7

14.3

14.8

24.6

Parramatta

21.6

20.9

22.2

10.3

15.3

23.7

Blacktown

27.9

27.1

28.7

20

25.5

35.3

Fairfield

32.2

31.6

31.3

22.4

20.2

30

Cabramatta

35.2

37.6

37.4

26

21.4

36.3

Liverpool

46.2

59.9

39.3

31.1

26.5

35

Casula

46.6

61

39.6

33.3

26.8

35.4

location_matrix 1 (km)

LocationName

BondiJunction

Mascot

Marrickville

Rockdale

Auburn

Bankstown

Hornsby

33.7

38.6

35.9

43.5

26.9

32.2

Wahroonga

27.8

32.7

30.4

39.4

25.4

28.9

Chatswood

16.6

19

18.9

26.5

21.4

24.8

Eastwood

26.1

24.3

20.8

29.2

12.6

18.1

Burwood

16.4

12.7

7.3

11.2

10.4

10.6

TownHall

5.7

6.9

9.5

12.5

21

23.6

BondiJunction

0

9.7

11.3

17.4

26.4

29.3

Mascot

9.7

0

5.2

7.7

23.3

20.8

Marrickville

11.3

5.2

0

6.1

17.9

16.8

Rockdale

17.4

7.7

6.1

0

23.6

16.4

Auburn

26.4

23.3

17.9

23.6

0

7.6

Bankstown

29.3

20.8

16.8

16.4

7.6

0

Revesby

0

19.1

11.3

17.4

26.4

29.3

Merrylands

9.7

0

5.2

7.7

23.3

20.8

Parramatta

11.3

5.2

0

6.1

17.9

16.8

Blacktown

17.4

7.7

6.1

0

23.6

16.4

Fairfield

26.4

23.3

17.9

23.6

0

7.6

Cabramatta

29.3

20.8

16.8

16.4

7.6

0

Liverpool

26.6

19.1

17

12.8

12.7

3.7

Casula

29.9

26.7

21.4

31

7.7

15.1

location_matrix 2 (km)

LocationName

Revesby

Merrylands

Parramatta

Blacktown

Fairfield

Cabramatta

Hornsby

36.4

27.6

21.6

27.9

32.2

35.2

Wahroonga

35.6

30.2

20.9

27.1

31.6

37.6

Chatswood

38

25.7

22.2

28.7

31.3

37.4

Eastwood

27.2

14.3

10.3

20

22.4

26

Burwood

14.3

14.8

15.3

25.5

20.2

21.4

TownHall

24.3

24.6

23.7

35.3

30

36.3

BondiJunction

26.6

29.9

30.8

46.4

39

43.4

Mascot

19.1

26.7

27.1

37.3

31.3

34

Marrickville

17

21.4

21.9

33

27.1

30.4

Rockdale

12.8

31

31.3

40.2

27.5

30

Auburn

12.7

7.7

7.6

22.4

7.6

12.1

Bankstown

3.7

15.1

14.3

27.5

9.9

13.9

Revesby

0

17.5

19.1

31.6

13.4

14.9

Merrylands

17.5

0

3.6

15.6

6.6

10.3

Parramatta

19.1

3.6

0

13.9

9.3

14.4

Blacktown

31.6

15.6

13.9

0

15.8

17.1

Fairfield

13.4

6.6

9.3

15.8

0

4.4

Cabramatta

14.9

10.3

14.4

17.1

4.4

0

Liverpool

26.6

29.9

30.8

46.4

39

4.9

Casula

19.1

26.7

27.1

37.3

31.3

7.3

location_matrix 3 (km)

LocationName

Liverpool

Casula

Hornsby

46.2

46.6

Wahroonga

59.9

61

Chatswood

39.3

39.6

Eastwood

31.1

33.3

Burwood

26.5

26.8

TownHall

35

35.4

BondiJunction

39.5

39.8

Mascot

30

30.4

Marrickville

25.8

26.2

Rockdale

25.7

26.2

Auburn

22.4

22.7

Bankstown

14.5

15.1

Revesby

10.5

12.2

Merrylands

16.8

18

Parramatta

19.4

19.7

Blacktown

28.4

31.6

Fairfield

10.8

12.1

Cabramatta

4.9

7.3

Liverpool

0

2.8

Casula

2.8

0

location_matrix 4 (km)

For the implementation of intelligent agent function one, not all of these 20 locations have direct routes between them. By querying the train route map on Google Maps, record the distance between adjacent stations in the train_ matrix. xlsx. Non adjacent sites are marked as 0.

LocationName

Hornsby

Wahroonga

Chatswood

Eastwood

Burwood

Hornsby

0

4.2

0

17.7

0

Wahroonga

4.2

0

11.8

0

0

Chatswood

0

11.8

0

0

0

Eastwood

17.7

0

0

0

14

Burwood

0

0

0

14

0

TownHall

0

0

12

0

11.8

BondiJunction

0

0

0

0

0

Mascot

0

0

0

0

0

Marrickville

0

0

0

0

0

Rockdale

0

0

0

0

0

Auburn

0

0

0

0

10.4

Bankstown

0

0

0

0

0

Revesby

0

0

0

0

0

Merrylands

0

0

0

0

0

Parramatta

0

0

0

0

0

Blacktown

0

0

0

0

0

Fairfield

0

0

0

0

0

Cabramatta

0

0

0

0

0

Liverpool

0

0

0

0

0

Casula

0

0

0

0

0

train_ matrix 1 (km)

LocationName

TownHall

BondiJunction

Mascot

Marrickville

Hornsby

0

0

0

0

Wahroonga

0

0

0

0

Chatswood

12

0

0

0

Eastwood

0

0

0

0

Burwood

11.8

0

0

0

TownHall

0

5.7

6.9

9.5

BondiJunction

5.7

0

0

0

Mascot

6.9

0

0

0

Marrickville

9.5

0

0

Rockdale

12.5

0

7.7

0

Auburn

0

0

0

0

Bankstown

0

0

0

16.8

Revesby

24.3

0

19.1

17

Merrylands

0

0

0

0

Parramatta

0

0

0

0

Blacktown

0

0

0

0

Fairfield

0

0

0

0

Cabramatta

0

0

0

0

Liverpool

0

0

0

0

Casula

0

0

0

0

train_ matrix 2(km)

LocationName

Rockdale

Auburn

Bankstown

Revesby

Merrylands

Hornsby

0

0

0

0

0

Wahroonga

0

0

0

0

0

Chatswood

0

0

0

0

0

Eastwood

0

0

0

0

0

Burwood

0

10.4

0

0

0

TownHall

12.5

0

0

24.3

0

BondiJunction

0

0

0

0

0

Mascot

7.7

0

0

19.1

0

Marrickville

0

0

16.8

17

0

Rockdale

0

0

0

0

0

Auburn

0

0

7.6

0

0

Bankstown

0

7.6

0

0

0

Revesby

0

0

0

0

0

Merrylands

0

0

0

0

0

Parramatta

0

7.6

0

0

3.6

Blacktown

0

0

0

0

0

Fairfield

0

0

0

0

6.6

Cabramatta

0

12.1

13.9

0

0

Liverpool

0

0

0

0

0

Casula

0

0

0

12.2

0

train_ matrix 3(km)

LocationName

Parramatta

Blacktown

Fairfield

Cabramatta

Liverpool

Casula

Hornsby

0

0

0

0

0

0

Wahroonga

0

0

0

0

0

0

Chatswood

0

0

0

0

0

0

Eastwood

0

0

0

0

0

0

Burwood

0

0

0

0

0

0

TownHall

0

0

0

0

0

0

BondiJunction

0

0

0

0

0

0

Mascot

0

0

0

0

0

0

Marrickville

0

0

0

0

0

0

Rockdale

0

0

0

0

0

0

Auburn

7.6

0

0

12.1

0

0

Bankstown

0

0

0

13.9

0

0

Revesby

0

0

0

0

0

12.2

Merrylands

3.6

0

6.6

0

0

0

Parramatta

0

13.9

0

0

0

0

Blacktown

13.9

0

0

0

0

0

Fairfield

0

0

0

4.4

0

0

Cabramatta

0

0

4.4

0

4.9

0

Liverpool

0

0

0

4.9

0

2.8

Casula

0

0

0

0

2.8

0

train_ matrix 4(km)

AI Techniques

After obtaining the coordinate data and distance data of these 20 locations, in order to achieve the first function of the intelligent agent, the Greedy Best First Algorithm (GBFS) will be adopted. The GBFS algorithm is a informed search method used to solve path planning and optimal route selection problems. The algorithm starts from the starting site and, based on the estimation of the heuristic evaluation function, selects the most promising node to approach the target for expansion. The process is repeated until the target node is reached or the list of nodes to be considered is empty.

To achieve the second function, namely TSP problem, the intelligent agent will use simulated annealing algorithm. Simulated annealing algorithm is a heuristic optimization algorithm inspired by the gradual cooling process of substances at high temperatures. At high temperatures, the movement of molecules is more intense, and molecular activity will decrease with the decrease of temperature. The simulated annealing algorithm, by introducing randomness and temperature scheduling to search for the solution space of the problem, is expected to find the global optimal solution or near optimal solution. In the early stage, due to the high temperature parameters set, the search frequency is relatively high, which will reduce the possibility of hill climbing algorithms reaching the local optimal solution due to a single search direction during gradient descent. At each temperature stage, the algorithm randomly selects new solutions, accepts better solutions or accepts inferior solutions with a certain probability. Moreover, simulated annealing algorithms have been proven to be suitable for various optimization problems, such as traveling salesman problems and layout optimization, and are highly favored for their ability to handle large-scale problems and solve problems that are difficult to establish accurate mathematical models (Kirkpatrick et al., 1983).

When using simulated annealing algorithm to solve the TSP problem, it is necessary to first randomly generate an initial path that represents the order in which the travel agent visits the city in sequence, and then set the initial temperature and cooling rate. At each temperature stage, the algorithm randomly selects two cities and exchanges their access order to form a new path. Then calculate the total distance difference between the new path and the old path, and if the new path is shorter, it will be accepted; Otherwise, accept with a certain probability, which is determined by the Metropolis criterion, which helps to avoid falling into local optima. The Metropolis criterion is the probability used in simulated annealing algorithms to evaluate whether new solutions are accepted. The expression is as follows:

ΔE is the change in the objective function value of the new solution, and T is the temperature coefficient. By using the formula, it can be concluded that under higher temperature coefficients, the probability of a new solution being accepted will also increase.

Then lower the temperature and continue the search for the next temperature stage until the stop condition is met. Finally, the algorithm returns the optimal path, which is the shortest route for the travel agent to visit all cities.

Implementation

This intelligent agent experiment will be implemented using Python on Jupyter. Firstly, as mentioned earlier, the WGS-84 coordinate system coordinates provided on Google Maps will be converted into relative coordinates of a plane. The data processing method here adopts the API for converting coordinates provided on the Google Maps platform (Google, n.d.).

For the implementation of function one. location_ coordinates and train_ matrix will be used as training data. The libraries to be imported here are Pandas and Matplotlib. The former is used to read data files, while the latter is used to draw topology maps between sites and simulate algorithm processes. Matplotlib only provides drawing tools, but the specific model topology drawing and algorithm demonstration are imported from the class library ‘graphSource’ provided in lab2. For the implementation of the GBFS algorithm, I will also import the best-first algorithm method provided in lab2 to implement the class library ‘BestFirstSearch’ to instantiate a GBFS object. ‘BestFirstSearch_ for_ graph’ will be imported as a class library for drawing the simulation process of the GBFS algorithm. The 20 locations and their coordinate data will be stored in a list and used to draw a planar topology map of the 20 locations. After having information about 20 locations, it is necessary to reflect the adjacent relationships between these 20 sites. Store the adjacent relationships and distances of each location in the list. The initial location and target location can be entered by the user. Then instantiate the GBFS model to optimize the selection of train routes between two points. Then simulate the search process of GBFS. These processes can be viewed specifically on Jupyter Notebook, which will provide links at the end of the article. In the experiment, the GBFS algorithm iterated 26 times using Parramatta 'to' Mascot 'as columns, obtaining the most optimized transfer route ‘Parramatta’ ->’Auburn’ ->’Burwood’ ->’TownHall’ ->’Mascot’.

For the solution of TSP problem, the intelligent agent adopts simulated annealing algorithm. Firstly, the Numpy library was imported for numerical calculations in the algorithm, the random library was used to provide functions for generating random numbers and random selections, and the sys library provided access to system specific parameters and functions. And used the tool library provided in lab3, which mainly provides commonly used modules in machine learning. In this section, loaction_matrix will be used as the dataset. For the implementation of simulated annealing algorithm, according to the algorithm principles introduced in the AI technology section above, several important functions and processes need to be defined first. First, define a temperature scheduling function (exp_schedule) for the annealing algorithm. According to the temperature scheduling calculation formula:k\ \times\ exp\ (-\ lam\ \times\ t). Here, set the parameters k=20, lam=0.005, and limit=10000. Then define a function for calculating state energy (cost or cost), typically used in solving optimization problems such as Traveling Salesman Problem (TSP). The function calculates the total cost of accessing each city based on a given state (in order of cities). The method used in the simulated annealing algorithm to search for adjacent paths in space (generate_k_neighboring_paths) will also be defined. Then create a simulated annealing algorithm method, where the method defined above will be used to iteratively search the state space, accept or reject new states based on energy differences and temperature, in order to gradually optimize the solution. The specific code implementation process will be presented in Notebook. Finally, in the experiment, using 'TownHall' as the starting departure point, the optimal route obtained was: 'TownHall' -> 'Burwood' -> 'Eastwood' -> 'Chatswood' -> 'Wahroonga' -> 'Hornsby' -> 'Blacktown' -> 'Parramatta' -> 'Merrylands' -> 'Auburn' -> 'Bankstown' -> 'Fairfield' -> 'Cabramatta' -> 'Liverpool' -> 'Casula' -> 'Revesby' -> 'Rockdale' -> 'Marrickville' -> 'Mascot' -> 'BondiJunction' -> 'TownHall'. The total route length is approximately 189km.

Recommendations for AI Technique

The GBFS algorithm used in the implementation of the intelligent agent function I may have some problems in solving the global optimal solution.GBFS is not guaranteed to find the global optimal solution and can easily fall into the local optimal solution because it only relies on the estimate of the heuristic evaluation function. Second, GBFS ignores the actual cost of the paths that have been traveled and may choose more costly paths. In addition, GBFS may generate unsolvable problems in the presence of loops or circular paths. Choosing the appropriate heuristic evaluation function is crucial for GBFS and is not suitable for all problems. As an improvement, a more advanced A* search algorithm can be used to handle the problem.

For the implementation of function two, the simulated annealing algorithm is used, which consists of a number of parameters, such as initial temperature, cooling rate, etc., and the selection of appropriate parameter values is critical to the performance of the algorithm. The algorithm is extremely sensitive to the parameters. Different problems and datasets may require different parameter settings, so parameter tuning can be difficult. And in this experiment, the parameter possibilities I chose were not the best in terms of performance. An improvement idea would be to substitute multiple sets of parameters into the model and compare their model performance.

Conclusions

AT1 focuses on the design and implementation of a Map Intelligent Agent aimed at solving the path planning and optimization problem in the Sydney region. Two key functions of map intelligent agents are identified: finding optimal train routes and solving the TSP, which are important for urban transportation and logistics planning. In terms of AI techniques, this paper introduces the Greedy Best First Search (GBFS) algorithm and the Simulated Annealing algorithm, which are used to solve different types of path planning problems. The GBFS performs well in finding the shortest train interchange routes, while the Simulated Annealing algorithm performs well in solving optimization problems, such as the Traveler's Problem. These algorithms provide powerful tools that can be used to solve complex GIS problems.

In terms of implementation, this paper presents experiments using Python on Jupyter Notebook, detailing the steps of data processing and algorithm implementation. Graphs simulating the algorithmic processes are also presented to see the implementation of these algorithms more clearly.

Finally, this paper suggests improvements. For the GBFS algorithm, it is suggested to consider a more advanced A* search algorithm to solve the problem of global optimal solution. For the simulated annealing algorithm, further parameter tuning is needed to improve the performance. These suggestions help to further improve the accuracy and efficiency of map intelligent agents.

Self-reflection

In completing this task, I looked up the datasets needed to form the modeling from Google Maps and chose the greedy best-first algorithm (GBFS) and the simulated annealing algorithm as the key tools for solving the path-planning and TSP. In my experiments, I delved into these techniques and successfully applied them to the Python programming environment. Lab 2, as well as Lab 3, provided the pre-equipment for the completion of this task. I was able to review the previous two experiments to enable me to complete the assignment successfully, and I also made some improvements to the methods provided in Lab 3. For example, when performing the simulated annealing algorithm, the Lab 3 guidebook gives the use of Euclidean distances to represent distances between locations, but in reality, paths are rarely represented as straight line distances. I carried out my experiments importing distance data from Google. This task not only strengthened my technical skills in AI algorithms, but also improved my other skills such as data collection. In the future, I will continue to explore the field of path planning and optimization, strengthen my skills in parameter tuning, and continue to improve my writing and presentation skills to better meet future challenges and opportunities. This assignment provided me with a valuable learning experience that will positively impact my research and career.

Reference

Kirkpatrick, S., Gelatt, C. D., & Vecchi, M. P. (1983). Optimization by simulated annealing. Science, 220(4598), 671-680. doi:10.1126/science.220.4598.671

Google. (n.d.). googlemaps/google-maps-services-python: Python client library for Google Maps API Web Services. GitHub. GitHub - googlemaps/google-maps-services-python: Python client library for Google Maps API Web Services

Appendix

Here is a link to the Jupyter Notebook (which contains only the Notebook):

https://colab.research.google.com/drive/1rmaN1-e-EhUeErpj2lKQgJ39Q035iilV?usp=sharing

Here is the project folder for Assignment1 (contains references to external libraries, datasets, notebooks and some Google Maps images) : https://drive.google.com/drive/folders/1HODEUuiL5BAqhQb6d_OJZl4eMwfeZDep?usp=sharing

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ultimo2023

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值