messif.objects.util.impl
Class AggregationFunctionEvaluator

java.lang.Object
  extended by messif.objects.util.AggregationFunction
      extended by messif.objects.util.impl.AggregationFunctionEvaluator
All Implemented Interfaces:
java.io.Serializable

public class AggregationFunctionEvaluator
extends AggregationFunction

Evaluator for basic arithmetic operators and functions applied on particular sub-distances. Basic arithmetic operators (+, -, *, /, ^) and "log" and "log10" functions are supported as well as numeric constants (treated as floats).

See Also:
Serialized Form

Constructor Summary
AggregationFunctionEvaluator(java.lang.String function)
          Creates a new instance of AggregationFunctionEvaluator.
AggregationFunctionEvaluator(java.lang.String function, java.util.Map<java.lang.String,java.lang.Float> maxDistances)
          Creates a new instance of AggregationFunctionEvaluator.
 
Method Summary
 float compute(float... distances)
          Computes the value of the aggregate distance from the provided sub-distances.
 float getParameterMaximalDistance(int parameterIndex)
          Returns the maximal distance for the specified parameter of the AggregationFunction.compute(float...) function.
 java.lang.String[] getParameterNames()
          Returns the names of distance parameters (i.e. the descriptor names) for the AggregationFunction.compute(float...) function.
 java.lang.String toString()
          Returns a string representation of the encapsulated function.
 
Methods inherited from class messif.objects.util.AggregationFunction
getDistance, getDistance, getFactoryClass, setFactoryClass, valueOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AggregationFunctionEvaluator

public AggregationFunctionEvaluator(java.lang.String function,
                                    java.util.Map<java.lang.String,java.lang.Float> maxDistances)
                             throws java.lang.IllegalArgumentException
Creates a new instance of AggregationFunctionEvaluator. The specified function is parsed and compiled. Basic arithmetic operations are supported as well as numeric constants. Blank space is ignored and everything else is considered to be a variable.

Parameters:
function - the function string
maxDistances - the list of maximal distances (map values) for the variable names (map keys)
Throws:
java.lang.IllegalArgumentException - if the specified function cannot be parsed

AggregationFunctionEvaluator

public AggregationFunctionEvaluator(java.lang.String function)
                             throws java.lang.IllegalArgumentException
Creates a new instance of AggregationFunctionEvaluator. The specified function is parsed and compiled. Basic arithmetic operations are supported as well as numeric constants. Blank space is ignored and everything else is considered to be a variable.

Parameters:
function - the function string
Throws:
java.lang.IllegalArgumentException - if the specified function cannot be parsed
Method Detail

compute

public float compute(float... distances)
Description copied from class: AggregationFunction
Computes the value of the aggregate distance from the provided sub-distances. The distances array items must correspond with the parameter names as returned by AggregationFunction.getParameterNames().

Specified by:
compute in class AggregationFunction
Parameters:
distances - the distances in respective descriptors
Returns:
the aggregate distance

getParameterNames

public java.lang.String[] getParameterNames()
Description copied from class: AggregationFunction
Returns the names of distance parameters (i.e. the descriptor names) for the AggregationFunction.compute(float...) function.

Specified by:
getParameterNames in class AggregationFunction
Returns:
the list of parameter (descriptor) names of the AggregationFunction.compute(float...) function

getParameterMaximalDistance

public float getParameterMaximalDistance(int parameterIndex)
Description copied from class: AggregationFunction
Returns the maximal distance for the specified parameter of the AggregationFunction.compute(float...) function. This method returns the LocalAbstractObject.MAX_DISTANCE by default.

Overrides:
getParameterMaximalDistance in class AggregationFunction
Parameters:
parameterIndex - the index of a parameter (corresponds to the index of the parameter name as given by AggregationFunction.getParameterNames())
Returns:
the maximal distances for the parameters of the AggregationFunction.compute(float...) function

toString

public java.lang.String toString()
Returns a string representation of the encapsulated function.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the encapsulated function