Package FAtiMA.Core.plans
Class Step
- java.lang.Object
-
- FAtiMA.Core.plans.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidAddEffect(Effect effect)Adds an effect to the StepvoidAddPrecondition(Condition cond)Adds a precondition to the StepvoidCheckIntegrity(IntegrityValidator val)Checks if the specification of a step is correct.booleancheckPreconditions(AgentModel am)Checks if the Step's preconditions are verified in the current State, i.e.java.lang.Objectclone()Clones this Step, returning an equal copy.voidDecreaseProbability(AgentModel am)Decreases a Step's probability of execution by a fixed ammount.booleanequals(IPlanningOperator op)Compares this step with another received operator to see if they are equalSymbolgetAgent()Gets the name of the agent that executes the actionEffectgetEffect(java.lang.Integer effectID)Gets the step's effect with the given IDjava.util.ArrayList<Effect>getEffects()Gets the step's effectsjava.lang.IntegergetID()Gets the ID of the Step in the planjava.lang.StringgetKey()NamegetName()Gets the Step's nameConditiongetPrecondition(java.lang.Integer preconditionID)Gets the step's precondition with the given IDjava.util.ArrayList<Condition>getPreconditions()Gets the preconditions of the StepfloatgetProbability(AgentModel am)Gets the Step's probability of executionvoidIncreaseProbability(AgentModel am)Increases a Step's probability of execution by a fixed ammount.booleanisGrounded()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.voidMakeGround(Substitution subst)Applies a set of substitutions to the object, grounding it.voidMakeGround(java.util.ArrayList<Substitution> bindings)Applies a set of substitutions to the object, grounding it.voidReplaceUnboundVariables(int variableID)Replaces all unbound variables in the object by applying a numeric identifier to each one.voidsetAction(Name name)Sets the Step's namevoidsetID(java.lang.Integer id)Sets the Step's ID in the planvoidsetProbability(float baseProb)Sets the Step's base probability of executionvoidSetSelfExecutable(boolean selfExecutable)Sets if the Action can be executed by the self Agentjava.lang.StringtoString()Converts the step into a StringvoidupdateEffectsProbability(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
-
-
-
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 actionaction- - the name of the action or stepprobability- - 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 actionaction- - the name of the action or steppreconditions- - 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.
-
getProbability
public float getProbability(AgentModel am)
Gets the Step's probability of execution- Specified by:
getProbabilityin interfaceIPlanningOperator- 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:
updateEffectsProbabilityin interfaceIPlanningOperator
-
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 nameUnknownSpeechActException- - 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:
checkPreconditionsin interfaceIPlanningOperator- 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:
equalsin interfaceIPlanningOperator- 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:
getEffectsin interfaceIPlanningOperator- 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:
getIDin interfaceIPlanningOperator- Returns:
- - the Step's ID
-
getName
public Name getName()
Gets the Step's name- Specified by:
getNamein interfaceIPlanningOperator- Returns:
- the Step's name
-
getAgent
public Symbol getAgent()
Gets the name of the agent that executes the action- Specified by:
getAgentin interfaceIPlanningOperator- Returns:
- the name of the executing action
-
getPreconditions
public java.util.ArrayList<Condition> getPreconditions()
Gets the preconditions of the Step- Specified by:
getPreconditionsin interfaceIPlanningOperator- 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:
getPreconditionin interfaceIPlanningOperator- 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:
getEffectin interfaceIPlanningOperator- 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:
clonein interfaceIPlanningOperator- Overrides:
clonein classjava.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:
ReplaceUnboundVariablesin interfaceIGroundable- 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:
MakeGroundin interfaceIGroundable- 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:
MakeGroundin interfaceIGroundable- 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:
isGroundedin interfaceIGroundable- 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:
setIDin interfaceIPlanningOperator- Parameters:
id- - the new Step's ID
-
toString
public java.lang.String toString()
Converts the step into a String- Overrides:
toStringin classjava.lang.Object- Returns:
- the converted String
-
-