pymasep.common.belief ===================== .. py:module:: pymasep.common.belief Classes ------- .. autoapisummary:: pymasep.common.belief.Belief Module Contents --------------- .. py:class:: Belief(environment, name = None, template=None, xml_node = None, parent=None) Bases: :py:obj:`pymasep.common.BaseObject` The 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 :cite:`sowa_conceptual_1984` :cite:`chein_graph-based_2008`. 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 :param environment: An Environment instance :param name: name of the Belief. :param xml_node: XML used to create the object. :param template: Template of the Belief. Needed if no xml_node or src_copy :param parent: parent object (see objects hierarchy) .. py:attribute:: beliefs beliefs data as a conceptual graph .. py:method:: state() State of the Belief. Always 'run' :return: The state of Belief .. py:method:: id_str() Create an str unique ID of the Belief :return: the string unique ID .. py:method:: node_id(g, c = None, cr = None) Get or create the node id of a node in the Belief. :param g: The graph to create the node id for :param c: the tuple of attribute of the node id to search if the node already exists :param cr: if c is a relation, this parameter represents the concepts linked to the relation .. py:method:: add(c1, r, c2) Adding two concepts linked with one relation into the belief :param c1: First concept as a tuple (concept, instance of the concept) :param r: relation between concepts. :param c2: Second concept as a tuple (concept, instance of the concept) .. py:method:: _create_request(c1, r, c2) .. py:method:: query(query) Query in a Belief :param query: Query as a graph. Use \* as an instance query. Example of a query [Agent:\*]-[Tell]-[Sentence:s1] will return a graph containing all agents that tell the sentence s1 in the agent belief. .. py:method:: to_xml() Transform the Belief to XML. See :ref:`serialization` for more information. :return: XML version of the BaseObject .. py:method:: from_xml(environment, xml_node) Transform an XML to a Belief. The instance must be created before (with __init__(), passing the xml_node). See :ref:`serialization` for more information. :param environment: The environment where the BaseObject is created. :param xml_node: The XML node that contains the Belief data.