Class Step

java.lang.Object
FAtiMA.Core.plans.Step
All Implemented Interfaces:
IPlanningOperator, IGroundable, Serializable, Cloneable

public class Step extends Object implements IPlanningOperator, Cloneable, Serializable
Represents a plan action/step/operator. Based in Strips, but the effects have associated probabilities.
Author:
Joao Dias
See Also:
  • Constructor Details

    • Step

      public Step(Symbol agent, Name action, float probability)
      Creates a new Step
      Parameters:
      agent - - the name of the agent that executes the action
      action - - the name of the action or step
      probability - - the likelihood of the action's execution by another agent
    • Step

      public Step(Symbol agent, Name action, float probability, ArrayList<Condition> preconditions, ArrayList<Effect> effects)
      Creates a new Step
      Parameters:
      agent - - the name of the agent that is going to execute the action
      action - - the name of the action or step
      preconditions - - the step's preconditions (a list of conditions)
      effects - - the step's effects (a list of effects)
      probability - - the likelihood of the action's execution by another agent
  • Method Details

    • getKey

      public String getKey()
    • AddEffect

      public void AddEffect(Effect effect)
      Adds an effect to the Step
      Parameters:
      effect - - the Effect to Add
    • AddPrecondition

      public void AddPrecondition(Condition cond)
      Adds a precondition to the Step
      Parameters:
      cond - - the precondition to add
    • DecreaseProbability

      public void DecreaseProbability(AgentModel am)
      Decreases a Step's probability of execution by a fixed ammount.
    • IncreaseProbability

      public void IncreaseProbability(AgentModel am)
      Increases a Step's probability of execution by a fixed ammount.
    • getProbability

      public float getProbability(AgentModel am)
      Gets the Step's probability of execution
      Specified by:
      getProbability in interface IPlanningOperator
      Returns:
      the steps's probability
    • setProbability

      public void setProbability(float baseProb)
      Sets the Step's base probability of execution
    • updateEffectsProbability

      public void updateEffectsProbability(AgentModel am)
      Updates the probabilities of the step's effects by checking if the effects did happen or not after the execution of the step
      Specified by:
      updateEffectsProbability in interface IPlanningOperator
    • CheckIntegrity

      Checks if the specification of a step is correct. The method checks if any unbound variables used in the step's effects and preconditions are also used in the step's name (they must be). Additionally, it determines if a existing precondition is unachievable, i.e. there is no effect from any other step that achieves the precondition. Additionaly, it also verifies if Speech-Act related effects correspond to predifined SpeechActs.
      Parameters:
      val - - an IntegrityValidator used to validate the SpeechActs effects
      Throws:
      UnspecifiedVariableException - - if the Step uses unbound variables not specified in the Step's name
      UnknownSpeechActException - - if the Step uses a Speech-Act effect not defined
      See Also:
    • checkPreconditions

      public boolean checkPreconditions(AgentModel am)
      Checks if the Step's preconditions are verified in the current State, i.e. the KnowledgeBase
      Specified by:
      checkPreconditions in interface IPlanningOperator
      Returns:
      true if all preconditions are true according to the world state stored in the KnowledgeBase, false otherwise
    • equals

      public boolean equals(IPlanningOperator op)
      Compares this step with another received operator to see if they are equal
      Specified by:
      equals in interface IPlanningOperator
      Parameters:
      op - - the planning operator to compare to
      Returns:
      true if the operators have the same ID in a plan
    • getEffects

      public ArrayList<Effect> getEffects()
      Gets the step's effects
      Specified by:
      getEffects in interface IPlanningOperator
      Returns:
      an ArrayList with all the step's effects
    • getID

      public Integer getID()
      Gets the ID of the Step in the plan
      Specified by:
      getID in interface IPlanningOperator
      Returns:
      - the Step's ID
    • getName

      public Name getName()
      Gets the Step's name
      Specified by:
      getName in interface IPlanningOperator
      Returns:
      the Step's name
    • getAgent

      public Symbol getAgent()
      Gets the name of the agent that executes the action
      Specified by:
      getAgent in interface IPlanningOperator
      Returns:
      the name of the executing action
    • getPreconditions

      public ArrayList<Condition> getPreconditions()
      Gets the preconditions of the Step
      Specified by:
      getPreconditions in interface IPlanningOperator
      Returns:
      an ArrayList with all the Step's preconditions
    • getPrecondition

      public Condition getPrecondition(Integer preconditionID)
      Gets the step's precondition with the given ID
      Specified by:
      getPrecondition in interface IPlanningOperator
      Parameters:
      preconditionID - - the id of the step's precondition
      Returns:
      the precondition
    • getEffect

      public Effect getEffect(Integer effectID)
      Gets the step's effect with the given ID
      Specified by:
      getEffect in interface IPlanningOperator
      Parameters:
      effectID - - the id of the step's effect
      Returns:
      the effect
    • SetSelfExecutable

      public void SetSelfExecutable(boolean selfExecutable)
      Sets if the Action can be executed by the self Agent
      Parameters:
      selfExecutable -
    • clone

      public Object clone()
      Clones this Step, returning an equal copy. If this clone is changed afterwards, the original object remains the same.
      Specified by:
      clone in interface IPlanningOperator
      Overrides:
      clone in class Object
      Returns:
      The Step's copy.
    • ReplaceUnboundVariables

      public void ReplaceUnboundVariables(int variableID)
      Replaces all unbound variables in the object by applying a numeric identifier to each one. For example, the variable [x] becomes [x4] if the received ID is 4. Attention, this method modifies the original object.
      Specified by:
      ReplaceUnboundVariables in interface IGroundable
      Parameters:
      variableID - - the identifier to be applied
    • MakeGround

      public void MakeGround(ArrayList<Substitution> bindings)
      Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.
      Specified by:
      MakeGround in interface IGroundable
      Parameters:
      bindings - - A list of substitutions of the type "[Variable]/value"
      See Also:
    • MakeGround

      public void MakeGround(Substitution subst)
      Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.
      Specified by:
      MakeGround in interface IGroundable
      Parameters:
      subst - - a substitution of the type "[Variable]/value"
      See Also:
    • isGrounded

      public boolean isGrounded()
      Indicates if the name is grounded (no unbound variables in it's WFN) Example: Stronger(Luke,John) is grounded while Stronger(John,[X]) is not.
      Specified by:
      isGrounded in interface IGroundable
      Returns:
      true if the name is grounded, false otherwise
    • setAction

      public void setAction(Name name)
      Sets the Step's name
      Parameters:
      name - - the new Name of the Step
    • setID

      public void setID(Integer id)
      Sets the Step's ID in the plan
      Specified by:
      setID in interface IPlanningOperator
      Parameters:
      id - - the new Step's ID
    • toString

      public String toString()
      Converts the step into a String
      Overrides:
      toString in class Object
      Returns:
      the converted String