Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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 Math.random()&& helper >= 2){ SingleChromosome parent2=poptocross.population[helper]; Random somer= new Random(); int[] parent2rep=parent2.chromosomerepersentation; parent2rep=swapArrayVals(parent2rep, 5, 10, 15); int[] offspring1=new int[parent2rep.length]; // int[] offspring2=new int[parent2rep.length]; //if there is 1 in bitmask gene comes from parent1 if 0 gene comes from parent 2 for(int i=0;i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students explore these related Databases questions