Package FAtiMA.Core.plans
Class Step
java.lang.Object
FAtiMA.Core.plans.Step
- All Implemented Interfaces:
IPlanningOperator,IGroundable,Serializable,Cloneable
Represents a plan action/step/operator. Based in Strips, but the effects
have associated probabilities.
- Author:
- Joao Dias
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an effect to the StepvoidAddPrecondition(Condition cond) Adds a precondition to the StepvoidChecks if the specification of a step is correct.booleanChecks if the Step's preconditions are verified in the current State, i.e.clone()Clones this Step, returning an equal copy.voidDecreases a Step's probability of execution by a fixed ammount.booleanCompares this step with another received operator to see if they are equalgetAgent()Gets the name of the agent that executes the actionGets the step's effect with the given IDGets the step's effectsgetID()Gets the ID of the Step in the plangetKey()getName()Gets the Step's namegetPrecondition(Integer preconditionID) Gets the step's precondition with the given IDGets the preconditions of the StepfloatGets the Step's probability of executionvoidIncreases a Step's probability of execution by a fixed ammount.booleanIndicates 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(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.voidSets the Step's namevoidSets 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 AgenttoString()Converts the step into a StringvoidUpdates the probabilities of the step's effects by checking if the effects did happen or not after the execution of the step
-
Constructor Details
-
Step
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, ArrayList<Condition> preconditions, 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 Details
-
getKey
-
AddEffect
Adds an effect to the Step- Parameters:
effect- - the Effect to Add
-
AddPrecondition
Adds a precondition to the Step- Parameters:
cond- - the precondition to add
-
DecreaseProbability
Decreases a Step's probability of execution by a fixed ammount. -
IncreaseProbability
Increases a Step's probability of execution by a fixed ammount. -
getProbability
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
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:
-
checkPreconditions
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
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
Gets the step's effects- Specified by:
getEffectsin interfaceIPlanningOperator- Returns:
- an ArrayList with all the step's effects
-
getID
Gets the ID of the Step in the plan- Specified by:
getIDin interfaceIPlanningOperator- Returns:
- - the Step's ID
-
getName
Gets the Step's name- Specified by:
getNamein interfaceIPlanningOperator- Returns:
- the Step's name
-
getAgent
Gets the name of the agent that executes the action- Specified by:
getAgentin interfaceIPlanningOperator- Returns:
- the name of the executing action
-
getPreconditions
Gets the preconditions of the Step- Specified by:
getPreconditionsin interfaceIPlanningOperator- Returns:
- an ArrayList with all the Step's preconditions
-
getPrecondition
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
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
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 classObject- 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
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:
-
MakeGround
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:
-
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
Sets the Step's name- Parameters:
name- - the new Name of the Step
-
setID
Sets the Step's ID in the plan- Specified by:
setIDin interfaceIPlanningOperator- Parameters:
id- - the new Step's ID
-
toString
Converts the step into a String
-