Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RandomRoute(int initpopulation)
- {
- population = new int[initpopulation, 7];
- for (int i = 0; i < initpopulation; i++)
- {
- route = 11111;
- citycount = 0;
- Random rand = new Random();
- while (route != 0) // all 5 cities
- {
- temp = rand.Next(1, 6);
- if (route % Convert.ToInt32(Math.Pow(10, temp)) > route % Convert.ToInt32(Math.Pow(10, temp - 1)))
- {
- route = route - Convert.ToInt32(Math.Pow(10, (temp - 1)));
- population[i, citycount] = Convert.ToInt32(Math.Pow(10, (temp - 1)));
- citycount++;
- }
- }
- population[i, citycount] = population[i, 0];
- population[i, citycount + 1] = CalculateCost(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement