Package FAtiMA.Core.plans
Class Plan
java.lang.Object
FAtiMA.Core.plans.Plan
- All Implemented Interfaces:
Serializable,Cloneable
Represents a plan and implements part of its functionality
- Author:
- Joao Dias
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a binding constraint to the plan of the form [X]/John or [X]/[X23] or [X]!=LukevoidAddBindingConstraints(ArrayList<Substitution> substs) Adds a set of binding constraint to the plan of the form [X]/John or [X]/[X23] or [X]!=LukevoidAdds a CausalLink of the Form A--p-->B to the PlanvoidAdds a new operator to the planvoidAdds an Ordering Constraint of the Type A > BvoidAddOrderingConstraint(Integer before, Integer after) Adds an Ordering Constraint of the Type A > BvoidChecks if any of the plan's operators introduced a causal conflict with an existing CausalLinkvoidChecks if any of the plan's operators has a conflict with a protected condition of an InterestGoalbooleanCheckRedundantStep(Integer opID) Checks if a given Operator is redundant and not needed anymore, because the CausalLinks it establishes are not needed anymore.clone()Clones this Plan, returning an equal hard copy.intCompare(IPlanningOperator op1, IPlanningOperator op2) Compares two operators, taking into account the existing ordering constraints in the plan, and specifies which one must become after the otherintCompares two Operators, taking into account the existing ordering constraints in the plan, and specifies which one must become after the othervoiddebug()Gets the special Finish StepGets a list with the first actions in a plan - DO NOT USE this method if you want to execute the actions.intgetID()Gets a list of CausalConflicts ignored due to emotion-focused coping strategies (denial or whishfull thinking)getLinks()Gets the plan CausalLinksGets the plan's OpenPreconditionsgetOperator(Integer stepID) Gets the plan's operator who's ID is the received IDGets the OrderConstraints or OrderRelations in the planfloatgets the plan's probability of successgetStart()Gets the special Start StepgetSteps()Gets all the plan's stepsGets the plan's threats to InterestGoalsfloath(AgentModel am) Gets a heuristic value H for the plan.voidIgnoreConflict(AgentModel am, CausalConflictFlaw flaw) Ignores a given CausalConflict.booleanbooleanisValid()indicates if the plan is valid or notNextFlaw()Gets the next CausalConflictFlaw in the planintNumberOfSourceLinks(Integer stepID) Gets the number of CausalLinks where the received Step participates as the Source for the CausalLink, i.e., the method determines how many CausalLinks the Step supportsvoidRemoveCausalLink(CausalLink link) Removes a CausalLink from the planvoidRemoveCausalLinks(Integer stepID) Removes all the CausalLinks that protected a given step's preconditionsvoidRemoveOpenPreconditions(Integer stepID) Remove all OpenPreconditions referenced by a given StepvoidRemoveOperator(Integer operatorID) Removes an Operator from the planvoidRemoveOrderingConstraint(OrderingConstraint orderConstraint) Removes an OrderingConstraint between two steps (A > B) from the planvoidRemoveOrderingConstraints(Integer stepID) Removes all OrderingRelations refering to a given StepvoidReplaceUnboundVariables(int variableID) static voidtoString()Converts the plan to a StringGets the next action that we must execute in the plan in order to achieve itUpdatePlan(AgentModel am) Method that implements the Continuous Planner features.voidRequests an explicit recalculation of a plan's probability.
-
Constructor Details
-
Plan
protected Plan() -
Plan
public Plan(ArrayList<ProtectedCondition> protectedConditions, ArrayList<Condition> finishConditions)
-
-
Method Details
-
setDetectThreatStrategy
-
AddBindingConstraint
Adds a binding constraint to the plan of the form [X]/John or [X]/[X23] or [X]!=Luke- Parameters:
bind- - the binding constraint to add (Substitution)- See Also:
-
AddBindingConstraints
Adds a set of binding constraint to the plan of the form [X]/John or [X]/[X23] or [X]!=Luke- Parameters:
substs- - a list of binding constraints to add (Substitutions)- See Also:
-
AddLink
Adds a CausalLink of the Form A--p-->B to the Plan- Parameters:
l- - the CausalLink to add- See Also:
-
AddOrderingConstraint
Adds an Ordering Constraint of the Type A > B- Parameters:
order- - the OrderConstraint to add
-
AddOperator
Adds a new operator to the plan- Parameters:
op- - the operator to add
-
CheckProtectedConstraints
public void CheckProtectedConstraints()Checks if any of the plan's operators has a conflict with a protected condition of an InterestGoal -
CheckCausalConflicts
public void CheckCausalConflicts()Checks if any of the plan's operators introduced a causal conflict with an existing CausalLink -
Compare
Compares two operators, taking into account the existing ordering constraints in the plan, and specifies which one must become after the other- Parameters:
op1- - The left operator to compareop2- - The right operator to compare- Returns:
- Returns -1 if the operator op1 must become before op2, +1 if op1 must become after op2 and 0 if there is no ordering contraint between the two operators
-
Compare
Compares two Operators, taking into account the existing ordering constraints in the plan, and specifies which one must become after the other- Parameters:
op1- - The id of the left operator to compareop2- - The id of the right operator to compare- Returns:
- Returns -1 if the operator op1 must become before op2, +1 if op1 must become after op2 and 0 if there is no ordering contraint between the two operators
-
UpdatePlan
Method that implements the Continuous Planner features. It is responsible for detecting if the plan is not consistent with the world state anymore, and to fix such continuous planning flaws. This method should be called whenever the world changes. -
CheckRedundantStep
Checks if a given Operator is redundant and not needed anymore, because the CausalLinks it establishes are not needed anymore.- Parameters:
opID- - the ID in the plan of the operator to remove- Returns:
- true if the operator is redundant, false otherwise
-
clone
Clones this Plan, returning an equal hard copy. If the new plan is changed afterwards, the original plan remains the same. -
getID
public int getID() -
getFinish
Gets the special Finish Step- Returns:
- the Finish Step
-
getIgnoredConflicts
Gets a list of CausalConflicts ignored due to emotion-focused coping strategies (denial or whishfull thinking)- Returns:
- an ArrayList with ignored CausalConflicts
-
getLinks
Gets the plan CausalLinks- Returns:
- an ArrayList with all the plan's CausalLinks
-
getOpenPreconditions
Gets the plan's OpenPreconditions- Returns:
- an ArrayList with all the plan's preconditions
-
debug
public void debug() -
getOrderingConstraints
Gets the OrderConstraints or OrderRelations in the plan- Returns:
- an ArrayList with OrderRelations between the distinct steps in the plan
-
getProbability
gets the plan's probability of success- Returns:
- the plan's probability
-
getOperator
Gets the plan's operator who's ID is the received ID- Parameters:
stepID- - the ID of the Step in the plan to be searched- Returns:
- the PlanningOperator that corresponds to the received ID
-
UpdateProbabilities
public void UpdateProbabilities()Requests an explicit recalculation of a plan's probability. This method must be called whenever there is a change in a plan that may lead to different success probability -
getStart
Gets the special Start Step- Returns:
- the Start Step
-
getSteps
Gets all the plan's steps- Returns:
- an ArrayList with all the plan's steps
-
getThreatenedInterestConstraints
Gets the plan's threats to InterestGoals- Returns:
- an ArrayList with the plan's GoalThreats to InterestGoals
-
h
Gets a heuristic value H for the plan. Useful for comparing plans. The lowest value of H corresponds to the likely better plan to continue planning.- Returns:
- the value H
-
IgnoreConflict
Ignores a given CausalConflict. This corresponds to the Wishfull thinking/Denial emotion-focused coping strategy.- Parameters:
flaw- - the CausalConflictFlaw to ignore
-
isFinished
public boolean isFinished() -
isValid
public boolean isValid()indicates if the plan is valid or not- Returns:
- true if the plan is valid, i.e., it does not have unsolvable causal conflicts and cycles in the OrderRelations
-
NextFlaw
Gets the next CausalConflictFlaw in the plan- Returns:
- null if there are no CausalConflicts in the plan, otherwise it returns the next CausalConflict in the list
-
NumberOfSourceLinks
Gets the number of CausalLinks where the received Step participates as the Source for the CausalLink, i.e., the method determines how many CausalLinks the Step supports- Parameters:
stepID- - the ID of the step to calculate the result- Returns:
- the number of CausalLinks that the step supports
-
RemoveOperator
Removes an Operator from the plan- Parameters:
operatorID- - the ID of the operator to be removed
-
RemoveCausalLink
Removes a CausalLink from the plan- Parameters:
link- - the link to be removed
-
RemoveCausalLinks
Removes all the CausalLinks that protected a given step's preconditions- Parameters:
stepID- - the ID of the step that we want to remove the CausalLinks
-
RemoveOpenPreconditions
Remove all OpenPreconditions referenced by a given Step- Parameters:
stepID- - the ID of the step that we want to remove its preconditions from the OpenPreconditions list
-
RemoveOrderingConstraint
Removes an OrderingConstraint between two steps (A > B) from the plan- Parameters:
orderConstraint- - The ordering constraint to remove
-
RemoveOrderingConstraints
Removes all OrderingRelations refering to a given Step- Parameters:
stepID- - the ID of the step to remove from OrderRelations
-
toString
Converts the plan to a String -
UnexecutedAction
Gets the next action that we must execute in the plan in order to achieve it- Returns:
- the next action to execute
-
GetFirstActions
Gets a list with the first actions in a plan - DO NOT USE this method if you want to execute the actions. Use it only to know which ones should be executed first. This is a simpler method that does not guarantee that you can indeed execute the action. If you want to execute an action, use the GetNextAction method instead- Returns:
- a list with steps that are the first to be executed in a plan
-
AddOrderingConstraint
Adds an Ordering Constraint of the Type A > B- Parameters:
before- - the id of the step A in A > Bafter- - the id of the step B in A > B
-
ReplaceUnboundVariables
public void ReplaceUnboundVariables(int variableID)
-