Package FAtiMA.Core.goals
Class Goal
- java.lang.Object
-
- FAtiMA.Core.goals.Goal
-
- All Implemented Interfaces:
IGroundable,java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
ActivePursuitGoal,InterestGoal
public abstract class Goal extends java.lang.Object implements IGroundable, java.lang.Cloneable, java.io.Serializable
abstract goal class used to represent common aspects of Interest goals and ActivePursuit goals.- Author:
- Joao Dias
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<Substitution>_appliedSubstitutionsprotected int_baseIOFprotected int_baseIOSprotected Name_dynamicIOFprotected Name_dynamicIOSprotected int_goalIDprotected java.lang.String_keyprotected Name_namestatic java.lang.StringACTIVATIONEVENTstatic java.lang.StringFAILUREEVENTprotected static intgoalCounterstatic java.lang.StringGOALDROPEDstatic java.lang.StringGOALFAILUREstatic java.lang.StringGOALSUCCESSstatic java.lang.StringIMPORTANCEOFFAILUREstatic java.lang.StringIMPORTANCEOFSUCCESSstatic java.lang.StringSUCCESSEVENT
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidAddCondition(java.lang.String conditionType, Condition cond)Adds a condition to the goalabstract voidCheckIntegrity(IntegrityValidator val)Checks the integrity of the goal.voidDecreaseImportanceOfFailure(AgentModel am, float decr)Decreases the ImportanceOfFailure of a goal by a given ammount Used for emotion-focused coping strategies like disengagementvoidDecreaseImportanceOfSuccess(AgentModel am, float decr)Decreases the ImportanceOfSuccess of a goal by a given amount Used for emotion-focused coping strategies like disengagementprotected EventgenerateEventDescription(short goalEventType)java.lang.StringGenerateGoalStatus(java.lang.String status)Generates a status description of goal according to the received status.EventGetActivationEvent()Gets an Event that represents the goal's activationjava.util.ArrayList<Substitution>getAppliedSubstitutions()EventGetCancelEvent()EventGetFailureEvent()Gets an Event that represents the goal's failurefloatGetImportanceOfFailure(AgentModel am)Gets the goal's importance of failurefloatGetImportanceOfSuccess(AgentModel am)Gets the goal's importance of successjava.lang.StringgetKey()NamegetName()Gets the goal's nameEventGetSuccessEvent()Gets an Event that represents the goal's successprotected java.util.ArrayList<Condition>GroundConditionList(java.util.ArrayList<Condition> originalList, java.util.ArrayList<Substitution> bindings)Gets a list of conditions, a list of bindings and returns a new list of conditions where the conditions were grounded with the list of received bindings.voidIncreaseImportanceOfFailure(AgentModel am, float incr)Increases the ImportanceOfFailure of a goal by a given ammount Used for emotion-focused coping strategiesvoidIncreaseImportanceOfSuccess(AgentModel am, float incr)Increases the ImportanceOfSuccess of a goal by a fixed ammount Used for emotion-focused coping strategiesbooleanisGrounded()Indicates if the Goal is grounded (no unbound variables in its name and conditions) Example: Stronger(Luke,John) is grounded while Stronger(John,[X]) is not.abstract voidMakeGround(Substitution subst)Applies a set of substitutions to the object, grounding it.abstract voidMakeGround(java.util.ArrayList<Substitution> bindings)Applies a set of substitutions to the object, grounding it.abstract voidReplaceUnboundVariables(int variableID)Replaces all unbound variables in the object by applying a numeric identifier to each one.voidSetImportanceOfFailure(AgentModel am, float imp)Sets the goal's importance of failurevoidSetImportanceOfSuccess(AgentModel am, float imp)Sets the goal's importance of successjava.lang.StringtoString()Converts the Goal to a String
-
-
-
Field Detail
-
GOALSUCCESS
public static final java.lang.String GOALSUCCESS
- See Also:
- Constant Field Values
-
GOALFAILURE
public static final java.lang.String GOALFAILURE
- See Also:
- Constant Field Values
-
GOALDROPED
public static final java.lang.String GOALDROPED
- See Also:
- Constant Field Values
-
IMPORTANCEOFSUCCESS
public static final java.lang.String IMPORTANCEOFSUCCESS
- See Also:
- Constant Field Values
-
IMPORTANCEOFFAILURE
public static final java.lang.String IMPORTANCEOFFAILURE
- See Also:
- Constant Field Values
-
ACTIVATIONEVENT
public static final java.lang.String ACTIVATIONEVENT
- See Also:
- Constant Field Values
-
SUCCESSEVENT
public static final java.lang.String SUCCESSEVENT
- See Also:
- Constant Field Values
-
FAILUREEVENT
public static final java.lang.String FAILUREEVENT
- See Also:
- Constant Field Values
-
goalCounter
protected static int goalCounter
-
_name
protected Name _name
-
_key
protected java.lang.String _key
-
_appliedSubstitutions
protected java.util.ArrayList<Substitution> _appliedSubstitutions
-
_goalID
protected int _goalID
-
_baseIOF
protected int _baseIOF
-
_baseIOS
protected int _baseIOS
-
_dynamicIOF
protected Name _dynamicIOF
-
_dynamicIOS
protected Name _dynamicIOS
-
-
Constructor Detail
-
Goal
public Goal()
Creates a new Empty Goal. Not used directly since its an abstract class
-
Goal
public Goal(Name description)
Creates a new Goal. Not used directly since its an abstract class- Parameters:
description- - the goal's name
-
-
Method Detail
-
getAppliedSubstitutions
public java.util.ArrayList<Substitution> getAppliedSubstitutions()
-
GenerateGoalStatus
public java.lang.String GenerateGoalStatus(java.lang.String status)
Generates a status description of goal according to the received status. Ex: if the goal is Fight(Luke) and the status is GOALSUCCESS the method returns GOALSUCCESS(Fight,Luke)- Parameters:
status- - the goal status, use one of the static status values: Goal.GOALSUCCESS Goal.GOALFAILURE Goal.GOALDROPED ... etc- Returns:
- status
-
AddCondition
public abstract void AddCondition(java.lang.String conditionType, Condition cond)Adds a condition to the goal- Parameters:
conditionType- - the type of the condition: success condition, precondition, etccond- - the condition to add
-
CheckIntegrity
public abstract void CheckIntegrity(IntegrityValidator val) throws UnreachableGoalException
Checks the integrity of the goal. For instance it checks if the goal's success conditions are reachable by at least one action in the domain operators. If not it means that the goal will never be achieve and probably is a typo in the goal's definition (or in the actions file)- Parameters:
val- - the validator used to check the goal- Throws:
UnreachableGoalException- - thrown if a goal's success conditions can never be achieved because there is no operator with such effects
-
DecreaseImportanceOfFailure
public void DecreaseImportanceOfFailure(AgentModel am, float decr)
Decreases the ImportanceOfFailure of a goal by a given ammount Used for emotion-focused coping strategies like disengagement
-
getKey
public java.lang.String getKey()
-
IncreaseImportanceOfFailure
public void IncreaseImportanceOfFailure(AgentModel am, float incr)
Increases the ImportanceOfFailure of a goal by a given ammount Used for emotion-focused coping strategies
-
DecreaseImportanceOfSuccess
public void DecreaseImportanceOfSuccess(AgentModel am, float decr)
Decreases the ImportanceOfSuccess of a goal by a given amount Used for emotion-focused coping strategies like disengagement
-
IncreaseImportanceOfSuccess
public void IncreaseImportanceOfSuccess(AgentModel am, float incr)
Increases the ImportanceOfSuccess of a goal by a fixed ammount Used for emotion-focused coping strategies
-
GetImportanceOfFailure
public float GetImportanceOfFailure(AgentModel am)
Gets the goal's importance of failure- Returns:
- the importance of failure ranged [0;10]
-
GetImportanceOfSuccess
public float GetImportanceOfSuccess(AgentModel am)
Gets the goal's importance of success- Returns:
- the importance of success ranged [0;10]
-
getName
public Name getName()
Gets the goal's name- Returns:
- the name of the goal
-
GetActivationEvent
public Event GetActivationEvent()
Gets an Event that represents the goal's activation- Returns:
- an Event that contains a description of the goal's activation
-
GetSuccessEvent
public Event GetSuccessEvent()
Gets an Event that represents the goal's success- Returns:
- an Event that contains a description of the goal's success
-
GetFailureEvent
public Event GetFailureEvent()
Gets an Event that represents the goal's failure- Returns:
- an Event that contains a description of the goal's failure
-
GetCancelEvent
public Event GetCancelEvent()
-
generateEventDescription
protected Event generateEventDescription(short goalEventType)
-
ReplaceUnboundVariables
public abstract 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 abstract 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 abstract 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 Goal is grounded (no unbound variables in its name and conditions) Example: Stronger(Luke,John) is grounded while Stronger(John,[X]) is not.- Specified by:
isGroundedin interfaceIGroundable- Returns:
- true if all the goal's conditions and name are grounded, false otherwise
-
SetImportanceOfFailure
public void SetImportanceOfFailure(AgentModel am, float imp)
Sets the goal's importance of failure- Parameters:
imp- - the new importance of failure (ranged [0;10])
-
SetImportanceOfSuccess
public void SetImportanceOfSuccess(AgentModel am, float imp)
Sets the goal's importance of success- Parameters:
imp- - the new importance of success (ranged [0;10])
-
toString
public java.lang.String toString()
Converts the Goal to a String- Overrides:
toStringin classjava.lang.Object- Returns:
- the converted String
-
GroundConditionList
protected java.util.ArrayList<Condition> GroundConditionList(java.util.ArrayList<Condition> originalList, java.util.ArrayList<Substitution> bindings)
Gets a list of conditions, a list of bindings and returns a new list of conditions where the conditions were grounded with the list of received bindings. Defined for internal use of the InterestGoal and ActivePursuitGoal classes- Parameters:
originalList- - the list of conditions to groundbindings- - a list of substitutions to apply to the condition list- Returns:
- a list with grounded conditions
- See Also:
Substitution
-
-