Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * Applies the transformation on the Data Sample and creates a new DataSample with the transformed
  * version
  *
  * @param data Data sample to be transformed
  * @return Transformed Data Sample (new object)
  */
 public Object apply(Object data) {
   LabeledObject x = (LabeledObject) data;
   Object obj = x.get();
   return Cloner.clone(obj);
 }