Class Step

  • All Implemented Interfaces:
    IPlanningOperator, IGroundable, java.io.Serializable, java.lang.Cloneable

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

      Constructors 
      Constructor Description
      Step​(Symbol agent, Name action, float probability)
      Creates a new Step
      Step​(Symbol agent, Name action, float probability, java.util.ArrayList<Condition> preconditions, java.util.ArrayList<Effect> effects)
      Creates a new Step
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void AddEffect​(Effect effect)
      Adds an effect to the Step
      void AddPrecondition​(Condition cond)
      Adds a precondition to the Step
      void CheckIntegrity​(IntegrityValidator val)
      Checks if the specification of a step is correct.
      boolean checkPreconditions​(AgentModel am)
      Checks if the Step's preconditions are verified in the current State, i.e.
      java.lang.Object clone()
      Clones this Step, returning an equal copy.
      void DecreaseProbability​(AgentModel am)
      Decreases a Step's probability of execution by a fixed ammount.
      boolean equals​(IPlanningOperator op)
      Compares this step with another received operator to see if they are equal
      Symbol getAgent()
      Gets the name of the agent that executes the action
      Effect getEffect​(java.lang.Integer effectID)
      Gets the step's effect with the given ID
      java.util.ArrayList<Effect> getEffects()
      Gets the step's effects
      java.lang.Integer getID()
      Gets the ID of the Step in the plan
      java.lang.String getKey()  
      Name getName()
      Gets the Step's name
      Condition getPrecondition​(java.lang.Integer preconditionID)
      Gets the step's precondition with the given ID
      java.util.ArrayList<Condition> getPreconditions()
      Gets the preconditions of the Step
      float getProbability​(AgentModel am)
      Gets the Step's probability of execution
      void IncreaseProbability​(AgentModel am)
      Increases a Step's probability of execution by a fixed ammount.
      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.
      void MakeGround​(Substitution subst)
      Applies a set of substitutions to the object, grounding it.
      void MakeGround​(java.util.ArrayList<Substitution> bindings)
      Applies a set of substitutions to the object, grounding it.
      void ReplaceUnboundVariables​(int variableID)
      Replaces all unbound variables in the object by applying a numeric identifier to each one.
      void setAction​(Name name)
      Sets the Step's name
      void setID​(java.lang.Integer id)
      Sets the Step's ID in the plan
      void setProbability​(float baseProb)
      Sets the Step's base probability of execution
      void SetSelfExecutable​(boolean selfExecutable)
      Sets if the Action can be executed by the self Agent
      java.lang.String toString()
      Converts the step into a String
      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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • 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,
                    java.util.ArrayList<Condition> preconditions,
                    java.util.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 Detail

      • getKey

        public java.lang.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.
      • 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

        public void CheckIntegrity​(IntegrityValidator val)
                            throws UnspecifiedVariableException,
                                   UnknownSpeechActException
        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:
        IntegrityValidator
      • 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 java.util.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 java.lang.Integer getID()
        Gets the ID of the Step in the plan
        Specified by:
        getID in interface IPlanningOperator
        Returns:
        - the Step's ID
      • 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 java.util.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​(java.lang.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​(java.lang.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 java.lang.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 java.lang.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​(java.util.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:
        Substitution
      • 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:
        Substitution
      • 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​(java.lang.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 java.lang.String toString()
        Converts the step into a String
        Overrides:
        toString in class java.lang.Object
        Returns:
        the converted String