decisionMakingSystem
Class DecisionModuleImpl

Package class diagram package DecisionModuleImpl
java.lang.Object
  extended by decisionMakingSystem.DecisionModuleImpl
All Implemented Interfaces:
DecisionModule, Serializable

public class DecisionModuleImpl
extends Object
implements DecisionModule, Serializable

main decision making module - presents the logic of the bot! it takes care about everything about the main logic cycle choice of intention to be performed, action to be performed, update of fadeout, attractivity, rollback when something fails, update of attractivity of intentions etc. basicaly all you need to know about the usage in Agent is that you has to call prepareLogic() in the prePrepareAgent() and doReasoning() in the doLogic, before using this module you need to specify couple XML files and if necessary atomicActions. The XML files are Loader.xml and then one for each root intention. All available atomic actions are in the atomicactions package and all affordance types are in the Enum AffordanceType so you will might need to change those as well. Items are handeled in the itemParameters.xml file. And note that if you add a new AtomicAction you need to add it to the BasicIntentionLoader to importIntentionForest() so it will be proceeded correctly.

Author:
Ondrej
See Also:
Serialized Form

Field Summary
 Action actualAction
          currently choosen action
 Intention actualIntention
          currently choosen intention
 Bot agent
          link to agent
 AgentParameters agentParameters
          agent parameters -> used for stres count and filter of attention, etc.
 ArrayList<Intention> allIntentions
          list of all intentions
 ArrayList<Intention> basicIntentions
          list of basic intentions - for the current day
 int counter
          time counter
 PogamutEndEventSource eventSource
           
 ArrayList<Intention> intentionArea
          list of intentions which are currently active or preactive
 Inventory inventory
          agent inventory - handles picked up things
 Logger log
          fast access to agent log
 ItemMemory memory
           
 HashMap<String,Intention> nameToIntention
           
 PerceptiveField perceptiveField
          link on perceptive field to access actions, perceived items etc.
 ThingsManager things
          link to thing manager -> takes care about all visible items
 
Constructor Summary
DecisionModuleImpl()
           
DecisionModuleImpl(ItemMemory itemMemory)
           
 
Method Summary
protected  void actionFailed(Action action)
          Recursive action which is executed when action fails.
protected  void actionSucceeded(Action action)
          success of an action means its removal from preactive actions and success of parental intention
 void addIntention(String name, Interval actInterval)
          This method adds dynamicaly new intention to the daily plan.
 void changeLifestyle(String directory, String planningFilename, int i)
           
protected  Action chooseAction(Intention intention)
          Start of a recursive proceeding, where we start from intention and ends up with action which is ready to execute its atomic actions.
protected  Intention chooseIntention(Action action)
          recursive function to choose current intention to fullfill
 DMSMemoryVO doReasoning(int myCounter)
          main function of DecisionModuleImpl, the only one that should be called from doLogic of Agent.
 void doReasoningItemScenario()
          a test case which serves to check if Want works correctly - e.g.
 Action getActualAction()
           
 AtomicAction getActualAtomicAction()
           
 Intention getActualIntention()
           
 int getCounter()
           
 double getGMTTime()
           
 AtomicAction getOldAtomicAction()
           
protected  void intentionFailed(Intention intention)
          Intention fails => parental action fails as well.
protected  void intentionSucceeded(Intention intention)
          When intention succeeds, parental action can continue with next intention.
static DecisionModuleImpl loadFromFile(String filename, Logger log, Bot agent, String directory)
           
protected  Action prepareAction(Action action)
          Part of recursive call.
 void prepareLogic(Bot agent, String directory, String planningFilename)
          quite close to the constructor, prepares everything in the logic (loads intentions from XML, initialize all structures).
protected  void removeActionAndDescendantIntentions(Action actualAction)
          removes action from processArea removes descendant intentions of action be careful about Want intentions as they can be descendants of more than one action
protected  void removeIntention(Intention intention)
          so far just removes intention from intention area without anything else as intentions are rolling back differently and when one fails it doesn't mean a disaster - so just the parent action failed as well.
 void saveToFile(String filename)
           
 void sensing()
           
 void setDMSLogger(DMSLogger logger)
           
 void setGMT(double gmtTime)
          set GMT and replan the schedule for the day
 DMSMemoryVO test()
          procedure which executes all testcases should be put in the agent.doLogic() instead of doReasoning()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventSource

public PogamutEndEventSource eventSource

log

public transient Logger log
fast access to agent log


agent

public transient Bot agent
link to agent


perceptiveField

public transient PerceptiveField perceptiveField
link on perceptive field to access actions, perceived items etc.


basicIntentions

public ArrayList<Intention> basicIntentions
list of basic intentions - for the current day


allIntentions

public ArrayList<Intention> allIntentions
list of all intentions


intentionArea

public ArrayList<Intention> intentionArea
list of intentions which are currently active or preactive


things

public transient ThingsManager things
link to thing manager -> takes care about all visible items


counter

public int counter
time counter


inventory

public transient Inventory inventory
agent inventory - handles picked up things


actualIntention

public Intention actualIntention
currently choosen intention


actualAction

public Action actualAction
currently choosen action


agentParameters

public AgentParameters agentParameters
agent parameters -> used for stres count and filter of attention, etc.


nameToIntention

public HashMap<String,Intention> nameToIntention

memory

public ItemMemory memory
Constructor Detail

DecisionModuleImpl

public DecisionModuleImpl()

DecisionModuleImpl

public DecisionModuleImpl(ItemMemory itemMemory)
Method Detail

changeLifestyle

public void changeLifestyle(String directory,
                            String planningFilename,
                            int i)

prepareLogic

public void prepareLogic(Bot agent,
                         String directory,
                         String planningFilename)
quite close to the constructor, prepares everything in the logic (loads intentions from XML, initialize all structures). it should be called in the prePrepareAgent() in Agent

Parameters:
agent - - pointer to agent
directory - - path, where are located Loader.xml and XML files of root intentions

sensing

public void sensing()

setGMT

public void setGMT(double gmtTime)
set GMT and replan the schedule for the day

Parameters:
GMTTime -

chooseAction

protected Action chooseAction(Intention intention)
Start of a recursive proceeding, where we start from intention and ends up with action which is ready to execute its atomic actions. This start is rather easy: it just checks if the intention has some actions (possibilities) to follow, if not it fails and if yes I prepare the action and return it.

Parameters:
intention - intention to start from
Returns:
action ready to execute atomic action

prepareAction

protected Action prepareAction(Action action)
Part of recursive call. It prepares action to execute, returned action has to be ready to execute atomic action. That means that all its sub-intentions are successfuly finished and all affordances are satisfied. So this method takes care about putting in sub-intentions, creating Want intentions etc. The split of chooseAction to chooseAction and prepareAction enables inputing spontaneous actions elegantly

Parameters:
action - which should be prepared
Returns:
action (some son of the provided action) which can be executed - its atomic action can be executed

chooseIntention

protected Intention chooseIntention(Action action)
recursive function to choose current intention to fullfill

Parameters:
action - action to start from
Returns:
parental intention of action which is ready to execute - null if not possible to choose next

actionFailed

protected void actionFailed(Action action)
Recursive action which is executed when action fails. It removes action and its descendants (shouldn't be necessary now). if spontaneous, then its finished as it doesn't need to propagate fail up some tree. Normal action forces parental intention to choose new action and if there are not any, it calls intentonFailed as it fails then as well.

Parameters:
action - action which failed

actionSucceeded

protected void actionSucceeded(Action action)
success of an action means its removal from preactive actions and success of parental intention

Parameters:
action - action which succeeded

intentionFailed

protected void intentionFailed(Intention intention)
Intention fails => parental action fails as well. If there is not a one (root intention), it means dropout of the intention.

Parameters:
intention - which failed

intentionSucceeded

protected void intentionSucceeded(Intention intention)
When intention succeeds, parental action can continue with next intention. When it is a root intention, than it's the end of execution of the intention => dropout.

Parameters:
intention -

doReasoning

public DMSMemoryVO doReasoning(int myCounter)
main function of DecisionModuleImpl, the only one that should be called from doLogic of Agent. So it goes as follows:
  1. recount activities of root intentions and get the most active of root intentions and of the preactive intentions in the intentionArea
  2. chooseAction - means to ensure that chosen intention has some preactive action in the perceptive field
  3. choose the most active action from preactive actions
  4. as actions are enabled only if they can already execute atomic action, execute it
  5. check if the execution of atomic action didn't lead to finish or fail of action (if yes, do the rollback)
  6. increase duration
  7. at the end update attractivity, activity, fadeout

Specified by:
doReasoning in interface DecisionModule
Returns:
value object with some basic info about the last iteration.

removeActionAndDescendantIntentions

protected void removeActionAndDescendantIntentions(Action actualAction)
removes action from processArea removes descendant intentions of action be careful about Want intentions as they can be descendants of more than one action

Parameters:
actualAction -

removeIntention

protected void removeIntention(Intention intention)
so far just removes intention from intention area without anything else as intentions are rolling back differently and when one fails it doesn't mean a disaster - so just the parent action failed as well. intentions are not linked to any items, want intentions etc. so it is not that difficult to delete it


addIntention

public void addIntention(String name,
                         Interval actInterval)
This method adds dynamicaly new intention to the daily plan. It shouldn't be called again until that intention activation interval expires. How does it works? First I check if the intention is present in the daily plan, if so I add new interval to it, if it is already active (there is an interval which is active at the current time), I don't do anything. Completely new intention is obtained from the hash map of (name,Intention) and I make a hard copy of it as I will be modifying activation intervals

Specified by:
addIntention in interface DecisionModule
Parameters:
name - - name of the intention
actInterval - - activation interval of the inserted intention

test

public DMSMemoryVO test()
procedure which executes all testcases should be put in the agent.doLogic() instead of doReasoning()


doReasoningItemScenario

public void doReasoningItemScenario()
a test case which serves to check if Want works correctly - e.g. attention, search environment, pocket, memory etc. good to do some basic tuning of memory - like how to count the trustfullness of an item


getActualAction

public Action getActualAction()
Specified by:
getActualAction in interface DecisionModule
Returns:
Action performed at the moment.

getActualIntention

public Intention getActualIntention()
Specified by:
getActualIntention in interface DecisionModule
Returns:
Intention in progress

getCounter

public int getCounter()
Specified by:
getCounter in interface DecisionModule
Returns:
counter - e.g. ticks of logic from the beginning of the simulation.

getActualAtomicAction

public AtomicAction getActualAtomicAction()
Specified by:
getActualAtomicAction in interface DecisionModule
Returns:
Actual atomic action which is being executed.

getOldAtomicAction

public AtomicAction getOldAtomicAction()
Specified by:
getOldAtomicAction in interface DecisionModule
Returns:
old atomic action - atomic action performed before the change to a next one. (set only for one tick of logic)

getGMTTime

public double getGMTTime()
Specified by:
getGMTTime in interface DecisionModule
Returns:
GMT time - e.g. the difference between the timezones of agent's origin and agent's current location.

saveToFile

public void saveToFile(String filename)

loadFromFile

public static DecisionModuleImpl loadFromFile(String filename,
                                              Logger log,
                                              Bot agent,
                                              String directory)

setDMSLogger

public void setDMSLogger(DMSLogger logger)


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.