You are on page 1of 2

UEMH3073/UECS2053/UECS2153 – ARTIFICIAL INTELLIGENCE Lab 3

LAB 3 – Genetic Algorithms

Requirements
• Python + Jupyter Notebook
Methodology
1. Download the ‘Lab3GeneticAlgorithm.ipynb’ Jupyter notebook and open it up.
2. Implement a genetic algorithm for solving the Travelling Salesman Problem (TSP) by replacing
codes marked as #TODO in the code cells explaining tasks you need to complete or codes you
need to write so that the genetic algorithm functions well and runs correctly. Look for
“Replacement starts here” and “Replacement ends here” to know the parts of the codes
requiring your revision and inputs. The #TODO list is as follows:-
Label Class/Functions Tasks Marks
#TODO1 Fitness Write a new fitness function (you may be guided by Peng 10
Chen, 2013)
#TODO2 Population Read a set of cities from the filename when creating an 10
initialization initial population
#TODO3 Parent selection Replace a dummy parent selection function with at least 20
two of Tournament Selection, Proportional Selection, or
any other relevant selection method
#TODO4 Survival Replace the dummy survival selection function with 10
selection either Fitness Based Selection or Merge, Sort & Truncate
#TODO5 Crossover Replace the dummy crossover function with at least two 20
appropriate crossover approach generating valid paths.
The Partially Mapped Crossover and Ordered Crossover
approaches are examples of appropriate crossover
approaches (see also Peng Chen, 2013)
#TODO6 Mutation Replace the dummy mutation function with an 10
appropriate mutation approach generating valid paths.
Shift mutation is a suitable mutation approach (see also
Peng Chen, 2013)
#TODO7 Performance Present performance evaluation for the different types of 10
evaluation functions used in this lab. You may choose to evaluate
route distance, convergence rate, or other relevant
performance metrics
Report Your report should present and summarize your obtained 10
formatting performance evaluation results.

3. For the parent selection and crossover functions, implement at least two of each.
4. Test your genetic algorithm on the small data set provided (cities8).
5. Once you have chosen the best combination of functions, try to obtain the best solution to the
large data set provided (cities500).
6. Remember to gather and save your results for performance evaluation.

Dr. Ng Oon-Ee <ngoe@utar.edu.my> 2023, OctTrimester, pg 1/2


UEMH3073/UECS2053/UECS2153 – ARTIFICIAL INTELLIGENCE Lab 3

7. Don’t forget to run the final cell when you have gotten a good result to save the actual route to a
text file, this is required for submission!
Report
• Your report should present your results and your analysis of those results.
• Pay special attention to the relative performance and effectiveness of the functions you
implemented.
• Page limit is 8 pages.
• Be sure to report the best distance in the report. The exported route is required to verify this
distance.
Submission
• Your submission comprises of ONE (1) Jupyter notebook, ONE (1) PDF document (Word files
not accepted), and ONE (1) text file containing the best route you have been able to find.
◦ ONE (1) Jupyter notebook with file name being <Your name>_jupyter.ipynb
◦ ONE (1) Report in PDF format with file name being <Your name>_report.pdf (Word files
are not accepted. The first page is the title page with the following details:-
▪ Your practical date.
▪ Your name
▪ Your student ID
▪ Your Programme of study
◦ ONE (1) exported route file with file name being <Your name>_solution.csv
• Submission deadline is exactly 7 days after your lab finishes (5.30pm on the next Friday after
your lab). Submission is through WBLE.

Dr. Ng Oon-Ee <ngoe@utar.edu.my> 2023, OctTrimester, pg 2/2

You might also like