분류 문제를 해결하기 위해 유전 알고리즘을 쓰고 있습니다.Genotype.evolve() throws '비교 메서드가 일반 계약을 위반합니다.'
다른 사람들이 온라인에서 어떻게 보았는지 정확하게 설정하고 있지만 자신의 피트니스 기능을 사용해야합니다 (필수). 내 인구를 보유하고이 인구를 진화시키는 임의의 Genotype을 생성합니다. 그러나 때로는 '비교 방법이 일반 계약을 위반합니다!'라는 오류가 나타납니다.
나는이 오류가 무엇을 의미하는지 이해하지만,이 프레임 워크 방법 .evolve에 호출되는 이후() 나는 확실히 내가 무엇을 할 수 있는지 ...
어떤 생각/도움이 아니에요? 감사합니다. .
내 설정 :
DefaultConfiguration.reset();
Configuration config = new DefaultConfiguration();
config.setPopulationSize(100);
// Setup fitness function
FitnessFunction fit = new HyperrectFitnessFunction(is);
config.setFitnessFunction(fit);
// Get bounds
double[][] bounds = getInstanceSetBounds(is);
// Setup chromosome
Chromosome sample = new Chromosome(config, createSampleGenes(config, attrCount, bounds));
config.setSampleChromosome(sample);
// Generate initial population
Genotype population = Genotype.randomInitialGenotype(config);
// Evolve
int i = 0;
IChromosome bestSolution = null;
for (i = 1; i < 100 + 1; i++) {
population.evolve();
bestSolution = population.getFittestChromosome();
double bestFitness = bestSolution.getFitnessValue();
if (bestFitness > 0.8)
break;
}
[ "비교 방법이 일반 계약을 위반합니다!"] (https://stackoverflow.com/questions/8327514/comparison-method-violates-its-general-contract) –