pymasep.common.belief
Classes
The Belief of an agent is all the agent knows about the world and that could have an influence on their actions. |
Module Contents
- class pymasep.common.belief.Belief(environment, name=None, template=None, xml_node=None, parent=None)
Bases:
pymasep.common.BaseObjectThe Belief of an agent is all the agent knows about the world and that could have an influence on their actions. Here, the concept of Belief is more inspired by the BDI agent architecture than by the belief of a DEC-POMDP.
Beliefs are based on Conceptual Graphs [Sow84] [CM08]. This version is limited to a simpler version of conceptual graphs. It has been tested with belief of three nodes (concept-relation-concept) See test_belief.py for more details.
NOTE: Contrary to other BaseObjects, src_copy is not used for Belief since Belief instances are never copied but stay as the same reference in the current state
- Parameters:
environment – An Environment instance
name (str) – name of the Belief.
xml_node (Optional[xml.etree.ElementTree.Element]) – XML used to create the object.
template – Template of the Belief. Needed if no xml_node or src_copy
parent – parent object (see objects hierarchy)
- beliefs
beliefs data as a conceptual graph
- state()
State of the Belief. Always ‘run’
- Returns:
The state of Belief
- Return type:
str
- id_str()
Create an str unique ID of the Belief
- Returns:
the string unique ID
- Return type:
str
- node_id(g, c=None, cr=None)
Get or create the node id of a node in the Belief.
- Parameters:
g (networkx.Graph) – The graph to create the node id for
c (Optional[Tuple[str] | Tuple[str, str]]) – the tuple of attribute of the node id to search if the node already exists
cr (Optional[List[Tuple[str, str]]]) – if c is a relation, this parameter represents the concepts linked to the relation
- Return type:
int
- add(c1, r, c2)
Adding two concepts linked with one relation into the belief
- Parameters:
c1 (Tuple[str, str]) – First concept as a tuple (concept, instance of the concept)
r (Tuple[str]) – relation between concepts.
c2 (Tuple[str, str]) – Second concept as a tuple (concept, instance of the concept)
- Return type:
None
- _create_request(c1, r, c2)
- Parameters:
c1 (Tuple[str, str])
- query(query)
Query in a Belief
- Parameters:
query (networkx.Graph) – Query as a graph. Use * as an instance query.
- Return type:
networkx.Graph
Example of a query [Agent:*]-[Tell]-[Sentence:s1] will return a graph containing all agents that tell the sentence s1 in the agent belief.
- to_xml()
Transform the Belief to XML. See Serialization for more information.
- Returns:
XML version of the BaseObject
- Return type:
xml.etree.ElementTree.Element
- from_xml(environment, xml_node)
Transform an XML to a Belief. The instance must be created before (with __init__(), passing the xml_node). See Serialization for more information.
- Parameters:
environment – The environment where the BaseObject is created.
xml_node (xml.etree.ElementTree.Element) – The XML node that contains the Belief data.