es.udc.gii.common.eaf.algorithm.operator
Class OperatorChain<T extends Operator>

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.operator.OperatorChain<T>

public class OperatorChain<T extends Operator>
extends java.lang.Object

Implements an operators' chain. This chain contains a group of operators to be executed on a particular problem to resolve it. This chain could be executed operator by operator or all operators in one step.

Since:
1.0
Author:
Grupo Integrado de IngenierĂ­a (www.gii.udc.es)

Field Summary
private  int next
          Indicates the next operator to be executed.
private  java.util.List<T> operators
          The operators of this chain.
 
Constructor Summary
OperatorChain()
          Creates a new operator chain with an empty list of operators.
 
Method Summary
 void addOperators(T operator)
          Add an object of type Operator to the List operators.
 java.util.List<Individual> execute(EvolutionaryAlgorithm algorithm, Population population)
          This method execute all chain's operators in one step over the current algorithm.
 java.util.List<Individual> executeNext(EvolutionaryAlgorithm algorithm, java.util.List<Individual> individuals)
          Execute the next operator in the chain and change the value of next attribute to execute the next operator the next time.
 java.util.List<T> getOperators()
          Get the list of operators
 void removeOperators(T operator)
          Remove an object of type Operator from the List operators.
 java.lang.String toString()
          Return the String that represents an operators' chain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

private int next
Indicates the next operator to be executed.


operators

private java.util.List<T extends Operator> operators
The operators of this chain.

Constructor Detail

OperatorChain

public OperatorChain()
Creates a new operator chain with an empty list of operators.

Method Detail

addOperators

public void addOperators(T operator)
Add an object of type Operator to the List operators.

Parameters:
operator - an operator to be inserted in the chain.

removeOperators

public void removeOperators(T operator)
Remove an object of type Operator from the List operators.

Parameters:
operator - an operator to be deleted from the chain.

getOperators

public java.util.List<T> getOperators()
Get the list of operators

Returns:
List of operators

execute

public java.util.List<Individual> execute(EvolutionaryAlgorithm algorithm,
                                          Population population)
This method execute all chain's operators in one step over the current algorithm. The population will change every time that an operator is executed.

Parameters:
algorithm - the algorithm wich over we will execute the chain's operator.
population - the initial population over we will execute the operators. And when we return to the execution of the algorithm this population will change.

executeNext

public java.util.List<Individual> executeNext(EvolutionaryAlgorithm algorithm,
                                              java.util.List<Individual> individuals)
Execute the next operator in the chain and change the value of next attribute to execute the next operator the next time.

Parameters:
algorithm - the algorithm wich over we will execute the current operator.
population - the population which over we will execute the current operator.

toString

public java.lang.String toString()
Return the String that represents an operators' chain.

Overrides:
toString in class java.lang.Object
Returns:
an String representing an operators' chain.