Package org.opt4j.operator
Class AbstractGenericOperator<O extends Operator<?>,Q extends Operator<?>>
- java.lang.Object
-
- org.opt4j.operator.AbstractGenericOperator<O,Q>
-
- All Implemented Interfaces:
GenericOperator<O>
- Direct Known Subclasses:
AlgebraGenericImplementation
,CopyGenericImplementation
,CrossoverGenericImplementation
,DiversityGenericImplementation
,MutateGenericImplementation
,NeighborGenericImplementation
public abstract class AbstractGenericOperator<O extends Operator<?>,Q extends Operator<?>> extends Object implements GenericOperator<O>
Superclass forGenericOperator
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractGenericOperator.ClassComparator
Comparator for a specific order: Superclasses always are sorted after subclasses.static class
AbstractGenericOperator.OperatorClassPredicate
TheAbstractGenericOperator.OperatorClassPredicate
returnstrue
for a given specific class.protected static class
AbstractGenericOperator.OperatorHolder<P>
static interface
AbstractGenericOperator.OperatorPredicate
TheAbstractGenericOperator.OperatorPredicate
interface.static class
AbstractGenericOperator.OperatorVoidPredicate
TheAbstractGenericOperator.OperatorVoidPredicate
interface is used as marker forOperator
s for which the predicate is not explicitly defined.
-
Field Summary
Fields Modifier and Type Field Description protected SortedMap<Class<? extends Genotype>,O>
classOperators
protected List<Class<? extends Q>>
cldef
protected Map<AbstractGenericOperator.OperatorPredicate,O>
genericOperators
-
Constructor Summary
Constructors Constructor Description AbstractGenericOperator(Class<? extends Q>... clazzes)
Constructs anAbstractGenericOperator
class with the given clazzes of default operators.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOperator(AbstractGenericOperator.OperatorPredicate predicate, O operator)
Adds an operator.O
getOperator(Genotype genotype)
Collection<O>
getOperators()
Returns all classOperators.protected static <O> Class<? extends Genotype>
getTarget(O operator)
protected void
inject(AbstractGenericOperator.OperatorHolder<Q> holder)
Inject and organize the operators.
-
-
-
Constructor Detail
-
AbstractGenericOperator
public AbstractGenericOperator(Class<? extends Q>... clazzes)
Constructs anAbstractGenericOperator
class with the given clazzes of default operators.- Parameters:
clazzes
- the default operators
-
-
Method Detail
-
inject
@Inject protected void inject(AbstractGenericOperator.OperatorHolder<Q> holder)
Inject and organize the operators.- Parameters:
holder
- the operator holder
-
addOperator
public void addOperator(AbstractGenericOperator.OperatorPredicate predicate, O operator)
Description copied from interface:GenericOperator
Adds an operator.- Specified by:
addOperator
in interfaceGenericOperator<O extends Operator<?>>
- Parameters:
predicate
- the operator predicateoperator
- TheOperator
-
getOperator
public O getOperator(Genotype genotype)
Description copied from interface:GenericOperator
- Specified by:
getOperator
in interfaceGenericOperator<O extends Operator<?>>
- Parameters:
genotype
- the genotype- Returns:
- the operator for this genotype
-
getOperators
public Collection<O> getOperators()
Description copied from interface:GenericOperator
Returns all classOperators.- Specified by:
getOperators
in interfaceGenericOperator<O extends Operator<?>>
- Returns:
- all classOperators
-
-