Class ArithmeticExpression

java.lang.Object
fr.uga.pddl4j.problem.numeric.AbstractNumericExpression
fr.uga.pddl4j.problem.numeric.ArithmeticExpression
All Implemented Interfaces:
NumericExpression, Serializable
Direct Known Subclasses:
NumericVariable

public class ArithmeticExpression extends AbstractNumericExpression
This class implements an arithmetic expression.
Since:
4.0
See Also:
Serialized Form
  • Field Details

    • DEFAULT_NUMERIC_FLUENT

      public static final int DEFAULT_NUMERIC_FLUENT
      The default numeric fluent index.
      See Also:
      Constant Field Values
    • DEFAULT_VALUE

      public static final double DEFAULT_VALUE
      The default value of the arithmetic expression.
      See Also:
      Constant Field Values
  • Constructor Details

    • ArithmeticExpression

      public ArithmeticExpression(ArithmeticExpression other)
      Creates a deep copy of arithmetic expression from an other.
      Parameters:
      other - the other arithmetic expression.
    • ArithmeticExpression

      public ArithmeticExpression(double value)
      Creates an arithmetic expression of type number with a specified value.
      Parameters:
      value - the value of this arithmetic expression of type number.
    • ArithmeticExpression

      public ArithmeticExpression(int index)
      Creates an arithmetic expression of type variable with for a specified numeric fluent.
      Parameters:
      index - the index of this numeric fluent that represents this variable.
    • ArithmeticExpression

      public ArithmeticExpression(int index, double value)
      Creates an arithmetic expression of type variable with for a specified numeric fluent and value.
      Parameters:
      index - the index of this numeric fluent that represents this variable.
      value - of this arithmetic expression.
    • ArithmeticExpression

      public ArithmeticExpression(ArithmeticOperator operator, ArithmeticExpression left, ArithmeticExpression right)
      Creates an arithmetic expression of type operator.
      Parameters:
      operator - the operator of the arithmetic expression.
      left - the left expression of the arithmetic expression.
      right - the left expression of the arithmetic expression.
  • Method Details

    • getType

      public final ArithmeticExpression.Type getType()
      Returns the type of the arithmetic expression.
      Returns:
      he type of the arithmetic expression.
    • setType

      public final void setType(ArithmeticExpression.Type type)
      Sets the type of this arithmetic expression.
      Parameters:
      type - the type of this arithmetic expression.
    • getNumericFluent

      public final int getNumericFluent()
      Returns the index of the numeric fluent of this arithmetic expression.
      Returns:
      the index of the numeric fluent of this arithmetic expression.
    • setNumericFluents

      public final void setNumericFluents(int index)
      Sets the index of the numeric fluent of this arithmetic expression.
      Parameters:
      index - the index of the numeric fluent of this arithmetic expression.
    • getValue

      public final double getValue()
      Returns the value of the arithmetic expression. The value is used when the arithmetic expression is of type NUMBER.
      Returns:
      the value of the arithmetic expression.
    • setValue

      public final void setValue(double value)
      Sets the value of this arithmetic expression.
      Parameters:
      value - the value to set.
    • getArithmeticOperator

      public final ArithmeticOperator getArithmeticOperator()
      Returns the operator of this arithmetic expression. The operator is not null if the arithmetic expression is of type operator.
      Returns:
      the operator of this arithmetic expression.
    • setArithmeticOpertor

      public final void setArithmeticOpertor(ArithmeticOperator operator)
      Sets the operator of this arithmetic expression.
      Parameters:
      operator - the operator to set.
    • evaluate

      public final double evaluate(List<NumericVariable> context)
      Evaluates an arithmetic expression and returns the result of its evaluation.
      Parameters:
      context - the context of the evaluation, i.e., the numeric variables and their respectives values.
      Returns:
      the result of the evaluation of this arithmetic expression.
    • equals

      public boolean equals(Object object)
      Returns if an object if equal to this arithmetic expression. The object is equal iff it is an instance of the class ArithmeticExpression and it has the same type. For number, both arithmetic expression must have the same value. For variable, both arithmetic expression must have the same numeric fluent. Finally, for arithmetic operator expression, both expression must have the same operator and left and right expressions.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to be compared.
      Returns:
      true if the object in parameter is equal to this arithmetic expression; false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code value of this arithmetic expression.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value of this arithmetic expression.
    • toString

      public String toString()
      Returns a string representation of this arithmetic expression.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this arithmetic expression.