Class UtilityNode

All Implemented Interfaces:
CostSet, Countable, Serializable, Iterable<CostSet.Entry>

public class UtilityNode extends FormulaNode
A cost set node that represents a utility expression. When a utility node's character is null, it represents the author's utility; otherwise, it represents that character's utility. Each branch of the conditional utility expression is represented by a goal node.
Author:
Stephen G. Ware
See Also:
  • Field Details

    • character

      public final Character character
      The character whose utility this node represents, or null for the author's utility
    • label

      public final Conditional<Disjunction<Clause<Precondition>>> label
      The conditional numeric expression that defines a utility value depending on the situation
    • goals

      public final List<GoalNode> goals
      A list of goal nodes that correspond to the branches of the conditional utility expression and which can cause this node to have different values
    • range

      protected final Range range
      The set of possible values this utility expression can have and their associated costs
  • Constructor Details

    • UtilityNode

      protected UtilityNode(HeuristicGraph graph, Character character, Conditional<Disjunction<Clause<Precondition>>> label)
      Constructs a new utility node that belongs to a given graph and represents a given utility.
      Parameters:
      graph - the graph this node belongs to
      character - the character whose utility this node represents, or null for the author
      label - the numeric utility expression this node represents
  • Method Details

    • size

      public final int size()
      Description copied from interface: Countable
      Returns the number of elements in this collection
      Returns:
      the number of elements in this collection
    • iterator

      public final Iterator<CostSet.Entry> iterator()
    • getValue

      public final Value getValue(int index)
      Description copied from interface: CostSet
      Returns the value at a given index in the set. The cost of value can be accessed via CostSet.getCost(int).
      Parameters:
      index - the index of the desired value
      Returns:
      the value at that index
    • getCost

      public final double getCost(int index)
      Description copied from interface: CostSet
      Returns the cost of the value at a given index in the set. The value itself can be accessed via CostSet.getValue(int).
      Parameters:
      index - the index of the value whose cost is desired
      Returns:
      the cost of the value at that index
    • getCost

      public final double getCost(Comparison.Operator operator, Value value)
      Description copied from interface: CostSet
      Returns the cost of some value in this set satisfying the given comparison operator when it is on the left and a given value is on the right. For example, if this method is called with the greater than operator and the value 0, it means "what is the cost of this set having a value above 0?"
      Parameters:
      operator - the comparison operator to satisfy
      value - the value on the right hand side of the comparison
      Returns:
      the cost of some value in this set that satisfies the comparison when it is on the left hand side of the comparison
    • setCost

      protected boolean setCost(Value value, double cost)
      Sets the cost of this node's utility expression having the given value. The value's cost will only be updated if the given cost is less than the current cost of that value.
      Overrides:
      setCost in class FormulaNode
      Parameters:
      value - a value that the utility expression can now have
      cost - the cost of the utility expression having that value
      Returns:
      true if the cost of that value was updated, or false if this node's state did not change
    • reset

      protected void reset()
      Description copied from class: Node
      Returns this node to its default state.
      Overrides:
      reset in class Node