Package fr.uga.pddl4j.problem.numeric
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
This class implements an arithmetic expression.
- Since:
- 4.0
- See Also:
- Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The type of the arithmetic operators. -
Field Summary
Modifier and TypeFieldDescriptionstatic int
The default numeric fluent index.static double
The default value of the arithmetic expression. -
Constructor Summary
ConstructorDescriptionArithmeticExpression(double value)
Creates an arithmetic expression of type number with a specified value.ArithmeticExpression(int index)
Creates an arithmetic expression of type variable with for a specified numeric fluent.ArithmeticExpression(int index, double value)
Creates an arithmetic expression of type variable with for a specified numeric fluent and value.Creates a deep copy of arithmetic expression from an other.ArithmeticExpression(ArithmeticOperator operator, ArithmeticExpression left, ArithmeticExpression right)
Creates an arithmetic expression of type operator. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns if an object if equal to this arithmetic expression.double
evaluate(List<NumericVariable> context)
Evaluates an arithmetic expression and returns the result of its evaluation.Returns the operator of this arithmetic expression.int
Returns the index of the numeric fluent of this arithmetic expression.getType()
Returns the type of the arithmetic expression.double
getValue()
Returns the value of the arithmetic expression.int
hashCode()
Returns the hash code value of this arithmetic expression.void
setArithmeticOpertor(ArithmeticOperator operator)
Sets the operator of this arithmetic expression.void
setNumericFluents(int index)
Sets the index of the numeric fluent of this arithmetic expression.void
setType(ArithmeticExpression.Type type)
Sets the type of this arithmetic expression.void
setValue(double value)
Sets the value of this arithmetic expression.toString()
Returns a string representation of this arithmetic expression.Methods inherited from class fr.uga.pddl4j.problem.numeric.AbstractNumericExpression
getLeftExpression, getRightExpression, setLeftExpression, setRightExpression
-
Field Details
-
DEFAULT_NUMERIC_FLUENT
public static final int DEFAULT_NUMERIC_FLUENTThe default numeric fluent index.- See Also:
- Constant Field Values
-
DEFAULT_VALUE
public static final double DEFAULT_VALUEThe default value of the arithmetic expression.- See Also:
- Constant Field Values
-
-
Constructor Details
-
ArithmeticExpression
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
Returns the type of the arithmetic expression.- Returns:
- he type of the arithmetic expression.
-
setType
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
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
Sets the operator of this arithmetic expression.- Parameters:
operator
- the operator to set.
-
evaluate
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
Returns if an object if equal to this arithmetic expression. The object is equal iff it is an instance of the classArithmeticExpression
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. -
hashCode
public int hashCode()Returns the hash code value of this arithmetic expression. -
toString
Returns a string representation of this arithmetic expression.
-