Class Condition

java.lang.Object
edu.tufts.hrilab.action.Condition
All Implemented Interfaces:
Serializable

public class Condition extends Object implements Serializable
A Condition is a (set of) predicate(s) that has(ve) to hold before or during the execution of an action. It consists of one or more predicates (description of the condition) and a type (pre-condition, overall-condition).

Uses LinkedHashMap to keep key insertion order, important when you have disjunctions to keep ordering and evaluation consistent (stop evaluating once the first condition holds).

See Also:
  • Constructor Details

  • Method Details

    • applySemanticTypes

      public void applySemanticTypes(ActionDBEntry actionDBEntry)
      Using the roles from the ActionDBEntry, attempt to extract semantic type information from the roles and apply them to the predicate(s) in this Condition.
      Parameters:
      actionDBEntry -
    • getType

      public ConditionType getType()
    • isDisjunction

      public boolean isDisjunction()
    • getPredicates

      public Map<Predicate,Observable> getPredicates()
    • bindToContext

      public Condition bindToContext(ArgumentBasedContext context)
      Bind each predicate in condition to a context.
      Parameters:
      context - Context in which to look up variable bindings
      Returns:
      New Condition with unbound arguments bound, if possible.
    • holds

      public Justification holds(ActionContext context, StateMachine sm)
      Verify if condition holds.
      Parameters:
      context - context providing variable bindings
      sm - state machine in which condition is checked
      Returns:
      justification with bindings. true if condition holds.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object