コード例 #1
0
 private ClassifierIndividual[] createKidsFromEncoding(
     GAParameterSet params, BitString c1, BitString c2) {
   ClassifierIndividual[] kids = new ClassifierIndividual[getRequiredNumberOfParents()];
   kids[0] =
       (ClassifierIndividual) params.getIndividualsFactory().createSpecificIndividual(c1, params);
   kids[1] =
       (ClassifierIndividual) params.getIndividualsFactory().createSpecificIndividual(c2, params);
   return kids;
 }
コード例 #2
0
 protected Individual[] makeCopyOfParents(Individual[] parents, GAParameterSet params) {
   Individual[] kids = new Individual[parents.length];
   for (int i = 0; i < kids.length; i++) {
     kids[i] =
         params
             .getIndividualsFactory()
             .createSpecificIndividual(
                 ((BinaryEncodedIndividual) parents[i]).getBitStringRepresentation(), params);
     // kids[i] = (BinaryEncodedIndividual) ((BinaryEncodedIndividual) parents[i]).clone();
     kids[i].setFitness(parents[i].getFitness());
   }
   return kids;
 }
コード例 #3
0
 private boolean kidsSatisfyConstraints(ClassifierIndividual[] kids, GAParameterSet params) {
   ClassifierIndividualFactory fact = (ClassifierIndividualFactory) params.getIndividualsFactory();
   for (int i = 0; i < kids.length; i++) if (!fact.valid(kids[i])) return false;
   return true;
 }