Package FAtiMA.Core.plans
Class Plan
- java.lang.Object
-
- FAtiMA.Core.plans.Plan
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class Plan extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableRepresents a plan and implements part of its functionality- Author:
- Joao Dias
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPlan()Plan(java.util.ArrayList<ProtectedCondition> protectedConditions, java.util.ArrayList<Condition> finishConditions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidAddBindingConstraint(Substitution bind)Adds a binding constraint to the plan of the form [X]/John or [X]/[X23] or [X]!=LukevoidAddBindingConstraints(java.util.ArrayList<Substitution> substs)Adds a set of binding constraint to the plan of the form [X]/John or [X]/[X23] or [X]!=LukevoidAddLink(CausalLink l)Adds a CausalLink of the Form A--p-->B to the PlanvoidAddOperator(IPlanningOperator op)Adds a new operator to the planvoidAddOrderingConstraint(OrderingConstraint order)Adds an Ordering Constraint of the Type A > BvoidAddOrderingConstraint(java.lang.Integer before, java.lang.Integer after)Adds an Ordering Constraint of the Type A > BvoidCheckCausalConflicts()Checks if any of the plan's operators introduced a causal conflict with an existing CausalLinkvoidCheckProtectedConstraints()Checks if any of the plan's operators has a conflict with a protected condition of an InterestGoalbooleanCheckRedundantStep(java.lang.Integer opID)Checks if a given Operator is redundant and not needed anymore, because the CausalLinks it establishes are not needed anymore.java.lang.Objectclone()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 otherintCompare(java.lang.Integer op1, java.lang.Integer op2)Compares two Operators, taking into account the existing ordering constraints in the plan, and specifies which one must become after the othervoiddebug()StepgetFinish()Gets the special Finish Stepjava.util.ArrayList<IPlanningOperator>GetFirstActions()Gets a list with the first actions in a plan - DO NOT USE this method if you want to execute the actions.intgetID()java.util.ArrayList<CausalConflictFlaw>getIgnoredConflicts()Gets a list of CausalConflicts ignored due to emotion-focused coping strategies (denial or whishfull thinking)java.util.ArrayList<CausalLink>getLinks()Gets the plan CausalLinksjava.util.ArrayList<OpenPrecondition>getOpenPreconditions()Gets the plan's OpenPreconditionsIPlanningOperatorgetOperator(java.lang.Integer stepID)Gets the plan's operator who's ID is the received IDjava.util.ArrayList<OrderRelation>getOrderingConstraints()Gets the OrderConstraints or OrderRelations in the planfloatgetProbability(AgentModel am)gets the plan's probability of successStepgetStart()Gets the special Start Stepjava.util.ArrayList<IPlanningOperator>getSteps()Gets all the plan's stepsjava.util.ArrayList<GoalThreat>getThreatenedInterestConstraints()Gets 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.booleanisFinished()booleanisValid()indicates if the plan is valid or notCausalConflictFlawNextFlaw()Gets the next CausalConflictFlaw in the planintNumberOfSourceLinks(java.lang.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(java.lang.Integer stepID)Removes all the CausalLinks that protected a given step's preconditionsvoidRemoveOpenPreconditions(java.lang.Integer stepID)Remove all OpenPreconditions referenced by a given StepvoidRemoveOperator(java.lang.Integer operatorID)Removes an Operator from the planvoidRemoveOrderingConstraint(OrderingConstraint orderConstraint)Removes an OrderingConstraint between two steps (A > B) from the planvoidRemoveOrderingConstraints(java.lang.Integer stepID)Removes all OrderingRelations refering to a given StepvoidReplaceUnboundVariables(int variableID)static voidsetDetectThreatStrategy(IDetectThreatStrategy strat)java.lang.StringtoString()Converts the plan to a StringIPlanningOperatorUnexecutedAction(AgentModel am)Gets the next action that we must execute in the plan in order to achieve itjava.util.ArrayList<IPlanningOperator>UpdatePlan(AgentModel am)Method that implements the Continuous Planner features.voidUpdateProbabilities()Requests an explicit recalculation of a plan's probability.
-
-
-
Constructor Detail
-
Plan
protected Plan()
-
Plan
public Plan(java.util.ArrayList<ProtectedCondition> protectedConditions, java.util.ArrayList<Condition> finishConditions)
-
-
Method Detail
-
setDetectThreatStrategy
public static void setDetectThreatStrategy(IDetectThreatStrategy strat)
-
AddBindingConstraint
public void AddBindingConstraint(Substitution bind)
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:
Substitution
-
AddBindingConstraints
public void AddBindingConstraints(java.util.ArrayList<Substitution> substs)
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:
Substitution
-
AddLink
public void AddLink(CausalLink l)
Adds a CausalLink of the Form A--p-->B to the Plan- Parameters:
l- - the CausalLink to add- See Also:
CausalLink
-
AddOrderingConstraint
public void AddOrderingConstraint(OrderingConstraint order)
Adds an Ordering Constraint of the Type A > B- Parameters:
order- - the OrderConstraint to add
-
AddOperator
public void AddOperator(IPlanningOperator op)
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
public int Compare(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 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
public int Compare(java.lang.Integer op1, java.lang.Integer op2)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
public java.util.ArrayList<IPlanningOperator> UpdatePlan(AgentModel am)
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
public boolean CheckRedundantStep(java.lang.Integer opID)
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
public java.lang.Object clone()
Clones this Plan, returning an equal hard copy. If the new plan is changed afterwards, the original plan remains the same.- Overrides:
clonein classjava.lang.Object- Returns:
- The plan's copy.
-
getID
public int getID()
-
getFinish
public Step getFinish()
Gets the special Finish Step- Returns:
- the Finish Step
-
getIgnoredConflicts
public java.util.ArrayList<CausalConflictFlaw> getIgnoredConflicts()
Gets a list of CausalConflicts ignored due to emotion-focused coping strategies (denial or whishfull thinking)- Returns:
- an ArrayList with ignored CausalConflicts
-
getLinks
public java.util.ArrayList<CausalLink> getLinks()
Gets the plan CausalLinks- Returns:
- an ArrayList with all the plan's CausalLinks
-
getOpenPreconditions
public java.util.ArrayList<OpenPrecondition> getOpenPreconditions()
Gets the plan's OpenPreconditions- Returns:
- an ArrayList with all the plan's preconditions
-
debug
public void debug()
-
getOrderingConstraints
public java.util.ArrayList<OrderRelation> getOrderingConstraints()
Gets the OrderConstraints or OrderRelations in the plan- Returns:
- an ArrayList with OrderRelations between the distinct steps in the plan
-
getProbability
public float getProbability(AgentModel am)
gets the plan's probability of success- Returns:
- the plan's probability
-
getOperator
public IPlanningOperator getOperator(java.lang.Integer stepID)
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
public Step getStart()
Gets the special Start Step- Returns:
- the Start Step
-
getSteps
public java.util.ArrayList<IPlanningOperator> getSteps()
Gets all the plan's steps- Returns:
- an ArrayList with all the plan's steps
-
getThreatenedInterestConstraints
public java.util.ArrayList<GoalThreat> getThreatenedInterestConstraints()
Gets the plan's threats to InterestGoals- Returns:
- an ArrayList with the plan's GoalThreats to InterestGoals
-
h
public float h(AgentModel am)
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
public void IgnoreConflict(AgentModel am, CausalConflictFlaw flaw)
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
public CausalConflictFlaw 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
public int NumberOfSourceLinks(java.lang.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 supports- Parameters:
stepID- - the ID of the step to calculate the result- Returns:
- the number of CausalLinks that the step supports
-
RemoveOperator
public void RemoveOperator(java.lang.Integer operatorID)
Removes an Operator from the plan- Parameters:
operatorID- - the ID of the operator to be removed
-
RemoveCausalLink
public void RemoveCausalLink(CausalLink link)
Removes a CausalLink from the plan- Parameters:
link- - the link to be removed
-
RemoveCausalLinks
public void RemoveCausalLinks(java.lang.Integer stepID)
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
public void RemoveOpenPreconditions(java.lang.Integer stepID)
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
public void RemoveOrderingConstraint(OrderingConstraint orderConstraint)
Removes an OrderingConstraint between two steps (A > B) from the plan- Parameters:
orderConstraint- - The ordering constraint to remove
-
RemoveOrderingConstraints
public void RemoveOrderingConstraints(java.lang.Integer stepID)
Removes all OrderingRelations refering to a given Step- Parameters:
stepID- - the ID of the step to remove from OrderRelations
-
toString
public java.lang.String toString()
Converts the plan to a String- Overrides:
toStringin classjava.lang.Object- Returns:
- the converted String
-
UnexecutedAction
public IPlanningOperator UnexecutedAction(AgentModel am)
Gets the next action that we must execute in the plan in order to achieve it- Returns:
- the next action to execute
-
GetFirstActions
public java.util.ArrayList<IPlanningOperator> 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
public void AddOrderingConstraint(java.lang.Integer before, java.lang.Integer after)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)
-
-