com.rapidminer.operator
Class OperatorChain

java.lang.Object
  extended by com.rapidminer.operator.Operator
      extended by com.rapidminer.operator.OperatorChain
All Implemented Interfaces:
ConfigurationListener, PreviewListener, ParameterHandler, LoggingHandler
Direct Known Subclasses:
AbstractMetaLearner, AbstractSplitChain, AttributeSubsetPreprocessing, BatchProcessing, ClusterIterator, EvolutionaryFeatureAggregation, ExampleSetBasedFeatureOperator, ExampleSetIterator, ExceptionHandling, FeatureIterator, FeatureOperator, FeatureSubsetIteration, FileIterator, ForwardSelectionOperator, GenericWekaEnsembleLearner, GenericWekaMetaLearner, IteratingOperatorChain, IteratingPerformanceAverage, IterativeWeightOptimization, LearningCurveOperator, MissingValueImputation, MultipleLabelIterator, OperatorEnabler, OperatorSelector, ParameterIteratingOperatorChain, PartialExampleSetLearner, ProcessBranch, ProcessRootOperator, PSOWeighting, RandomOptimizationChain, RepeatUntilOperatorChain, ROCBasedComparisonOperator, SDRulesetInduction, SimpleOperatorChain, TextSegmenter, TopDownClustering, TransformedRegression, Trend, UnivariateLabelSeriesPrediction, ValidationChain, ValueIteration, ValueSubgroupIteration, WeightOptimization, WrapperValidationChain, XVPrediction

public abstract class OperatorChain
extends Operator

A chain of operators that is subsequently applied. As an OperatorChain is an Operator itself it can be arbitrarily nested.
Inheritants can access inner operators by getOperator(int). They should override getMaxNumberOfInnerOperators() and getMinNumberOfInnerOperators() which are used for some checks. They should also override getInnerOperatorCondition() to ensure that all inner operators get the desired input and return the necessary output for the next inner operator. Please refer to the RapidMiner tutorial for a description how to implement your own operator chain.

Author:
Simon Fischer, Ingo Mierswa

Constructor Summary
OperatorChain(OperatorDescription description)
          Creates an empty operator chain.
 
Method Summary
 void addAddListener(AddListener listener)
          Adds the given listener.
 int addOperator(Operator o)
          Adds a new inner operator at the last position.
 int addOperator(Operator operator, int index)
          Adds the given operator at the given position.
 IOObject[] apply()
          Applies all inner operators.
 int checkDeprecations()
          Will count an the number of deprecated operators, i.e. the operators which Operator.getDeprecationInfo() method does not return null.
 java.lang.Class<?>[] checkIO(java.lang.Class<?>[] input)
          This method checks if inner operators can handle their input and deliver the necessary output.
 int checkNumberOfInnerOperators()
          Checks if the number of inner operators lies between MinInnerOps and MaxInnerOps.
 int checkProperties()
          Will throw an exception if a non optional property has no default value and is not defined by user.
 void clearErrorList()
          Clears the error list for this operator (by invoking the super method) and all children.
 Operator cloneOperator(java.lang.String name)
          Performs a deep clone of this operator chain.
protected  java.lang.String createExperimentTree(int indent, java.lang.String selfPrefix, java.lang.String childPrefix, Operator markOperator, java.lang.String mark)
          Deprecated. Use createProcessTree(int,String,String,Operator,String) instead
protected  java.lang.String createProcessTree(int indent, java.lang.String selfPrefix, java.lang.String childPrefix, Operator markOperator, java.lang.String mark)
          Returns this OperatorChain's name and class and the process trees of the inner operators.
 java.util.List<Operator> getAllInnerOperators()
          Returns recursively all child operators independently if they are activated or not.
 int getIndexOfOperator(Operator operator, boolean useDisabled)
          Returns the index of the given operator in the list of children.
abstract  InnerOperatorCondition getInnerOperatorCondition()
          Must return a condition of the IO behaviour of all desired inner operators.
 Operator getInnerOperatorForName(java.lang.String name)
          Returns the inner operator named name or null if no such operator exists.
protected  java.lang.String getInnerOperatorsXML(java.lang.String indent, boolean hideDefault)
          Returns the XML representation for all inner operators.
abstract  int getMaxNumberOfInnerOperators()
          Returns the maximum number of inner operators.
abstract  int getMinNumberOfInnerOperators()
          Returns the minimum number of inner operators.
 int getNumberOfAllOperators()
          Returns the number of all inner operators (including the disabled operators).
 int getNumberOfOperators()
          Returns the number of all enabled inner operators.
 Operator getOperator(int i)
          Returns the i-th inner operator.
 Operator getOperatorFromAll(int i)
          Returns the i-th operator.
 java.util.Iterator<Operator> getOperators()
          Returns an iterator over all Operators.
 void performAdditionalChecks()
          This method invokes the additional check method for each child.
 void processFinished()
          Invokes the super method and the method for all children.
 void processStarts()
          Invokes the super method and the method for all children.
protected  void registerOperator(Process process)
          Register this operator chain and all of its children in the given process.
 void removeAddListener(AddListener listener)
          Removes the given listener.
protected  void removeOperator(Operator operator)
          Removes the given operator from this operator chain.
protected  boolean shouldAddNonConsumedInput()
           
protected  boolean shouldReturnInnerOutput()
          Indicates if inner output should be delivered by this operator chain.
protected  void unregisterOperator(Process process)
          Unregisters this chain and all of its children from the given process.
 
Methods inherited from class com.rapidminer.operator.Operator
addError, addValue, addWarning, apply, checkForStop, createExperimentTree, createFromXML, createMarkedExperimentTree, createMarkedProcessTree, createProcessTree, getAddOnlyAdditionalOutput, getApplyCount, getDeliveredOutputClasses, getDeprecationInfo, getDesiredInputClasses, getEncoding, getErrorList, getExperiment, getInput, getInput, getInput, getInputClasses, getInputDescription, getIOContainerForInApplyLoopBreakpoint, getIODescription, getLog, getName, getOperatorClassName, getOperatorDescription, getOutputClasses, getParameter, getParameterAsBoolean, getParameterAsColor, getParameterAsDouble, getParameterAsFile, getParameterAsFile, getParameterAsInputStream, getParameterAsInt, getParameterAsMatrix, getParameterAsString, getParameterList, getParameters, getParameterType, getParameterTypes, getParent, getProcess, getStartTime, getStatus, getUserDescription, getValue, getValues, getXML, hasBreakpoint, hasBreakpoint, hasInput, inApplyLoop, isDebugMode, isEnabled, isExpanded, isParallel, isParameterSet, log, logError, logNote, logWarning, register, remove, rename, resume, setApplyCount, setBreakpoint, setEnabled, setExpanded, setInput, setListParameter, setOperatorParameters, setParameter, setParameters, setParent, setUserDescription, toString, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OperatorChain

public OperatorChain(OperatorDescription description)
Creates an empty operator chain.

Method Detail

getMaxNumberOfInnerOperators

public abstract int getMaxNumberOfInnerOperators()
Returns the maximum number of inner operators.


getMinNumberOfInnerOperators

public abstract int getMinNumberOfInnerOperators()
Returns the minimum number of inner operators.


getInnerOperatorCondition

public abstract InnerOperatorCondition getInnerOperatorCondition()
Must return a condition of the IO behaviour of all desired inner operators. If there are no "special" conditions and the chain works similar to a simple operator chain this method should at least return a SimpleChainInnerOperatorCondition. More than one condition should be combined with help of the class CombinedInnerOperatorCondition.


addAddListener

public void addAddListener(AddListener listener)
Adds the given listener.


removeAddListener

public void removeAddListener(AddListener listener)
Removes the given listener.


cloneOperator

public Operator cloneOperator(java.lang.String name)
Performs a deep clone of this operator chain. Use this method only if you are sure what you are doing.

Overrides:
cloneOperator in class Operator

checkIO

public java.lang.Class<?>[] checkIO(java.lang.Class<?>[] input)
                             throws IllegalInputException,
                                    WrongNumberOfInnerOperatorsException
This method checks if inner operators can handle their input and deliver the necessary output. Depending on the return value of the method shouldReturnInnerOutput() this method returns

Overrides:
checkIO in class Operator
Throws:
IllegalInputException
WrongNumberOfInnerOperatorsException

shouldReturnInnerOutput

protected boolean shouldReturnInnerOutput()
Indicates if inner output should be delivered by this operator chain. Default is false. Operators which want to change this default behaviour should override this method and should return true. In this case the method checkIO would not longer return the result of Operator.getDeliveredOutputClasses() but of getAllOutputClasses(Class[]).


shouldAddNonConsumedInput

protected boolean shouldAddNonConsumedInput()

addOperator

public final int addOperator(Operator o)
Adds a new inner operator at the last position. The returned index is the position of the added operator with respect to all operators (including the disabled operators).


addOperator

public final int addOperator(Operator operator,
                             int index)
Adds the given operator at the given position. Please note that all operators (including the disabled operators) are used for position calculations.


registerOperator

protected void registerOperator(Process process)
Register this operator chain and all of its children in the given process. This might change the name of the operator.

Overrides:
registerOperator in class Operator

unregisterOperator

protected void unregisterOperator(Process process)
Unregisters this chain and all of its children from the given process.

Overrides:
unregisterOperator in class Operator

removeOperator

protected final void removeOperator(Operator operator)
Removes the given operator from this operator chain. Do not use this method to actually remove an operator from an operator chain. Use operator.remove() instead. This method will be invoked by the remove() method (which also performs some other actions).


getOperator

public Operator getOperator(int i)
Returns the i-th inner operator.


getOperators

public java.util.Iterator<Operator> getOperators()
Returns an iterator over all Operators.


getAllInnerOperators

public java.util.List<Operator> getAllInnerOperators()
Returns recursively all child operators independently if they are activated or not.


getNumberOfOperators

public int getNumberOfOperators()
Returns the number of all enabled inner operators.


getNumberOfAllOperators

public int getNumberOfAllOperators()
Returns the number of all inner operators (including the disabled operators). Mainly used for GUI purposes. Operators should use getNumberOfOperators().


getOperatorFromAll

public Operator getOperatorFromAll(int i)
Returns the i-th operator. In contrast to the method getOperator(int i) this method also uses disabled operators. Mainly used for GUI purposes. Other operators should use the method getOperator(int i) which only delivers enabled inner operators.


getIndexOfOperator

public int getIndexOfOperator(Operator operator,
                              boolean useDisabled)
Returns the index of the given operator in the list of children. If useDisabled is true, disabled operators are also used for index calculations.


getInnerOperatorForName

public Operator getInnerOperatorForName(java.lang.String name)
Returns the inner operator named name or null if no such operator exists.


processStarts

public void processStarts()
                   throws OperatorException
Invokes the super method and the method for all children.

Overrides:
processStarts in class Operator
Throws:
OperatorException

processFinished

public void processFinished()
                     throws OperatorException
Invokes the super method and the method for all children.

Overrides:
processFinished in class Operator
Throws:
OperatorException

apply

public IOObject[] apply()
                 throws OperatorException
Applies all inner operators. The input to this operator becomes the input of the first inner operator. The latter's output is passed to the second inner operator and so on. Note to subclassers: If subclasses (for example wrappers) want to make use of this method remember to call exactly this method (super.apply()) and do not call super.apply(IOContainer) erroneously which will result in an infinite loop.

Specified by:
apply in class Operator
Returns:
the last inner operator's output or the input itself if the chain is empty.
Throws:
OperatorException

performAdditionalChecks

public void performAdditionalChecks()
                             throws UserError
This method invokes the additional check method for each child. Subclasses which override this method to perform a check should also invoke super.performAdditionalChecks()!

Overrides:
performAdditionalChecks in class Operator
Throws:
UserError

checkProperties

public int checkProperties()
Will throw an exception if a non optional property has no default value and is not defined by user.

Overrides:
checkProperties in class Operator

checkDeprecations

public int checkDeprecations()
Will count an the number of deprecated operators, i.e. the operators which Operator.getDeprecationInfo() method does not return null. Returns the total number of deprecations.

Overrides:
checkDeprecations in class Operator

checkNumberOfInnerOperators

public int checkNumberOfInnerOperators()
Checks if the number of inner operators lies between MinInnerOps and MaxInnerOps. Performs the check for all operator chains which are children of this operator chain.


createExperimentTree

@Deprecated
protected java.lang.String createExperimentTree(int indent,
                                                           java.lang.String selfPrefix,
                                                           java.lang.String childPrefix,
                                                           Operator markOperator,
                                                           java.lang.String mark)
Deprecated. Use createProcessTree(int,String,String,Operator,String) instead

Returns this OperatorChain's name and class and the ExperimentTrees of the inner operators.

Overrides:
createExperimentTree in class Operator

createProcessTree

protected java.lang.String createProcessTree(int indent,
                                             java.lang.String selfPrefix,
                                             java.lang.String childPrefix,
                                             Operator markOperator,
                                             java.lang.String mark)
Returns this OperatorChain's name and class and the process trees of the inner operators.

Overrides:
createProcessTree in class Operator

getInnerOperatorsXML

protected final java.lang.String getInnerOperatorsXML(java.lang.String indent,
                                                      boolean hideDefault)
Returns the XML representation for all inner operators.

Overrides:
getInnerOperatorsXML in class Operator

clearErrorList

public void clearErrorList()
Clears the error list for this operator (by invoking the super method) and all children.

Overrides:
clearErrorList in class Operator
See Also:
Operator.addError(String)


Copyright © 2001-2009 by Rapid-I