예제 #1
0
파일: ArityTwo.java 프로젝트: shrein/alife
 /** Constructor: Create a crossover operator with the given selection parent strategy */
 public ArityTwo(Environment _environment, Selection _selection) {
   super(_environment);
   selection = _selection;
   if (selection != null) {
     selection.setSize(2);
   }
 }
예제 #2
0
파일: ArityTwo.java 프로젝트: shrein/alife
 /**
  * Apply the operator over the given individuals
  *
  * @param population Source population
  * @param x Individual used as first parent
  * @return A collection of individuals generated by the operator
  */
 public Vector apply(Population population, int x) {
   Vector children = null;
   if (population != null && selection != null) {
     Vector parents = selection.choose(population, x);
     Individual child1 = (Individual) (Cloner.clone(parents.elementAt(0)));
     Individual child2 = (Individual) (Cloner.clone(parents.elementAt(1)));
     // only for two children
     apply(child1, child2);
     children = new Vector();
     children.add(child1);
     children.add(child2);
   }
   return children;
 }
예제 #3
0
파일: ArityTwo.java 프로젝트: shrein/alife
 public void setEnvironment(Environment _environment) {
   super.setEnvironment(_environment);
   selection.setEnvironment(environment);
 }