Question: Write working python code using local search Genetic Algorithm with following steps a . Population Initialisation, b . Fitness Selection using roulette s wheel, c
Write working python code using local search Genetic Algorithm with following steps
a Population Initialisation,
b Fitness Selection using roulettes wheel,
c Cross over by single split or two split
d Mutatation
Consider,
def manhattandistancepoint point:
x y nodecoordinatespoint
x y nodecoordinatespoint
return absx x absy y
def generateinitialpopulationgraph populationsize:
initialpopulation
for in rangepopulationsize:
path listgraphkeys
random.shufflepath
initialpopulation.appendpath
return initialpopulation
def calculatefitnesspath:
totaldistance summanhattandistancepathi pathi for i in rangelenpath
return totaldistance if totaldistance else floatinf
From diagram, representation of different places using some short forms and graph using dictionary of them as follows:
pu: Purasawalkam
pe: Perumbakkam
v: Velachery
g: Guindy
t: Tambaram
n: Nungambakkam
graph
pu: pet
pe: putvg
v: gpe
g: petnv
n: gt
t: ngpepu
nodecoordinates
pu:
pe:
t:
v:
g:
n:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
