Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement and evaluate two search algorithms. Input data file: Your input file will be a CSV ( comma separated values ) file ( campus .

Implement and evaluate two search algorithms.
Input data file:
Your input file will be a CSV (comma separated values) file (campus.csv - The csv file has no header, SB is starting node, always strat from SB only).
You CANNOT modify nor rename input data files.
Each row in that input file will correspond to STATE information: STATE_LABEL, and state 2D Cartesian space coordinates: X and Y. You can assume X and Y to be positive integers.
Problem description:
Your task is to solve a Traveling Salesman Problem [TSP](find minimum cost/weight Hamiltonian Cycle) on G using algorithms specified below.
Your task is to implement two search algorithms in Python:
Simulated Annealing, and
Genetic Algorithm,
and apply them to solve the TSP (starting at Stuart Building [SB] node) problem using provided data.
Your program should:
Accept four (4) command line arguments corresponding to two states / state capitals (initial and goal states) so your code could be executed with
python cs581_P01_AXXXXXXXX.py FILENAME ALGO P1 P2
where:
cs581_P01_AXXXXXXXX.py is your python code file name,
FILENAME is the input CSV file name (graph G data),
ALGO is mode in which your program should operate
1 Simulated Annealing,
2 Genetic Algorithm,
P1 is a value for a specific algorithm parameter:
SA: P1- initial temperature T,
GA: P1- no. of iterations K,
P2 is a value for a specific algorithm parameter:
SA: P2-\alpha parameter for the temperature cooling schedule,
GA: P2- mutation probability,
Example:
python cs581_P01_A11111111.py DATA.CSV 210000.01
If the number of arguments provided is NOT four your program should display the following error message:
ERROR: Not enough or too many input arguments.
and exit.
Run Simulated Annealing and Genetic Algorithm searches to find the Traveling Salesman Problem solution starting at INITIAL (first state/line in the input CSV file) state and measure execution time (in seconds) for both methods.
Report results on screen in the following format:
Last Name, First Name, AXXXXXXXX solution:
Initial state: INITIAL
Simulated Annealing:
Command Line Parameters:
Initial solution: LABEL1, LABEL2, LABEL3,..., LABELN-1, LABELN
Final solution: LABEL1, LABEL2, LABEL3,..., LABELN-1, LABELN
Number of iterations: AAAA
Execution time: T1 seconds
Complete path cost: Y1
Genetic Algorithm:
Command Line Parameters:
Initial solution: LABEL1, LABEL2, LABEL3,..., LABELN-1, LABELN
Final solution: LABEL1, LABEL2, LABEL3,..., LABELN-1, LABELN
Number of iterations: AAAA
Execution time: T2 seconds
Complete path cost: Y2
where:
AXXXXXXXX is your IIT A number,
START_NODE is the label/name of the initial graph node,
AAAA is the number of iterations completed before termination,
LABEL1, LABEL2, LABEL3,..., LABELN-1, LABELN is a solution represented as a list of visited states (with LABEL1= START_NODE and LABELN = INITIAL),
Save your solutions to a file named:
Simulated Annealing: INPUTFILENAME_SOLUTION_SA.csv file.
Genetic Algorithm: INPUTFILENAME_SOLUTION_GA.csv file.
Where: INPUTFILENAME is the input file name WITHOUT extension (for example for input file DATA2.CSV, the GA solution file should be named DATA2_SOLUTION_GA.csv.
Solution file (text file) format:
XXXX
STATE1
STATE2
STATE3
STATEN
Where:
XXXX will be the final path / solution cost
STATE1, STATE2,..., STATEN state LABELS (one per line, names as in the input file) represent solution path (the one displayed on screen; here assumed to be of length 4) in order.
Algorithm Parameters [SPECIFY WHAT IS NOT GIVEN BELOW]:
Simulated Annealing parameters are:
Initial state: pick one at random
Initial temperature: T = P1
What is a move? 2-edge swap
Termination condition: Temperature T >0.
Temperature cooling schedule: exponential (P2=\alpha provided as command line argument)
Ti = TINITIAL * e-i *\alpha
Cost / objective function:
Genetic Algorithm parameters are:
Individual representation (it does not need to be binary):
Population size N =
Fitness function:
Selection mechanism: Roulette Wheel,
Probability of crossover: Pc =1,
Crossover mechanism: 2-point crossover with crossover points
Probability of mutation: Pm = P1,
Termination condition: number of iterations > P2= K.
Results and Conclusions
Assume that the INITIAL state is the first state in the CSV file. Run both algorithms:
with three different values of P2 for both algorithms,
with number of iterations K / T: 100,1000,10000[repeat each 5 times and find average min, max, and average path cost and search times] for every P2 value,
and for every ALGO-P1-P2 value combination provide ONE min/average/max fitness function plot (one plot with three traces; add labels and legend). Pick a run that was interesting or best and explain your choice.
Report your findings in Table.
What are your conclusions? What have you observed? Which algorithm/parameter set performed better? Was the optimal path found? Write a summary below.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

More Books

Students also viewed these Databases questions