com.ace.moab.api.node
Class FunctionExpression

java.lang.Object
  extended by com.ace.moab.api.node.FunctionExpression
All Implemented Interfaces:
java.lang.Comparable<FunctionExpression>

public class FunctionExpression
extends java.lang.Object
implements java.lang.Comparable<FunctionExpression>

This class represents a node priority function expression, which is a part of any priority function. An expression is simply an attribute multiplied by a factor. A complete function can have any number of expressions, although it is useless to have multiple expressions that have the same attribute.

Author:
Scott Brown

Constructor Summary
FunctionExpression()
          Default constructor.
FunctionExpression(PriorityComponent attribute, double factor)
           Constructor that creates a complete Function Expression.
 
Method Summary
 int compareTo(FunctionExpression o)
          
 double evaluateForNode(MoabNode node)
           Evaluates this function expression for a given node.
 PriorityComponent getAttribute()
           Get the attribute of a node that is evaluated to a numerical value.
 double getFactor()
           Get the value that is multiplied to the attribute to evaluate the expression.
static FunctionExpression parseExpression(java.lang.String exprString)
          Parses a function expression from a Moab string.
 void setAttribute(PriorityComponent attribute)
           Sets the attribute of the function expression.
 void setFactor(double factor)
           Sets the factor (coefficient) of the function expression.
 java.lang.String toMoabString()
          Reports the function expression in a Moab-parsable string format.
 java.lang.String toString()
          Reports the function expression in a human-readable string format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionExpression

public FunctionExpression()
Default constructor. No attribute or factor set.


FunctionExpression

public FunctionExpression(PriorityComponent attribute,
                          double factor)

Constructor that creates a complete Function Expression. This sets the attribute and factor attributes of the function expression.

The attribute must be a valid PriorityComponent whose corresponding NodeTableColumn attribute is a Numerical Type or an IllegalArgumentException will be thrown.

Parameters:
attribute - the attribute of the expression.
factor - the factor (coefficient) of the expression.
Method Detail

compareTo

public int compareTo(FunctionExpression o)

Specified by:
compareTo in interface java.lang.Comparable<FunctionExpression>

evaluateForNode

public double evaluateForNode(MoabNode node)

Evaluates this function expression for a given node. This function determines the value of the attribute field for the node, and then multiplies this value by the factor.

If the attribute of this priority function is a boolean value, this method returns 1 for the attribute value, and the result is simply the factor value.

Parameters:
node - The MoabNode which contains actual values for various attributes that will be used to evaluate the value of this expression.
Returns:
the value of the evaluated expression for the input node.

getAttribute

public PriorityComponent getAttribute()

Get the attribute of a node that is evaluated to a numerical value.

Returns:
The attribute of a node that is evaluated to a numerical value.

getFactor

public double getFactor()

Get the value that is multiplied to the attribute to evaluate the expression.

Returns:
The value that is multiplied to the attribute to evaluate the expression.

setAttribute

public void setAttribute(PriorityComponent attribute)

Sets the attribute of the function expression.

The attribute must be a valid PriorityComponent whose corresponding NodeTableColumn attribute is a Numerical Type or an IllegalArgumentException will be thrown.

Parameters:
attribute - The attribute of the function expression.

setFactor

public void setFactor(double factor)

Sets the factor (coefficient) of the function expression.

Parameters:
factor - The factor (coefficient) of the function expression.

parseExpression

public static FunctionExpression parseExpression(java.lang.String exprString)
                                          throws java.text.ParseException
Parses a function expression from a Moab string. Expected format for the string is [factor*]attribute. The factor (a double value) is not necessary. The attribute is one of the PriorityComponent attributes.

Parameters:
exprString - String representing a function expression.
Returns:
A function expression based on the input string.
Throws:
java.text.ParseException

toMoabString

public java.lang.String toMoabString()
Reports the function expression in a Moab-parsable string format.

Returns:
The function expression in a Moab-parsable string format.

toString

public java.lang.String toString()
Reports the function expression in a human-readable string format.

Overrides:
toString in class java.lang.Object
Returns:
The function expression in a human-readable string format.


Copyright © 2001-2009 Cluster Resources, Inc. All Rights Reserved.