edu.udo.cs.ie.cowbots.bdi.brf
Class CowbotRevision

Package class diagram package CowbotRevision
java.lang.Object
  extended by edu.udo.cs.ie.cowbots.bdi.brf.CRevisionComponent
      extended by edu.udo.cs.ie.cowbots.bdi.brf.CowbotRevision
All Implemented Interfaces:
IEpistemicState
Direct Known Subclasses:
exRevision

public class CowbotRevision
extends CRevisionComponent
implements IEpistemicState

This class manages the components of the epistemic state in the Cowbot-BDI-model, namely the belief base, the belief state and the belief set. It also invokes the corresponding belief operators to perform belief base changes and revising an agents beliefs.


Nested Class Summary
(package private) static class CowbotRevision.LiteralRewrite
           
 
Field Summary
protected  java.util.List<ELPLiteral> belAdd
           
protected  java.util.List<ELPLiteral> belDel
           
protected  BeliefBase beliefBase
           
protected  BeliefSet beliefSet
           
protected  boolean bsOldUpdate
           
protected  boolean directMessageAccept
           
protected  DLV dlv
           
protected  java.util.List<ELPLiteral> exploredCells
           
protected  boolean extendedRevision
           
protected  IInferenceOperator infop
           
protected  boolean prn
           
protected  boolean reviseFull
           
protected  java.util.Map<java.lang.String,CowbotRevision.LiteralRewrite> rewrite
           
protected  GridMap scenarioMap
           
protected  int simulationID
           
protected  ICowbotUI ui
           
 
Constructor Summary
CowbotRevision()
          default constructor to create a cowbot revision instance (the setup has to be done with the init method).
 
Method Summary
protected  void addBelief(Literal beliefToAdd)
          adds a fact to an agents beliefs
 void addProgram(ELP program, java.lang.String source)
          adds a logical program to an agents beliefs
 void addUserProgram(java.lang.String name, ELP program)
          this method adds a logical program to the program storage
protected  BeliefSet computeBeliefs(ELP extraRules)
          computes a new belief set based upon the belief state and optinal extra rules.
protected  void copyMap(java.util.Collection<ELPLiteral> target)
          experimental function, copies
protected  void delBelief(Literal beliefToDel)
          removes a literal from an agents beliefs
 void dumpBB()
          test function, prints bb contents to stdout
 BeliefBase getBeliefBase()
          this method returns the logical belief base of an agent.
 java.util.List<Literal> getBeliefs(ELP elp)
          Deprecated. 
 ELP getBeliefsAsELP()
          returns the belief set as an elp
 BeliefSet getBeliefSet()
          this method returns an agents belief set.
 java.util.List<Literal>[] getChangeOfBeliefs()
          returns a tupel of two lists describing changes in an agent's beliefs. this is used to update the jason belief base properly after the epistemic state was revised.
 IEpistemicState getEpistemicState()
          returns the epistemic state of an agent
 java.util.List<ELPLiteral> getExploredCells()
          this method returns a list of new, but not not necessarily revised, perceptions.
 GridMap getMap()
          this function returns the beliefs about an agents environment as a gridmap.
 java.util.Queue<Message> getMessages()
          this function returns the queue of unprocessed messages
 ELP getProgram(java.lang.String name)
          returns a user program identified by a unique name (user programs are not part of the belief revision process over the epistemic state)
 int getWorldTime()
          returns the time of the world (this is the time the agent beliefs in)
 void init(Settings stts, DLV dlv, ICowbotUI ui)
          initialization routine, allows the cowbot revision to be configured with user parameters.
 void internalInit(org.w3c.dom.Element brfConfig, java.lang.String configName, DLV dlv, ICowbotUI ui)
          initialization routine, allows the cowbot revision to be configured with user parameters.
 boolean newRevisionMode()
          only used internally, do not care about!
 java.util.List<Literal>[] processMessages(java.lang.String agName)
          a very simple way to handle communication: every information send by a "tell" is accepted. the information (encoded by literals) within the message is appended to the belief base.
protected  void pruneBeliefBase(java.util.Set<java.lang.String> predicates, java.util.Set<ELPLiteral> facts)
          this method removes facts from the belief base
 void queueMessage(Message m)
          this method queues an incoming message. the deliberation may then decide to handle the message
 void reset()
          resets the revision component (is set back to a fresh initialized state).
 java.util.List<Literal>[] revise_belief(Literal beliefToAdd, Literal beliefToDel, Intention i)
          revision method that is called from jason's "brf" method
 boolean revise_percepts(java.util.List<Literal> per, java.util.List<ELPLiteral> explored)
          this method is used to integrate percepts from the environment into the agent's belief base.
protected  void reviseEx()
          extended revision. makes extensive use of the map and identtable operators. can purge elps from the belief base if the reject set of an inference operator tells to reject something.
protected  void reviseSimple()
          simple revision, more or less good enough to support the massim scenario using elp or java operators
protected  void reviseState()
          internal method, usually called by the update methods after the belief base was changed. this computes a new belief state and a new belief set.
protected  void setNewBeliefs(java.util.Set<ELPLiteral> newBS)
          applies a new belief set to the epistemic state
protected  java.util.List<Literal> transformELP2Jason(java.util.List<ELPLiteral> ll)
          auxiliary function, transforms an elp literal into a jason literal
protected  java.util.List<ELPLiteral> transformJasonToELP(java.util.List<Literal> literals)
          auxiliary function, transforms a list of jason literals into a list of elp literals
protected  ELPLiteral transformJasonToELP(Literal beliefToAdd)
          auxiliary function, transforms jason literals into elp literals
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beliefBase

protected BeliefBase beliefBase

beliefSet

protected BeliefSet beliefSet

dlv

protected DLV dlv

infop

protected IInferenceOperator infop

prn

protected boolean prn

scenarioMap

protected GridMap scenarioMap

ui

protected ICowbotUI ui

reviseFull

protected boolean reviseFull

bsOldUpdate

protected boolean bsOldUpdate

simulationID

protected int simulationID

rewrite

protected java.util.Map<java.lang.String,CowbotRevision.LiteralRewrite> rewrite

extendedRevision

protected boolean extendedRevision

belAdd

protected java.util.List<ELPLiteral> belAdd

belDel

protected java.util.List<ELPLiteral> belDel

exploredCells

protected java.util.List<ELPLiteral> exploredCells

directMessageAccept

protected boolean directMessageAccept
Constructor Detail

CowbotRevision

public CowbotRevision()
default constructor to create a cowbot revision instance (the setup has to be done with the init method).

Method Detail

revise_belief

public java.util.List<Literal>[] revise_belief(Literal beliefToAdd,
                                               Literal beliefToDel,
                                               Intention i)
revision method that is called from jason's "brf" method

Specified by:
revise_belief in class CRevisionComponent
Parameters:
beliefToAdd - single literal to add to an agents beliefs
beliefToDel - single literal to remove from an agents beliefs
i - intention that issued the brf call (always ignored)
Returns:
tupel of lists with added and deleted literals

addBelief

protected void addBelief(Literal beliefToAdd)
adds a fact to an agents beliefs

Parameters:
beliefToAdd - literal to add

delBelief

protected void delBelief(Literal beliefToDel)
removes a literal from an agents beliefs

Parameters:
beliefToDel - literal to remove

revise_percepts

public boolean revise_percepts(java.util.List<Literal> per,
                               java.util.List<ELPLiteral> explored)
Description copied from class: CRevisionComponent
this method is used to integrate percepts from the environment into the agent's belief base.

Specified by:
revise_percepts in class CRevisionComponent
Parameters:
per - the list of environmental percepts
Returns:
true if beliefs were changed, false otherwise

getBeliefs

@Deprecated
public java.util.List<Literal> getBeliefs(ELP elp)
Deprecated. 

Description copied from interface: IEpistemicState
returns the beliefs (a list of Literals) representing an agent's belief set. the addRules parameter lets the caller specify additional inference rules.

Specified by:
getBeliefs in interface IEpistemicState
Parameters:
elp - (optional) inference rules
Returns:
belief set

getBeliefsAsELP

public ELP getBeliefsAsELP()
Description copied from interface: IEpistemicState
returns the belief set as an elp

Specified by:
getBeliefsAsELP in interface IEpistemicState

computeBeliefs

protected BeliefSet computeBeliefs(ELP extraRules)
computes a new belief set based upon the belief state and optinal extra rules.

Parameters:
extraRules - additional elp expressions
Returns:

getEpistemicState

public IEpistemicState getEpistemicState()
Description copied from class: CRevisionComponent
returns the epistemic state of an agent

Specified by:
getEpistemicState in class CRevisionComponent
Returns:
epistemic state

reviseState

protected void reviseState()
internal method, usually called by the update methods after the belief base was changed. this computes a new belief state and a new belief set.


dumpBB

public void dumpBB()
test function, prints bb contents to stdout


queueMessage

public void queueMessage(Message m)
Description copied from class: CRevisionComponent
this method queues an incoming message. the deliberation may then decide to handle the message

Specified by:
queueMessage in class CRevisionComponent

getMessages

public java.util.Queue<Message> getMessages()
Description copied from interface: IEpistemicState
this function returns the queue of unprocessed messages

Specified by:
getMessages in interface IEpistemicState

getMap

public GridMap getMap()
Description copied from interface: IEpistemicState
this function returns the beliefs about an agents environment as a gridmap.

Specified by:
getMap in interface IEpistemicState
Returns:
gridmap with beliefs about the environment

getBeliefSet

public BeliefSet getBeliefSet()
Description copied from interface: IEpistemicState
this method returns an agents belief set.

Specified by:
getBeliefSet in interface IEpistemicState
Returns:
belief set of an agent

reviseSimple

protected void reviseSimple()
simple revision, more or less good enough to support the massim scenario using elp or java operators


reviseEx

protected void reviseEx()
extended revision. makes extensive use of the map and identtable operators. can purge elps from the belief base if the reject set of an inference operator tells to reject something.


setNewBeliefs

protected void setNewBeliefs(java.util.Set<ELPLiteral> newBS)
applies a new belief set to the epistemic state

Parameters:
newBS - new set of beliefs

pruneBeliefBase

protected void pruneBeliefBase(java.util.Set<java.lang.String> predicates,
                               java.util.Set<ELPLiteral> facts)
this method removes facts from the belief base

Parameters:
predicates - functor names of predicates to remove
facts - set of facts to remove

getChangeOfBeliefs

public java.util.List<Literal>[] getChangeOfBeliefs()
Description copied from class: CRevisionComponent
returns a tupel of two lists describing changes in an agent's beliefs. this is used to update the jason belief base properly after the epistemic state was revised.

Specified by:
getChangeOfBeliefs in class CRevisionComponent
Returns:
tupel

transformELP2Jason

protected java.util.List<Literal> transformELP2Jason(java.util.List<ELPLiteral> ll)
auxiliary function, transforms an elp literal into a jason literal

Parameters:
ll -
Returns:

transformJasonToELP

protected ELPLiteral transformJasonToELP(Literal beliefToAdd)
auxiliary function, transforms jason literals into elp literals

Parameters:
beliefToAdd -
Returns:

transformJasonToELP

protected java.util.List<ELPLiteral> transformJasonToELP(java.util.List<Literal> literals)
auxiliary function, transforms a list of jason literals into a list of elp literals

Parameters:
literals -
Returns:

newRevisionMode

public boolean newRevisionMode()
Description copied from class: CRevisionComponent
only used internally, do not care about!

Specified by:
newRevisionMode in class CRevisionComponent
Returns:
true or false

copyMap

protected void copyMap(java.util.Collection<ELPLiteral> target)
experimental function, copies

Parameters:
target -

processMessages

public java.util.List<Literal>[] processMessages(java.lang.String agName)
a very simple way to handle communication: every information send by a "tell" is accepted. the information (encoded by literals) within the message is appended to the belief base.

Specified by:
processMessages in class CRevisionComponent
Returns:
list of belief additions and deletions

getExploredCells

public java.util.List<ELPLiteral> getExploredCells()
Description copied from interface: IEpistemicState
this method returns a list of new, but not not necessarily revised, perceptions.

Specified by:
getExploredCells in interface IEpistemicState
Returns:
collection of recent observations

getWorldTime

public int getWorldTime()
Description copied from interface: IEpistemicState
returns the time of the world (this is the time the agent beliefs in)

Specified by:
getWorldTime in interface IEpistemicState
Returns:
time of world

addProgram

public void addProgram(ELP program,
                       java.lang.String source)
Description copied from class: CRevisionComponent
adds a logical program to an agents beliefs

Specified by:
addProgram in class CRevisionComponent
Parameters:
program - logical program to add
source - source (agent name) of program

init

public void init(Settings stts,
                 DLV dlv,
                 ICowbotUI ui)
          throws java.lang.Exception
Description copied from class: CRevisionComponent
initialization routine, allows the cowbot revision to be configured with user parameters.

Specified by:
init in class CRevisionComponent
dlv - instance of dlv asp solver
Throws:
java.lang.Exception

internalInit

public void internalInit(org.w3c.dom.Element brfConfig,
                         java.lang.String configName,
                         DLV dlv,
                         ICowbotUI ui)
                  throws java.lang.Exception
initialization routine, allows the cowbot revision to be configured with user parameters.

Parameters:
brfConfig - XML Node named "brf" containing setup data
configName - user configuration override from mas2j
dlv - instance of dlv asp solver
Throws:
java.lang.Exception

getProgram

public ELP getProgram(java.lang.String name)
Description copied from interface: IEpistemicState
returns a user program identified by a unique name (user programs are not part of the belief revision process over the epistemic state)

Specified by:
getProgram in interface IEpistemicState
Parameters:
name - unique name of program
Returns:
elp matching given name or null

addUserProgram

public void addUserProgram(java.lang.String name,
                           ELP program)
Description copied from class: CRevisionComponent
this method adds a logical program to the program storage

Specified by:
addUserProgram in class CRevisionComponent

getBeliefBase

public BeliefBase getBeliefBase()
Description copied from class: CRevisionComponent
this method returns the logical belief base of an agent.

Specified by:
getBeliefBase in class CRevisionComponent
Returns:

reset

public void reset()
Description copied from class: CRevisionComponent
resets the revision component (is set back to a fresh initialized state).

Specified by:
reset in class CRevisionComponent