net.sourceforge.cilib.util.selection.recipes.BoltzmannSelector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cilib-library Show documentation
Show all versions of cilib-library Show documentation
A library of composable components enabling simpler Computational Intelligence
The newest version!
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.util.selection.recipes;
import java.util.Arrays;
import java.util.Iterator;
import net.sourceforge.cilib.entity.Entity;
import net.sourceforge.cilib.entity.comparator.BoltzmannComparator;
import net.sourceforge.cilib.util.selection.PartialSelection;
import net.sourceforge.cilib.util.selection.Selection;
public class BoltzmannSelector implements Selector {
private BoltzmannComparator comparator;
public BoltzmannSelector() {
this.comparator = new BoltzmannComparator();
}
@Override
public PartialSelection on(Iterable iterable) {
Iterator iter = iterable.iterator();
E item1 = iter.next();
E item2 = iter.next();
if (comparator.compare(item1, item2) < 0) {
return Selection.copyOf(Arrays.asList(item2));
}
return Selection.copyOf(Arrays.asList(item1));
}
public void setComparator(BoltzmannComparator comparator) {
this.comparator = comparator;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy