Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## jgap-users

 [jgap-users] Unique constraint From: Pierre G - 2012-10-25 09:23:50 ```Hi all, I have a problem, I guess very similair to Saleman Problem. I have N persons and M places. 2 persons should visit a place. As there is some constraints to be fullfilled, N should be > 2*M . I want to be sure that one person is only at one place but my first attempt give me solution where person appear many times. Here what I did : I used IntegerGene with value = index in array of Person. I create a sample chromosome with 2M distinct Person this way : for (int i = 0;i < 2*M;i++ ) { sampleGenes[i] = new IntegerGene(conf, 0, N -1); sampleGenes[i].setAllele(Integer.valueOf(i)); } IChromosome sampleChromosome = new Chromosome(conf, sampleGenes); I understood that I shoud not used randomInitialGenotype for creation population so I copy new chromosomes from sampleChromosome like I see in Saleman example : IChromosome[] chromosomes = new IChromosome[conf.getPopulationSize()]; Gene[] samplegenes = sampleChromosome.getGenes(); for (int i = 0; i < chromosomes.length; i++) { Gene[] genes = new Gene[samplegenes.length]; for (int k = 0; k < genes.length; k++) { genes[k] = samplegenes[k].newGene(); genes[k].setAllele(samplegenes[k].getAllele()); } chromosomes[i] = new Chromosome(conf, genes); } Then population is created : Genotype population = new Genotype(conf, new Population(conf,chromosomes)); After evolving, a Person can be used many times. What am I doing wrong ? Where to put this "unique" constraint ? in configuration, in sample chromosome or in fitness evaluation ? Thanks in advance for any help Pierre -- View this message in context: http://old.nabble.com/Unique-constraint-tp34600224p34600224.html Sent from the jgap-users mailing list archive at Nabble.com. ```