<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A Possible Approach for Implementing Self-Awareness in JASON</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Luca Sabatucci</string-name>
          <email>sabatucci@pa.icar.cnr.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Massimo Cossentino</string-name>
          <email>cossentino@pa.icar.cnr.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Carmelo Lodato</string-name>
          <email>c.lodato@pa.icar.cnr.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Salvatore Lopes</string-name>
          <email>s.lopes@pa.icar.cnr.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Valeria Seidita</string-name>
          <email>valeria.seidita@unipa.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ICAR-CNR</institution>
          ,
          <addr-line>Palermo</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Palermo</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>In Philosophy, the term awareness is often associated to theories of consciousness and self-referential behavior. In computer science, the awareness is a topic of increasing relevance in both Software Engineering and Arti cial Intelligence, being closely related to autonomy and proactiveness. We can distinguish two orders of awareness: the rst order is the awareness of the environment also known as context-awareness; conversely, self-awareness is a higher order awareness (knowledge about one's own mental states). Nowadays, many agent oriented languages o er native instruments to implement context-awareness. However, self-awareness is not adequately supported and it requires further considerations. This paper focuses on implementation techniques, based on JASON, for creating software agents able to dynamically reason about their knowledge of the environment, as well as on their missions, capabilities and current execution state.</p>
      </abstract>
      <kwd-group>
        <kwd>Self-Adaptation</kwd>
        <kwd>Self-Awareness</kwd>
        <kwd>Multi-Agent Systems</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Runtime adaptation is, today, an important aspect of complex systems such
as distributed systems, defense software, and pervasive computing systems [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
The most successful examples of self-adaptation in computer science have been
designed ad hoc for the speci c problem. As a consequence, the experience
concerning such systems is hard to generalize, thus making self-adaptation di cult
to (a) transfer or reuse in other applications, (b) reason about or analyze to
ascertain whether the adaptations will result in proper-running systems, and (c)
change.
      </p>
      <p>
        Recently, the research community in the area of distributed-systems is
focusing on the general area of self-* [
        <xref ref-type="bibr" rid="ref16 ref2">2, 16</xref>
        ]. For instance, self-healing systems attempt
to \heal" themselves in the sense of recovering from faults and regaining
normative performance levels independently in a way similar to how biological system
heals a wound [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. The lesson learned is that implementing self-adaptation
often implies 1) the ability of self-tuning own behavior for reacting to external
changes ans 2) the ability of re ecting upon how to behave, own capabilities and
resources, for adapting to changes.
      </p>
      <p>
        Several scientists agree [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] that self-adaptation (for humans as well as for
software components) is closely related to the ability of reasoning about its own
outer and inner world, or in other worlds, being self-aware. So far, there is still
the need for methods that allow to implement these two features by using results
from the theoretical approach to the implementation one.
      </p>
      <p>
        The complexity of current and emerging computing systems has lead to take
inspiration from several areas (for instance complex systems, control theory,
arti cial intelligence, sociology, philosophy, biology, . . . ). In Philosophy, the term
awareness is often associated with theories of consciousness and of self-referential
behavior [
        <xref ref-type="bibr" rid="ref14 ref17">14, 17</xref>
        ]. \Thinking that One Thinks" resumes a very high level of
awareness that is common in human consciousness.
      </p>
      <p>
        Examining the literature we discovered several approaches to self-adaption.
Holland and Goodman [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] built an internal model of the environment and
generated suitable predictions, Haikonen [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] used the feedback received by a loop in
which the model of the environment is implicitly learned in terms of weights of
an associative neural network. First Order Logic has been used by Weyhrauch
that proposed a system able to make inferences and re ect on them; he
established a seminal theory to provide arti cial reasoning systems with self re ection
capability [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ]. The work in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] deals with the relationship between higher order
access and phenomenology through the use of a kernel architecture based on the
ve axioms of consciousness. Manzotti [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] introduced the externalist point of
view, self-conscious ability is reached by continuously comparing the subjective
with the objective experience, by re ecting about itself and the world around.
So from the theoretical point of view, higher order perception sees an entity able
to re ect about itself hence to make inferences about how to act in the world.
      </p>
      <p>This work focuses on creating tools for implementing agents that reason on
their own goals, capabilities and knowledge of the environment. Above all, we
experienced the use of JASON where an agent is able to reason in order to act
in the environment for pursuing its goals but it is not able to re ect on its plans
and to re-organize them for dealing with changing situations. Thus inspired by
the beliefs of beliefs mechanism we provide some implementation techniques for
enabling agents to dynamically reason on their knowledge about the environment
as well as on the knowledge of themselves: their goals, their capabilities and their
current execution states.</p>
      <p>We aim at reducing the gap between self-awareness theory and
implementation in the context of multi-agent systems, since self awareness is not native in
the most common and used agent oriented language.</p>
      <p>The paper is organized as follows: Sections 2 provides an overview on the
JASON agent language, Section 3 shows how to implement self-awareness in
JASON, section 4 discusses the proposed work using an experiment and nally
Section 5 draws some conclusions.</p>
    </sec>
    <sec id="sec-2">
      <title>The JASON Architecture</title>
      <p>
        The JASON [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] platform is based on the AgentSpeak language [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] and the BDI
theory [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The Belief Desire Intention (BDI) model was developed at the
Stanford Research Institute during the activities of the Rational Agency project. It is
derived from the theory of human practical reasoning formulated by the
philosopher Michael Bratman. In the BDI model we assume that computer programs
can have a mental state. Thus, when we refer to a Belief-Desire-Intention system,
we are considering computer programs having computational features that are
analogues of beliefs, desires and intentions [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>Beliefs are information the agent owns about the environment where it runs
and, of course, it could also be out of date, inaccurate or false.</p>
      <p>
        Desires correspond to the possible states of the world the agent might like to
achieve. A desire, however, does not imply that an agent acts for ful lling it. A
desire is then only an option among all the future possible actions of the agent.
Instead, intentions are states of world that the agent has decided to achieve.
The BDI paradigm is based on a decision making model known as Practical
Reasoning (PR). PR consists in two steps. First, the PR process takes into
account all the Desires of an agent and selects the most suitable ones according
to the agent's Beliefs. This deliberation step produces as results that an agent
adopts an intention to pursue the selected desire. Intentions play a much stronger
role in in uencing the following action of the agent than desires do [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>Intentions are characterized by an important property: they persist. When
an agent adopts an intention, then it attempts to achieve it. If it initially does
not success, then it would try again, and it will not easily give up. However, it
may happen that beliefs (or other changes in the world) make the intention not
useful or interesting anymore. In this case it will be dropped it. Thus the agent
reconsiders the new situation and selects another desire.</p>
      <p>Moreover, once an agent adopted an intention, its future deliberative
reasoning will consider or adopt options that are consistent with that intention.
Finally, intentions are closely related to beliefs about the future. In particular,
to pursue an intention for achieving a particular state implies that this state is in
principle possible. Under normal circumstances, the agent will then succeed with
its intention. However, it is possible that its intention might fail. The second step
PR is called mean-ends reasoning. It is the process of deciding how to achieve
an intention on the base of the actions the agent can perform in his
environment. Means-ends reasoning is based on goals or intentions, beliefs and actions;
it should generate a plan, that is a sequence of actions. If the mean-ends
reasoning works properly it would produce the sequence of action the agent should
execute for attaining its goal or intention.</p>
      <p>However, it is a common practice in current application to develop collections
of partial plans at design time. The task of the agent is then to pursue these
plans for their execution at run time. This approach lacks of exibility because
the ability of an agent to deal with changing circumstances is dependent on the
plans coded for it by the agent programmer. Nevertheless, this approach can
work well in practice and AgentSpeak is based on that model.</p>
      <p>
        AgentSpeak is a programming language based on events and actions [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
The behavior of agents is ruled by programs written in the AgentSpeak
language. The state of an agent together with its environment and eventual other
agents represent its belief base. Desires are states which the agent wants to attain
based on its perceptions and beliefs. When an agent adopts a plan it transforms
a desire to an intention to be pursued. Hence, the program of an agent includes
a set of base beliefs and a set of plans. Plans are triggered by events and consist
of a sequence of actions to be performed. At run-time, an agent can be viewed
as consisting of several sets: beliefs, plans, intentions, events, actions and
selection functions. Among these elements only beliefs are explicitly represented with
modal formulas. Goals or sub-goals are actually considered as the successful nal
condition of plans.
      </p>
      <p>In JASON, the agent's knowledge is expressed by a symbolic representation
(based on implicit ontology) by using beliefs, that are simple predicates (such
as tall(john). or likes(john,music).) that state what the agent thinks to be true.
Sources of agent's beliefs are: (i) perception (the agent acquires beliefs as a
consequence of sensing the environment), (ii) communication (information acquired
from other agents is annotated by beliefs) and (iii) mental activity of an agent,
that may generate new information (mental notes), deducted from current beliefs
and added to the belief base for convenience. The current state of the agent, its
environment, and other agents, can be viewed as its current belief state. States
which the agent wants to bring about can be viewed as desires, that are used for
activating plans. The context of a plan is used for checking the current situation
so as to determine which plan is more suitable to be executed. The context is
a logic formula that must be true in order the plan to be applicable. The three
parts of a plan are triggering event : context body. Trigger conditions tell
the agent what are the speci c changes in the agent's mental attitudes for which
the plan is to be used.</p>
      <p>A JASON agent is continuously perceiving the environment and it is
reasoning about how to act on it for achieving its goals. The reasoning part of
the agent's cyclic behavior is done according to the plans the agent has in its
own plan library. In the current implementation, JASON agents are actually not
aware neither of their goals nor of their capabilities. The speci cation of a goal
is strictly connected to the plans to be executed for achieving it. In order to
implement adaptivity and self-awareness we have to separately de ne goals and
capabilities that is the sequence of actions or of sub-goals necessary for achieving
the goal. Such an issue will be discussed in the next sections.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Self-Aware Agents in Jason</title>
      <p>We consider self-awareness as a sort of ability of introspection the agent can use
to adapt its behavior to its own internal state. As well as in BDI systems, when</p>
      <p>Listing 1: Beliefs about a goal
we mention the internal state of an agent, we refer to the agent's knowledge of
its Goals, of its Capabilities and of the Environment.</p>
      <p>
        We adopt the de nition of system goal from GoalSPEC [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] in which a goal
is described as a tuple (Actor, TriggerCondition, FinalState). Where in JASON
a goal is a term !g(t1; : : : ; tn) which addition/deletion represents a trigger for
activating plans, in GoalSPEC, a system goal describes the state of the world
the agent wants to achieve. We also re ne the concept of Capability from the
BDI theory. A Capability is made of 1) the beliefs about what the agent is able
to do, and plans for actually addressing the declared result.
      </p>
      <p>In the agent belief-base, a goal is represented as a set of beliefs. Listing 1
reports an example of goal. The agent believes that: (at line 1) g1 is a goal; (at line
2) the system is responsible to address g1; (at lines 3-8) the triggering condition
of g1 is the AND-condition of two context-properties (property( unclassi ed,
[doc] ) and property( done, [received document] ) ); (at lines 9-12) the nal
state of g1 is also given by two context-properties (property(classif ied; [doc])
and property(done; [classif y]) ).</p>
      <p>The rst advantage of having goals in the agent belief base is that they can
dynamically change during the agent life. Indeed new goals can be added into
the belief-base, or existing goals can be ejected. Di erently from JASON, a goal
that is injected into the system does not automatically becomes a trigger for a
plan. Indeed, when injected, a goal has a lifecycle; Figure 1(a) shows the possible
states of a goal. The initial state is Injected. When the agent decides to address
it, then the goal moves to a state of Ready. When the goal's triggering condition
is true then the goal becomes Active. This state changes when the agent executes
its attempt to address it: if the goal's nal state is true then the goal is now
Addressed. Otherwise the goal stays Active unless a capability failure occurs.</p>
      <p>Another advantage is that the agent may reason on goals in the belief base
in order to decide its behavior. This property pushes the agent autonomy and
proactivity: for instance the agent can decide to commit to a goal only if it nds
this action convenient for itself. In any case, the necessary condition since an
agent can commit to a goal is shown in Listing 2.</p>
      <p>Listing 2: Rule for goal belief-set. The agent is able to commit to a goal when it
is able to catch the triggering condition and to address the nal state
1 a b l e t o c o m m i t t o ( G , C o n te x t )
2 : g o a l (G)
3 &amp; t r i g g e r i n g c o n d i t i o n (G , TC )
4 &amp; f i n a l s t a t e (G , FS )
5 &amp; a b l e t o c a t c h (TC, C on t e x t )
6 &amp; a b l e t o a d d r e s s ( FS , C o nt e x t )
7 .</p>
      <p>A Capability is composed of two components: a description and an
implementation. The capability description contains indications about when the capability
can be used and it is represented as a set of beliefs. On the other hand, the
implementation is a set of Jason plans to be executed when the agent wants to
activate the capability. Listing 3 reports an example of capability. The agent
believes that: (at line 1) classif y document is a capability the agent owns; (at lines
2-3) classif y document works on objects of type doc; when doc is in the initial
condition of available this capability promises to return a classif ied doc, if no
failures occur. The remaining part of the code concerns the capability
implementation. It is composed of three plans: (at line 5) the prepare plan is executed
before of all the other capability plans; it may be used to prepare data to work
on, or to wait some internal condition to be true; (at lines 6-11) the action plan
contains the body of the capability that addresses the state transition, as a set of
traditional Jason instructions; (at line 12) the terminate plan is executed after
the action is nished and may be used to de-allocate all data that has been used.</p>
      <p>All the three plans have the same arguments: the rst is the name of the
capability and the second is the Context variable that will be explained later on
this section. This makes to invoke a capability a ordable simply by knowing its
name. Listing 4 shows the Jason plan to invoke a capability and to retreat it.</p>
      <p>GOAL LIFECYCLE FS=false
Addressed FS=true</p>
      <p>Active
Injected
capability</p>
      <p>failure
commit</p>
      <p>TC=true</p>
      <p>Ready
eject
commitment failure</p>
      <p>goal
addressed</p>
      <p>Idle ignojeaclted
goal
disclaim</p>
      <p>GOAL ACHIEVEMENT LIFECYCLE</p>
      <p>Commitment goal Perceiving</p>
      <p>decision ready TC
rceocmomnsitimdeernt goal a/cptliavne
goal addressing</p>
      <p>Capability
execution
Recovering
failure
alternative
solutions
/replan
capability failure</p>
      <p>Perceiving</p>
      <p>FS
(a) The lifecycle of a goal</p>
      <p>(b) The lifecycle of a capability
Fig. 1: State charts for a goal and its achievement by an agent</p>
      <p>Listing 3: Beliefs about a capability
1 a g e n t c a p a b i l i t y ( c l a s s i f y d o c ) .
2 i n p u t s t a t e ( c l a s s i f y d o c , p r o p e r t y ( a v a i l a b l e , [ doc ] ) ) .
3 o u t p u t s t a t e ( c l a s s i f y d o c , p r o p e r t y ( c l a s s i f i e d , [ doc ] ) ) .
4
5 +! p r e p a r e ( c l a s s i f y d o c , Context ) &lt; t r u e .
6 +! a c t i o n ( c l a s s i f y d o c , Context )
7 &lt;
8 ! g e t d a t a ( doc , Doc , Context ) ;
9 ! c l a s s i f y d o c ( Doc ) ;
10 ! r e g i s t e r s t a t e ( p r o p e r t y ( c l a s s i f i e d , [ doc ] ) , Context ) ;
11 .
12 +! t e r m i n a t e ( c l a s s i f y d o c , Context ) &lt; t r u e .</p>
      <p>Listing 4: How to invoke a capability
1 +! i n v o k e c a p a b i l i t y ( C a p a b i l i t y , Context )
2 :
3 a g e n t c a p a b i l i t y ( C a p a b i l i t y )
4 &lt;
5 ! p r e p a r e ( C a p a b i l i t y , Context ) ;
6 ! a c t i o n ( C a p a b i l i t y , Context ) ;
7 .
8 +! r e t r e a t p r o j e c t c a p a b i l i t y ( C a p a b i l i t y , Context )
9 :
10 a g e n t c a p a b i l i t y ( C a p a b i l i t y )
11 &lt;
12 ! t e r m i n a t e ( C a p a b i l i t y , Context ) ;
13 .</p>
      <p>The advantage of this programming style, is to decouple goals from the plans
used to achieve them. However, the agent architecture must include a technique
for recreating the link among plans and goals at run-time (means-end reasoning).</p>
      <p>Listing 5 is a trivial example of a plan that given a Goal, tries to nd a
Capability among those the agent owns, that is suitable to address the goal's
nal state. The plan decomposes the FinalState into a set of properties that must
be true for considering the goal satis ed. Then the plan searches in the agent
belief base if at least one capability matches with this nal state. Of course
this plan can be more sophisticated, for instance it could consider additional
parameters for selecting the best capability to pick according to non functional
requirements such as quality of service, cost, etc.</p>
      <p>The variable Context, shown in Listings 3-Listing 4, is a reference for
grouping all the beliefs about the environment. There are cases in which an agent
may work with di erent contexts at the same time. It is more common that an
unique context exists for each agent. The Context reference may be used to store
property of the environment that are believed true, or value of parameters.
Listing 6 reports an example to store a property and one data-value into the context.
Of course these beliefs can be improved with other parameters on purpose, for
instance the trustability of the source, the timestamp of acquisition and so on.</p>
      <p>Listing 5: Plans for creating the bridge between a goal to address and the plan
to be executed
1 +! l i n k g o a l t o c a p a c i t y (G , C a p a b i l i t y )
2 :
3 f i n a l s t a t e (G , F i n a l S t a t e )
4 &lt;
5
6
7 .</p>
      <p>! d e c o m p o s e s u b s t a t e ( F i n a l S t a t e , S t a t e L i s t ) ;
! p i c k c a p a b i l i t y f o r ( C a p a b i l i t y , S t a t e L i s t ) ;</p>
      <p>Listing 6: Beliefs for representing properties and data of the context
1 e n v i r o n m e n t ( c o n t e x t , p r o p e r t y ( c l a s s i f i e d , [ doc ] ) .
2 e n v i r o n m e n t ( c o n t e x t , v a l u e ( doc , 12) ) .</p>
      <p>As we already described, the goal trigger condition belief set declares the
requirement for addressing a goal, and the capability input state beliefs declare
the requirements for activating a capability. Therefore before invoking the
capability, it is necessary to check if the current Context variable contains the proper
beliefs.</p>
      <p>Figure 1(b) shows the lifecycle of an agent when tries to address a goal by
using its own capabilities. The agent is initially in an Idle state, until a goal is
injected. Then it decides if making a commitment to the goal. The trivial case for
that is to check if it is able to do it according to the rule reported in Listing 2. Of
course this decision may be more complex, for instance by involving additional
parameters, and/or by looking for collaborations with other agents in the society.
If the agent commits to the goal, then it activates its perception capabilities to
detect when the goal's trigger condition is true. When this happens the agent
picks a capability according to the plan in Listing 5 and activates this capability
according to the plan in Listing 4. During the execution of the capability, the
agents also activates its perception capabilities again, in order to check if the nal
state has been properly addressed, thus to come back to the Idle state. Otherwise
the agent declares a capability failure and it enters in a Recovering state. This
can be solved in two ways: by selecting another capability to execute, if available,
or by coming back to the Commitment state, for changing its intentions. In the
case of a collaborative solution, the agent may ask for help from other agents,
or it may conclude with the complete failure in addressing the goal.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Experiencing self-awareness in work ows</title>
      <p>The Innovative Document Sharing (IDS) research project arose to deal with
selfadaption in work ow enactment. The mission of the project was to develop a
smart document management system to deploy in local small/medium enterprise.
business
analyst</p>
      <p>BPMN
goal-pack</p>
      <p>MAS
goal
goal web server
web page
workflow
users
Documents
Currently, a beta version of the described framework is already redeployed for
beta testing at three project partners.</p>
      <p>The grounding principle of our framework is to decouple what should be
addressed from how this result can be achieved; this allows to make the system
and the goal-set evolve independently. Thus, being dynamic, system
requirements may be considered as part of the execution context.</p>
      <p>The result has been a work ow engine (see Figure 2) realized as a multi-agent
system that exploits its features (mainly autonomy and proactivity) in order to
monitor the execution state of the process and to discover a distributed solution
to unpredictable situations or to speci cations' evolution.</p>
      <p>In such a system, each autonomous software agent must be self-aware as
described in Section 3. However, an agent is not generally able to execute the
whole work ow alone, so agents have to collaborate for building a distributed
plan.</p>
      <p>All together, the agents have to self-organize in groups that proactively
discover a distributed solution as the orchestration of many capabilities.
4.1</p>
      <p>
        From BPMN to System Goals Achievement
The whole engine grounds on GoalSPEC [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ], a language for representing
business and system goals. A goal has a responsible actor, and it describes a desired
state transition from a triggering condition to a nal state. We use the following
notation for goal state transition: g : tc &gt; f s. In order to reduce any additional
burden for business analysts, we maintain the BPMN as the main interface to
model work ows. Hence, we developed BPMN2Goal, a component that is
responsible to take a BPMN 2.0 XML le in input and to generate as output a set
of GoalSPEC goals. All the agents of the system are able to interpret GoalSPEC
and to convert goals into belief-sets (as well as in Listing 1).
      </p>
      <p>A di erence with the engine described in Section 3 is that goals coming
from the same work ow are correlated. They must be considered as a goal-pack
that is injected into the system as a whole. Agents collaborate to discover a
solution that is a set of potential commitment to a subset of the goal-pack. The
goals of a solution are closely related, since if the solution is actuated, then the
commitment must be done for all or none of them at the same time.</p>
      <p>Listing 7: Example of a perception capability
1 a g e n t c a p a b i l i t y ( m o n i t o r r e p o s i t o r y ) [ c a t e g o r y ( p e r c e p t i o n ) ] .
2 o u t p u t s t a t e ( m o n i t o r r e p o s i t o r y , p r o p e r t y ( a v a i l a b l e , [ doc ] ) ) .
3 o u t p u t v a l u e ( m o n i t o r r e p o s i t o r y , v a l u e ( doc ) ) .
4
5 +! p r e p a r e ( m o n i t o r r e p o s i t o r y , C on t e x t ) &lt; t r u e .
6 +! p e r c e p t ( m o n i t o r r e p o s i t o r y , C on t e x t )
7 &lt;
8 //MONITOR NEW DOCUMENTS
9 .
10 +! t e r m i n a t e ( m o n i t o r r e p o s i t o r y , C on t e x t ) &lt; t r u e .
4.2</p>
      <p>The Agent Level
The work ow enactment is possible because every agent owns special capabilities
for addressing the activities speci ed in the business plan. Anyway agents are
not designed with a priori knowledge about which plan is good for a given BPMN
activity, nor which is the right order for executing plans.</p>
      <p>It is up to the agents' autonomy to generate, at run-time, the missing link
between a goal set address and the plans to execute. In line with Figure ??
and Listings 4-5, these are the main features of an agent: (i) agents are able
to interpret the injected goals and to reason on the trigger condition and the
desired nal state; (ii) agents are aware of their own capabilities and can check
if they are able to commit to a system goal or a portion of it; and (iii) agents
monitor the current state of the context in order to identify when an expected
condition holds (trigger condition or nal state) and to check if something wrong
happens.</p>
      <p>Therefore, the architecture of Section 3 provides the engine for allowing an
agent to know its capabilities and for creating the bridge between capabilities
and goals (what an agent is able to do and what it is expected).</p>
      <p>The context is the portion of the environment in which the work ow operates.
It may include both software abstractions (document repository, web-services,
software resources, database, etc) and physical resources (hardware
devices/resources, physical environment and also human participants). In particular we
decided to use a di erent Context variable for each work ow instance in order
to separately store the state of parallel processes. Moreover the Context is shared
among all the agents that are involved in the enactment of the work ow instance.
Finally, all the beliefs concerning the state of the process and the availability of
resources are persistent, thus to let the system to be restored after a restart.</p>
      <p>For updating the Context, we implemented a proactive monitor loop based on
a set of Perceptions. Compatibly with the architecture of Section 3, agent
perceptions are also capabilities, that are specialized in monitoring a portion of the
environment. Listing 7 is an example of perception capability. The agent capability
belief uses the Jason Annotation syntax (e.g. [category(perception)] ) to tag the
capability as a perception one. The invocation of perception capability is similar
Listing 8: Example of a capability for interacting with human participants by
web pages
to those shown in Listing 4, but it invokes the percept plan cyclically until the
Context variable does not contain the conditions declared in the output state.</p>
      <p>Another new category of capability is used to interact with human
participants of the work ow. In our framework interaction has been realized by dynamic
web pages. Any participant has a personal page that lists all the Tasks that are
assigned to him. Any item in this list is a web-link to a dynamic web-page that
is generated ad hoc by the agent of the system that is responsible of monitoring
the Task progress. In other words the agent acts as a web server, reacting to
URL request by building and then routing the proper HTML page. Listing 8 is
an example of capability for interacting with human participants. The
annotation ([category(manual)] ) indicates the capability can be selected for handling
manual tasks. A new belief participant speci es the human role that is involved.
The beliefs input state and output state specify as usual the input and output
conditions for the capability execution. Finally a new belief http url speci es
routing information for the http protocol.</p>
      <p>The capability invocation mechanism di ers slightly from that of Listing 4.
The plan serve page substitutes the plan action that is invoked only when a
HTTP request incomes from the user. Listings 9 shows three new plans that
substitute the plan invoke capability of Listing 4, and the plan link goal to capacity
of Listing 5. The event +request triggers when a new http request incomes from
the user. A http request is associated to a relative path and a set of
parameters (in the form www.mydomain.net/path?par1=val1&amp;par2=val2). By
the http url belief it is possible to identify the capability that is responsible of
building the reply. The plan check capability is ready veri es the capability is
currently active (otherwise the agent will reply with an http error code). Finally
the plan serve request invokes the capability and then sends the web-page as
response to the user.</p>
      <p>Listing 9: How to invoke a capability for handling manual task implemented as
a web page
? h t t p u r l ( C a p a b i l i t y , Path ) ;
! c h e c k c a p a b i l i t y i s r e a d y ( C a p a b i l i t y , Path , ParamSet , P r o x y S e r v e r ) ;</p>
      <p>! s e r v e p a g e ( C a p a b i l i t y , Context , Path , ParamSet , ReplyHtml ) ;
. send ( P r o x y S e r v e r , t e l l , html ( Path , ParamSet , ReplyHtml ) ) ;
We already mentioned goal commitment becomes a social activity. This requires
to add further Jason plans to the basic mechanism of goal commitment presented
in Section 3.</p>
      <p>When a new goal-pack is injected, each agent may check if its own
capabilities allow to commit to some of these goals. Anyway, commitment is regulated
because: 1) goals in the same goal-pack are related one with the others, thus
the commitment must be for all or none of them at the same time; 2) more
agents could be able to commit the same goal, thus a synchronization technique
is required.</p>
      <p>The collective commitment to a goal-set is possible thanks to the formation
of many Teams of agents, each of them proposing a possible Solution to the
goalpack. A Solution is a set of related potential commitments to a subset of the goals
in the goal-pack that allows to address the whole work ow. Agents involved in a
solution form a Team. We omit to report the algorithm used for Team formation
and Solution discovery. Eventually, all the Solutions are compared on the base of
many possible parameters thus to select the winning one. The agent who formed
the winning Team is nominated leader and it is responsible to coordinate the
team for actuating the solution. Listing 10 reports the source code for handling
the social commitment. The Solution variable is a structure that contains the
name of the Leader agent and a list of Contracts. Every contract is a tuple
of: 1) the Agent who has engaged, 2) the Goal to which commit to, and 3)
the Cost requested by the agent for address the goal (this variable can in turn
be a structure formed by multiple parameters). By the .send instruction, all
the agents in the team receive the noti cation to commit to the proper goal.</p>
      <p>Listing 10: Plan for handling the commitment of a while goal-pack
Therefore the leader has also the additional responsibility to monitor when the
whole state transition is completed (the work ow is completed).
5</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusions</title>
      <p>The presented framework is based on decoupling the two concepts Goal and
Capability thus to make them evolve independently. To let agent a means-end
reasoning, we follow the approach of bridging at run-time what to do with how
to do. We have provided our agents the ability to explicitly reason on their goals,
capabilities and the knowledge of the environment.</p>
      <p>Another possible approach for implementing a mechanism of self-awareness
in JASON is to use the exible technique of subclassing. By customizing the
agent class and the architecture class it is also possible to extend the agent
reasoning cycle for implementing a more sophisticated technique for selecting
the plan to execute. However, making explicit the deliberation cycle without
modifying the agent architecture, (as in our approach) makes the concepts such
as Goal, Capability and Context rst class citizens of the language together with
native concepts of rules, plans and beliefs. The result is a exible and easy way
for customizing the agent architecture but maintaining the compatibility with
all the Jason extensions and plugins.</p>
      <p>In addition the approach o ers several extension points for programmer in
order to extend the basic functionalities. An example of this process has been
shown in Section 4 in which the Context variable is shared among many agents,
the commitment is a social activity, and more categories of capabilities have
been introduced over the existing architecture.</p>
      <p>
        Concluding, our approach mainly exploits rst-order logic programming that
is a common feature of other agent programming languages such as GOAL [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]
and 2APL [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. As well as JASON, these languages share a declarative approach
for develop agents that is based on a knowledge base, logic rules and procedural
plans (or capabilities in 2APL). However, the deliberation cycle of both GOAL
and 2APL is embedded in the respective framework and is not accessible by
language interpreter. We suppose our work cold be useful also for these agent
programming languages.
      </p>
      <p>Acknowledgements This work has been partially funded by the Innovative
Document Sharing (IDS) Project funded by the Autonomous Region of Sicily
(PO FESR Sicilia 2007-2013).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>I.</given-names>
            <surname>Aleksander</surname>
          </string-name>
          and
          <string-name>
            <given-names>H.</given-names>
            <surname>Morton</surname>
          </string-name>
          .
          <article-title>Computational studies of consciousness</article-title>
          .
          <source>Progress in Brain Research</source>
          ,
          <volume>168</volume>
          :
          <fpage>77</fpage>
          {
          <fpage>93</fpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>G. S.</given-names>
            <surname>Blair</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Coulson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Blair</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Duran-Limon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Grace</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Moreira</surname>
          </string-name>
          , and
          <string-name>
            <given-names>N.</given-names>
            <surname>Parlavantzas</surname>
          </string-name>
          .
          <article-title>Re ection, self-awareness and self-healing in openorb</article-title>
          .
          <source>In Proceedings of the rst workshop on Self-healing systems, pages</source>
          <volume>9</volume>
          {
          <fpage>14</fpage>
          . ACM,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>R.</given-names>
            <surname>Bordini</surname>
          </string-name>
          , J. Hubner, and
          <string-name>
            <given-names>M.</given-names>
            <surname>Wooldridge</surname>
          </string-name>
          .
          <article-title>Programming multi-agent systems in AgentSpeak using Jason</article-title>
          , volume
          <volume>8</volume>
          . Wiley-Interscience,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Bratman</surname>
          </string-name>
          .
          <article-title>What is intention</article-title>
          . Intentions in communication, pages
          <volume>15</volume>
          {
          <fpage>32</fpage>
          ,
          <year>1990</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Bratman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. J.</given-names>
            <surname>Israel</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Pollack</surname>
          </string-name>
          .
          <article-title>Plans and resource-bounded practical reasoning</article-title>
          .
          <source>Computational intelligence</source>
          ,
          <volume>4</volume>
          (
          <issue>3</issue>
          ):
          <volume>349</volume>
          {
          <fpage>355</fpage>
          ,
          <year>1988</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. B. Cheng, R. de Lemos, H. Giese,
          <string-name>
            <given-names>P.</given-names>
            <surname>Inverardi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Magee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Andersson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Becker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Bencomo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Brun</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Cukic</surname>
          </string-name>
          , et al.
          <article-title>Software engineering for self-adaptive systems: A research roadmap</article-title>
          .
          <source>Software Engineering for Self-Adaptive Systems</source>
          , pages
          <fpage>1</fpage>
          {
          <fpage>26</fpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>M.</given-names>
            <surname>Dastani</surname>
          </string-name>
          . 2APL:
          <article-title>a practical agent programming language. Autonomous agents and multi-agent systems</article-title>
          ,
          <volume>16</volume>
          (
          <issue>3</issue>
          ):
          <volume>214</volume>
          {
          <fpage>248</fpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>D.</given-names>
            <surname>Ghosh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Sharman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. Raghav</given-names>
            <surname>Rao</surname>
          </string-name>
          , and
          <string-name>
            <given-names>S.</given-names>
            <surname>Upadhyaya</surname>
          </string-name>
          .
          <article-title>Self-healing systems| survey and synthesis</article-title>
          .
          <source>Decision Support Systems</source>
          ,
          <volume>42</volume>
          (
          <issue>4</issue>
          ):
          <volume>2164</volume>
          {
          <fpage>2185</fpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>P.</given-names>
            <surname>Haikonen</surname>
          </string-name>
          .
          <article-title>The Cognitive Approach to Conscious Machines</article-title>
          . Imprint Academic, Exeter, UK,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>K. V.</given-names>
            <surname>Hindriks</surname>
          </string-name>
          , F. S. de Boer,
          <string-name>
            <given-names>W. Van Der</given-names>
            <surname>Hoek</surname>
          </string-name>
          , and J.
          <string-name>
            <surname>-J. C.</surname>
          </string-name>
          <article-title>Meyer. Agent programming with declarative goals</article-title>
          .
          <source>In Intelligent Agents VII Agent Theories Architectures and Languages</source>
          , pages
          <volume>228</volume>
          {
          <fpage>243</fpage>
          . Springer,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11. O. Holland and
          <string-name>
            <given-names>R.</given-names>
            <surname>Goodman</surname>
          </string-name>
          .
          <article-title>Robots with internal models - a route to machine consciousness?</article-title>
          <source>Journal of Consciousness Studies</source>
          ,
          <volume>10</volume>
          (
          <issue>4 -5</issue>
          ):
          <volume>77</volume>
          {
          <fpage>109</fpage>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>R.</given-names>
            <surname>Manzotti</surname>
          </string-name>
          .
          <article-title>A process oriented view of conscious perception</article-title>
          .
          <source>Journal of Consciousness Studies</source>
          ,
          <volume>13</volume>
          (
          <issue>6</issue>
          ):7 {
          <fpage>41</fpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>A. S.</given-names>
            <surname>Rao</surname>
          </string-name>
          . Agentspeak (l):
          <article-title>Bdi agents speak out in a logical computable language</article-title>
          .
          <source>In Agents Breaking Away</source>
          , pages
          <volume>42</volume>
          {
          <fpage>55</fpage>
          . Springer,
          <year>1996</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>D. M.</surname>
          </string-name>
          <article-title>Rosenthal. Consciousness and mind</article-title>
          . Oxford University Press Oxford,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15. L.
          <string-name>
            <surname>Sabatucci</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Ribino</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Lodato</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Lopes</surname>
            , and
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Cossentino</surname>
          </string-name>
          .
          <article-title>GoalSPEC: a Goal Speci cation Language supporting Adaptivity and Evolution. In Engineering Multi-Agent Systems</article-title>
          . LNCS 8245., In Printing.
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <given-names>B.</given-names>
            <surname>Schmerl</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Garlan</surname>
          </string-name>
          .
          <article-title>Exploiting architectural design knowledge to support self-repairing systems</article-title>
          .
          <source>In proceedings of the 14th SEKE</source>
          , pages
          <volume>241</volume>
          {
          <fpage>248</fpage>
          . ACM,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>V. E. Silva</given-names>
            <surname>Souza</surname>
          </string-name>
          .
          <article-title>Requirements-based Software System Adaptation</article-title>
          .
          <source>PhD thesis</source>
          , University of Trento,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>R.</given-names>
            <surname>Weyhrauch</surname>
          </string-name>
          .
          <article-title>Prolegomena to a theory of mechanized formal reasoning</article-title>
          .
          <source>Arti cial Intelligence</source>
          ,
          <volume>13</volume>
          (
          <issue>1-2</issue>
          ):
          <volume>133</volume>
          {
          <fpage>170</fpage>
          ,
          <year>1980</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>