Created
December 10, 2022 12:35
-
-
Save deleteman/fd4b3b0be2390ae840bee6c65b11f417 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NUM_CITIES = 10; // number of cities in the sales route | |
const POPULATION_SIZE = 100; // number of individuals in the population | |
const MUTATION_RATE = 0.1; // probability of mutation | |
const CROSSOVER_RATE = 0.7; // probability of crossover | |
const MAX_ITERATIONS = 1000; // maximum number of iterations | |
// define the distance between each pair of cities | |
const distances = [ | |
[0, 10, 15, 20, 25, 30, 35, 40, 45, 50], //distance of city 0 to all other cities | |
[10, 0, 5, 10, 15, 20, 25, 30, 35, 40],//distance of city 1 to all other cities | |
[15, 5, 0, 5, 10, 15, 20, 25, 30, 35],//distance of city 2 to all other cities | |
[20, 10, 5, 0, 5, 10, 15, 20, 25, 30],//distance of city 3 to all other cities | |
[25, 15, 10, 5, 0, 5, 10, 15, 20, 25],//distance of city 4 to all other cities | |
[30, 20, 15, 10, 5, 0, 5, 10, 15, 20],//distance of city 5 to all other cities | |
[35, 25, 20, 15, 10, 5, 0, 5, 10, 15],//distance of city 6 to all other cities | |
[40, 30, 25, 20, 15, 10, 5, 0, 5, 10],//distance of city 7 to all other cities | |
[45, 35, 30, 25, 20, 15, 10, 5, 0, 5],//distance of city 8 to all other cities | |
[50, 40, 35, 30, 25, 20, 15, 10, 5, 0],//distance of city 9 to all other cities | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment