I am writing a Genetic Algorithm in Java using Unifrom order Crossover with BITMASK for solving TSP Problem. My issue is my initial pop is
I am writing a Genetic Algorithm in Java using Unifrom order Crossover with BITMASK for solving TSP Problem. My issue is my initial pop is of size popsize with each having a path of 1,2,3--numofcities, and if i do a uniform order crossover with 1,2,3 / 1,2,3, and whatever the bitmask is I get the same path 1,2,3,4...
here is my code:
public static SetOfChromosomes crossoverPopulationn(SetOfChromosomes poptocross){ int helper=0; SetOfChromosomes newPop= new SetOfChromosomes(poptocross.population.length, 0, 0); int[] bitmask22= createBitmaskArray(poptocross.population[0].chromosomerepersentation.length); //creates array to repersent bitmask for 22 cities (1010101010101010101010) for 51 cities (101010101010101010101010101010101010101010101010101) int[] bitmask51= createBitmaskArray(poptocross.population[0].chromosomerepersentation.length); SingleChromosome parent1 = TournamentSelection(poptocross,103434);//parent 1 //picks the best individual in the population subset of (tournament size) int[] parent1rep= parent1.chromosomerepersentation; while(helper
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started