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 Each row in

Implement and evaluate two search algorithms.
Input data file:
Your input file will be a CSV (comma separated values) file
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:
You are given a weighted complete graph G. Your task is to solve a Traveling Salesman Problem [TSP](find minimum cost/weight Hamiltonian Cycle) on G using algorithms specified below.
Assume that edge weights represent straight line distances between states.
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 file.py FILENAME ALGO P1 P2
where:
file.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:
Simulated Annealing: P1 is the initial temperature T value,
Genetic Algorithm: P1 is the number of iterations K,
P2 is a value for a specific algorithm parameter:
Simulated Annealing: P2 is the \alpha parameter for the temperature cooling schedule,
Genetic Algorithm: P2 is the mutation probability Pm value,
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:
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:
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.
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
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.
What are your conclusions? What have you observed? Which algorithm/parameter set performed better? Was the optimal path found? Write a summary below.campus
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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions