gov.sandia.cognition.evaluator
Class CompositeEvaluatorPair<InputType,IntermediateType,OutputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.DefaultPair<Evaluator<? super InputType,? extends IntermediateType>,Evaluator<? super IntermediateType,? extends OutputType>>
          extended by gov.sandia.cognition.evaluator.CompositeEvaluatorPair<InputType,IntermediateType,OutputType>
Type Parameters:
InputType - The input type for the first evaluator. This is also the input type of the composite evaluator.
IntermediateType - The output of the first evaluator and input to the second evaluator.
OutputType - The output type of the second evaluator. This is also the output type of the composite evaluator.
All Implemented Interfaces:
Evaluator<InputType,OutputType>, CloneableSerializable, Pair<Evaluator<? super InputType,? extends IntermediateType>,Evaluator<? super IntermediateType,? extends OutputType>>, Serializable, Cloneable
Direct Known Subclasses:
LogisticRegression.Function

@CodeReview(reviewer="Kevin R. Dixon",
            date="2008-12-02",
            changesNeeded=false,
            comments={"I *really* don\'t like the names used by this class.","\'first\' and \'second\' are ambiguous about which one gets fired first.","This is address by the comments, but I would still prefer to see the member names changed.","I\'m not going to flunk this, but I\'m just going on record here."})
public class CompositeEvaluatorPair<InputType,IntermediateType,OutputType>
extends DefaultPair<Evaluator<? super InputType,? extends IntermediateType>,Evaluator<? super IntermediateType,? extends OutputType>>
implements Evaluator<InputType,OutputType>, Serializable

Implements a composition of two evaluators. The input is passed to the first then the output of the first is passed to the second, and the output of the second is returned. If the first evaluator is f1, the second is f2, and the input is x, the composition is f2(f1(x)).

Since:
2.1
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
 
Fields inherited from class gov.sandia.cognition.util.DefaultPair
first, second
 
Constructor Summary
CompositeEvaluatorPair()
          Creates a new CompositeEvalutor.
CompositeEvaluatorPair(Evaluator<? super InputType,? extends IntermediateType> first, Evaluator<? super IntermediateType,? extends OutputType> second)
          Creates a new CompositeEvaluatorPair from the two given evaluators.
 
Method Summary
static
<InputType,IntermediateType,OutputType>
CompositeEvaluatorPair<InputType,IntermediateType,OutputType>
create(Evaluator<? super InputType,? extends IntermediateType> first, Evaluator<? super IntermediateType,? extends OutputType> second)
          A convenience method for creating composite evaluators.
 OutputType evaluate(InputType input)
          Evaluates the function on the given input and returns the output.
 
Methods inherited from class gov.sandia.cognition.util.DefaultPair
clone, create, equals, equals, getFirst, getSecond, hashCode, mergeCollections, setFirst, setSecond
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeEvaluatorPair

public CompositeEvaluatorPair()
Creates a new CompositeEvalutor. The two internal evaluators are initialized to null.


CompositeEvaluatorPair

public CompositeEvaluatorPair(Evaluator<? super InputType,? extends IntermediateType> first,
                              Evaluator<? super IntermediateType,? extends OutputType> second)
Creates a new CompositeEvaluatorPair from the two given evaluators.

Parameters:
first - The first evaluator.
second - The second evaluator.
Method Detail

evaluate

public OutputType evaluate(InputType input)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Specified by:
evaluate in interface Evaluator<InputType,OutputType>
Parameters:
input - The input to evaluate.
Returns:
The output produced by evaluating the input.

create

public static <InputType,IntermediateType,OutputType> CompositeEvaluatorPair<InputType,IntermediateType,OutputType> create(Evaluator<? super InputType,? extends IntermediateType> first,
                                                                                                                           Evaluator<? super IntermediateType,? extends OutputType> second)
A convenience method for creating composite evaluators.

Type Parameters:
InputType - The input type for the first evaluator.
IntermediateType - The output of the first evaluator and input to the second evaluator.
OutputType - The output type of the second evaluator.
Parameters:
first - The first evaluator.
second - The second evaluator.
Returns:
A new CompositeEvaluatorPair from the two given evaluators.