Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.epochx.representation.dbl
Class ProtectedDivisionFunction

    java.lang.Object
      com.epochx.representation.Node<TYPE>
          com.epochx.representation.FunctionNode<java.lang.Double>
              com.epochx.representation.dbl.ProtectedDivisionFunction

All Implemented Interfaces:
  java.lang.Cloneable

    public class ProtectedDivisionFunction

extends FunctionNode<java.lang.Double>

A `FunctionNode` which performs the arithmetic function of division. The division is protected to avoid the scenario where division by zero is attempted - which is undefined. Division by zero evaluates to zero.

Constructor Summary
`ProtectedDivisionFunction()` Construct a ProtectedDivisionFunction with no children.
`ProtectedDivisionFunction(java.lang.Double protectionValue)` Construct a ProtectedDivisionFunction with a protection value to assign during divide-by-zero.
`ProtectedDivisionFunction(Node<java.lang.Double> dividend, Node<java.lang.Double> divisor)` Construct a ProtectedDivisionFunction with 2 children.
`ProtectedDivisionFunction(Node<java.lang.Double> dividend, Node<java.lang.Double> divisor, java.lang.Double protectionValue)` Construct a ProtectedDivisionFunction with 2 children and a divide-by-zero protection value.

Method Summary
`java.lang.Double` | `evaluate()` Evaluating a `ProtectedDivisionFunction` involves dividing the result of evaluating both children.
`java.lang.String` | `getFunctionName()` Get the unique name that identifies this function.

Methods inherited from class com.epochx.representation.FunctionNode
`equals, toString`

Methods inherited from class com.epochx.representation.Node
`clone, getArity, getChild, getChildren, getDepth, getFunctionNodes, getLength, getNodesAtDepth, getNoDistinctFunctions, getNoDistinctTerminals, getNoFunctions, getNoTerminals, getNthNode, getTerminalNodes, hashCode, setChild, setChildren, setNthNode`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ProtectedDivisionFunction

    public ProtectedDivisionFunction()

  Construct a ProtectedDivisionFunction with no children. A default protection value that is returned in the case of divide-by-zero is set as 0.0.

### ProtectedDivisionFunction

    public ProtectedDivisionFunction(java.lang.Double protectionValue)

  Construct a ProtectedDivisionFunction with a protection value to assign during divide-by-zero. This overrides the default protection value of 0.0.

  Parameters:
    `protectionValue` - a double value to return in the case of divide-by-zeros.

### ProtectedDivisionFunction

    public ProtectedDivisionFunction(Node<java.lang.Double> dividend,
                                     Node<java.lang.Double> divisor)

  Construct a ProtectedDivisionFunction with 2 children. When evaluated, the evaluation of the first child will be divided by the evaluation of the second. A default protection value that is returned in the case of divide-by-zero is set as 0.0.

  Parameters:
    `dividend` - The first child node - the dividend.
    `divisor` - The second child node - the divisor.

### ProtectedDivisionFunction

    public ProtectedDivisionFunction(Node<java.lang.Double> dividend,
                                     Node<java.lang.Double> divisor,
                                     java.lang.Double protectionValue)

  Construct a ProtectedDivisionFunction with 2 children and a divide-by-zero protection value. When evaluated, the evaluation of the first child will be divided by the evaluation of the second. If the second (divisor) child evaluates to zero, then no division takes place and the specified protectionValue is returned.

  Parameters:
    `dividend` - The first child node - the dividend.
    `divisor` - The second child node - the divisor.
    `protectionValue` - a double value to return in the case of divide-by-zeros.

Method Detail

### evaluate

    public java.lang.Double evaluate()

  Evaluating a `ProtectedDivisionFunction` involves dividing the result of evaluating both children. If the divisor resolves to zero then the result returned will be zero to avoid the divide by zero issue.

  Specified by:
    `evaluate` in class `Node<java.lang.Double>`
  Returns:
    The result of evaluating the candidate program.

### getFunctionName

    public java.lang.String getFunctionName()

  Get the unique name that identifies this function.

  Specified by:
    `getFunctionName` in class `FunctionNode<java.lang.Double>`
  Returns:
    the unique name for the ProtectedDivisionFunction which is PDIV.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD