Hi Guys,
How to implement N-Opt in Genetic Algorithm To Solve the Travelesman Problem?
Im trying to implement 2-opt in a GA algorithm, but im confused in how-to…
Should i implement it in the mutate() method or mate() method?
//
I know in theory how 2-opt should WORK :
Example :
For 4 Cities A,B,C,D
A B
C D
A–> D -->C -->B
Their connections form concorrent lines…
The method should be capable to Transform that into either these :
A–>B–>D–>C
or
A–>C–>D–>B
The one with less cost obviously.
Im not getting how to do it.
I know how to identify if a line intersects other by using
f(x) = mx + b
Or is there any other way i should do it?