=Paper= {{Paper |id=None |storemode=property |title=JaCa-Android: An Agent-based Platform for Building Smart Mobile Applications |pdfUrl=https://ceur-ws.org/Vol-627/lads_7.pdf |volume=Vol-627 |dblpUrl=https://dblp.org/rec/conf/mallow/SantiGR10 }} ==JaCa-Android: An Agent-based Platform for Building Smart Mobile Applications== https://ceur-ws.org/Vol-627/lads_7.pdf
          JaCa-Android: An Agent-based Platform for
             Building Smart Mobile Applications
              Andrea Santi                              Marco Guidi                               Alessandro Ricci
         University of Bologna                     University of Bologna                    DEIS, University of Bologna
             Cesena, Italy                             Cesena, Italy                               Cesena, Italy
         Email: a.santi@unibo.it            Email: marco.guidi7@studio.unibo.it               Email: a.ricci@unibo.it



   Abstract—Agent-Oriented Programming (AOP) provides an             by mainstream programming languages such as the object-
effective level of abstraction for tackling the programming          oriented ones.
of mainstream software applications, in particular those that           So, in this paper we discuss the application of an agent-
involve complexities related to concurrency, asynchronous events
management and context-sensitive behaviour. In this paper we         oriented programming platform called JaCa for the develop-
support this claim in practice by discussing the application of      ment of smart mobile applications. Actually JaCa is not a
AOP technologies – Jason and CArtAgO in particular – for the         new platform, but simply the integration of two existing agent
development of smart mobile applications based on the Google         programming technologies: Jason [5] agent programming
Android platform.                                                    language and platform, and CArtAgO [17] framework, for
                                                                     programming and running the environments where agents
                      I. I NTRODUCTION                               work. JaCa is meant to be a general-purpose programming
                                                                     platform, so useful for developing software applications in
   The value of Agent-Oriented Programming (AOP) [20] – in-          general. In order to apply JaCa to mobile computing, we
cluding Multi-Agent Programming (MAP) – is often remarked            developed a porting of the platform on top of Google Android,
and evaluated in the context of Artificial Intelligence (AI)         which we refer as JaCa-Android. Google Android is an open-
and Distributed AI problems. This is evident, for instance,          source software stack for mobile devices provided by Google
by considering existing agent programming languages (see             that includes an operating system (Linux-based), middleware,
[4], [6] for comprehensive surveys) – whose features are             SDK and key applications.
typically demonstrated by considering toy problems such as              Other works in literature discuss the use of agent-based
block worlds and alike.                                              technology on mobile devices—examples include AgentFac-
   Besides this view, we argue that the level of abstraction in-     tory [13], 3APL [10], JADE [3]. Differently from these works,
troduced by AOP is effective for organizing and programming          here we do not consider the issue of porting agent technologies
software applications in general, starting from those programs       on limited capability devices, but we focus on the advantages
that involve aspects related to reactivity, asynchronous inter-      brought by the adoption of agent-oriented programming level
actions, concurrency, up to those involving different degrees        of abstraction for the development of complex mobile appli-
of autonomy and intelligence. Following this view, one of            cations.
our current research lines investigates the adoption and the            The remainder of the paper is organised as follows: in
evaluation of existing agent-based programming languages and         Section II we provide a brief overview of the JaCa platform
technologies for the development of applications in some of          – which we consider part of the background of this paper;
the most modern and relevant application domains. In this            then, in Section III we introduce and discuss the application
context, a relevant one is represented by next generation            of JaCa for the development of smart mobile applications on
mobile applications. Applications of this kind are getting a         top of Android, and in Section IV we describe two practical
strong momentum given the diffusion of mobile devices which          application samples useful to evaluate the approach. Finally,
are more and more powerful, in terms of computing power,             in Section V we briefly discuss some open issues related
memory, connectivity, sensors and so on. Main examples are           to JaCa-Android and, more generally, to the use of current
smart-phones such as the iPhone and Android-based devices.           agent-oriented programming technologies for developing ap-
On the one side, smart mobile applications share more and            plications and related future works.
more features with desktop applications, and eventually ex-
tending such features with capabilities related to context-              II. AGENT-O RIENTED P ROGRAMMING FOR M AINSTREAM
awareness, reactivity, usability, and so on, all aspects that are          A PPLICATION D EVELOPMENT – T HE J AC A A PPROACH
important in the context of Internet of Things and Ubiquitous          An application in JaCa is designed and programmed as
Computing scenarios. All this increases – on the other side          a set of agents which work and cooperate inside a com-
– the complexity required for their design and programming,          mon environment. Programming the application means then
introducing aspects that – we argue – are not suitably tackled       programming the agents on the one side, encapsulating the



                                                                    48
logic of control of the tasks that must be executed, and the           use of artifact-based environments by Jason agents seamless.
environment on the other side, as a first-class abstraction            To this purpose, first, the overall set of external actions that a
providing the actions and functionalities exploited by the             Jason agent can perform is determined by the overall set of
agents to do their tasks. It is worth remarking that this is an        artifacts that are actually available in the workspaces where
endogenous notion of environment, i.e. the environment here            the agent is working. So, the action repertoire is dynamic and
is part of the software system to be developed [18].                   can be changed by agents themselves by creating, disposing
   More specifically, in JaCa Jason [5] is adopted as pro-             artifacts. Then, the overall set of percepts that a Jason
gramming language to implement and execute the agents and              agent can observe is given by the observable properties and
CArtAgO [17] as the framework to program and execute the               observable events of the artifacts available in the workspace
environments.                                                          at runtime. Actually an agent can explicitly select which
   Being a concrete implementation of an extended version              artifacts to observe, by means of a specific action called
of AgentSpeak(L) [15], Jason adopts a BDI (Belief-Desire-              focus. By observing an artifact, artifacts’ observable properties
Intention)-based computational model and architecture to de-           are directly mapped into beliefs in the belief-base, updated
fine the structure and behaviour of individual agents. In that,        automatically each time the observable properties change their
agents are implemented as reactive planning systems: they run          value. So a Jason agent can specify plans reacting to changes
continuously, reacting to events (e.g., perceived changes in the       to beliefs that concern observable properties or can select plans
environment) by executing plans given by the programmer.               according to the value of beliefs which refer to observable
Plans are courses of actions that agents commit to execute             properties. Artifacts’ signals instead are not mapped into the
so as to achieve their goals. The pro-active behaviour of              belief-base, but processed as non persistent percepts possibly
agents is possible through the notion of goals (desired states         triggering plans—like in the case of message receipt events.
of the world) that are also part of the language in which plans        Finally, the Jason data-model – essentially based on Prolog
are written. Besides interacting with the environment, Jason           terms – is extended to manage also (Java) objects, so as
agents can communicate by means of speech acts.                        to work with data exchanged by performing actions and
   On the environment side, CArtAgO – following the A&A                processing percepts.
meta-model [14], [19] – adopts the notion of artifact as first-           A full description of Jason language/platform and
class abstraction to define the structure and behaviour of             CArtAgO framework – and their integration – is out of the
environments and the notion of workspace as a logical con-             scope of this paper: the interested reader can find details in
tainer of agents and artifacts. Artifacts explicitly represent the     literature [17], [16] and on Jason and CArtAgO open-source
environment resources and tools that agents may dynamically            web sites12 .
instantiate, share and use, encapsulating functionalities de-
signed by the environment programmer. In order to be used by               III. P ROGRAMMING S MART M OBILE A PPLICATIONS WITH
the agents, each artifact provides a usage interface composed                                     J AC A
by a set of operations and observable properties. Operations              In this section we describe how JaCa’s features can be
correspond to the actions that the artifact makes it available         effectively exploited to program smart mobile applications,
to agents to interact with such a piece of the environment;            providing benefits over existing non-agent approaches. First,
observable properties define the observable state of the artifact,     we briefly sketch some of the complexities related to the
which is represented by a set of information items whose value         design and programming of such a kind of applications; then,
(and value change) can be perceived by agents as percepts.             we describe how these are addressed in JaCa-Android—
Besides observable properties, the execution of operations             which is the porting of JaCa on Android, extended with a
can generate signals perceivable by agents as percepts, too.           predefined set of artifacts specifically designed for exploiting
As a principle of composability, artifacts can be assembled            Android functionalities.
together by a link mechanism, which allows for an artifact to
                                                                       A. Programming Mobile Applications: Complexities
execute operations over another artifact. CArtAgO provides a
Java-based API to program the types of artifacts that can be              Mobile systems and mobile applications have gained a lot
instantiated and used by agents at runtime, and then an object-        of importance and magnitude both in research and industry
oriented data-model for defining the data structures used in           over the last years. This is mainly due to the introduction
actions, observable properties and events.                             of mobile devices such as the iPhone3 and the most modern
   The notion of workspace is used to define the topology              Android4 -based devices that changed radically the concept
of complex environments, that can be organised as multiple             of smart-phone thanks to: (i) hardware specifications that
sub-environments, possibly distributed over the network. By            allow to compare these devices to miniaturised computers,
default, each workspace contains a predefined set of artifacts         situated – thanks to the use of practically every kind of known
created at boot time, providing basic actions to manage the            connectivity (GPS, WiFi, bluetooth, etc.) – in a computational
overall set of artifacts (for instance, to create, lookup, link to-         1 http://jason.sourceforge.net
gether artifacts), to join multiple workspaces, to print messages           2 http://cartago.sourceforge.net
on the console, and so on.                                                  3 http://www.apple.com/it/iphone/

   JaCa integrates Jason and CArtAgO so as to make the                      4 http://www.android.com/




                                                                      49
network which is becoming more and more similar to the              that particular Intent. The set of Intents manageable by a
vision presented by both the Internet of Things and ubiquitous      component are defined by specifying, for that component, a
computing, and (ii) the evolution of both the smart-phone O.S.      proper set of IntentFilters.
(Apple iOS, Android, Meego5 ) and their related SDK.                   Generally speaking, these components and the Intent-based
   These innovations produce a twofold effect: on the one           interaction model are useful – indeed – to organise and
side, they open new perspectives, opportunities and application     structure applications; however – being the framework fully
scenarios for these new mobile devices; on the other side,          based on an object-oriented virtual machine and language such
they introduce new challenges related to the development            as Java – they do not shield programmers from using callbacks,
of the mobile applications, that are continuously increasing        threads, and low-level synchronisation mechanisms as soon as
their complexity [1], [11]. These applications – due to the         applications with complex reactive behaviour are considered.
introduction of new usage scenarios – must be able to address       For instance, in classic Android applications asynchronous
issues such as concurrency, asynchronous interactions with dif-     interactions with external resources are still managed using
ferent kinds of services (Web sites/Services, social-networks,      polling loops or some sort of mailbox; context-dependent
messaging/mail clients, etc.) and must also expose a user-          behaviour must be realised staining the source code with
centric behaviour governed by specific context information          a multitude of if statements; concurrency issues must be
(geographical position of the device, presence/absence of           addressed using Java low-level synchronisation mechanisms.
different kinds of connectivity, events notification such as the    So, more generally, we run into the problems that typically
reception of an e-mail, etc.).                                      arise in mainstream programming languages when integrating
   To cope with these new requirements, Google has developed        one or multiple threads of control with the management of
the Android SDK6 , which is an object-oriented Java-based           asynchronous events, typically done by callbacks.
framework meant to provide a set of useful abstractions for en-        In the next section we discuss how agent-oriented program-
gineering mobile applications on top of Android-enable mobile       ming and, in particular, the JaCa programming model, are
devices. Among the main coarse-grain components introduced          effective to tackle these issues at a higher-level of abstraction,
by the framework to ease the application development we             making it possible to create more clear, terse and extensible
mention here:                                                       programs.
   • Activities: an activity provides a GUI for one focused
                                                                    B. An Agent-oriented Approach based on JaCa
      endeavor the user can undertake. For example, an activity
      might present a list of menu items users can choose, list        By adopting the JaCa programming model, a mobile An-
      of contacts to send messages to, etc.                         droid application can be realised as a workspace in which
   • Services: a service does not have a GUI and runs in the        Jason agents are used to encapsulate the logic and the control
      background for an indefinite period of time. For example,     of tasks involved by the mobile application, and artifacts are
      a service might play background music as the user attends     used as tools for agents to seamlessly exploit available Android
      to other matters.                                             device/platform components and services.
   • Broadcast Receiver: a broadcast receiver is a component           From a conceptual viewpoint, this approach makes it pos-
      that does nothing but receive and react to broadcast          sible to keep the same level of abstraction – based on agent-
      announcements. Many broadcasts originate in system            oriented concepts – both when designing the application and
      code - for example, announcements that the timezone has       when concretely implementing it using Jason and CArtAgO.
      changed, that the battery is low, etc.                        In this way we are able to provide developers a uniform
   • Content providers: a content provider makes a specific set     guideline – without conceptual gaps between the abstractions
      of the application’s data available to other applications.    used in the analysis and implementation phases – that drives
      The data can be stored in the file system, in an SQLite       the whole engineering process of a mobile application.
      database, etc.                                                   From a programming point of view, the agent paradigm
                                                                    makes it possible to tackle quite straightforwardly some of
   In Android, interactions among components are managed
                                                                    the main challenges mentioned in previous sections, in partic-
using a messaging facility based on the concepts of Intent
                                                                    ular: (i) task and activity oriented behaviours can be directly
and IntentFilter. An application can request the execution of
                                                                    mapped onto agents, possibly choosing different kinds of
a particular operation – that could be offered by another
                                                                    concurrent architectures according to the needs—either using
application or component – simply providing to the O.S. an
                                                                    multiple agents to concurrently execute tasks, or using a single
Intent properly characterised with the information related to
                                                                    agent to manage the interleaved execution of multiple tasks;
that operation. So, for example, if an application needs to
                                                                    (ii) agents’ capability of adapting the behaviour on the basis of
display a particular Web page, it expresses this need creating
                                                                    the current context information can be effectively exploited to
a proper Intent instance, and then sending this instance to the
                                                                    realise context-sensitive and context-dependent applications;
Android operating system. The O.S. will handle this request
                                                                    (iii) asynchronous interactions can be managed by properly
locating a proper component – e.g. a browser – able to manage
                                                                    specifying the agents’ reactive behaviour in relation to the
  5 http://meego.com                                                reception of particular percepts (e.g. the reception of a new
  6 http://developer.android.com/sdk/index.html                     e-mail).



                                                                   50
               JaCa-Android app                   JaCa-services
                                                shared workspace                     •   CalendarArtifact, providing functionalities for man-
                                  ActivityGUI                   SMSManager
                  MyArtifact                                                          aging the built-in Google calendar.
                                                                                 These artifacts, being general purpose, are situated in a
                                                    Calendar
                                                                  GPSArtifact
                                                                                 workspace called jaca-services (see Fig. 1) which is shared
                                                                                 by all the JaCa-Android applications—being stored and
                                                                                 executed into a proper Android service installed with the
                                                                                 JaCa-Android platform. More generally, any JaCa-Android
                                           JaCa
                                                  JaCa Android artifacts         workspace can be shared among different applications—
                                     (Jason+CArtAgO)
                                                                                 promoting, then, the modularisation and the reuse of the
                                   Android Framework                             functionalities provided by JaCa-Android applications.
                           (Dalvik Virtual Machine + Libraries)
                                                                                   In next section we discuss more in detail the benefits of
                                         Linux kernel                            the JaCa programming model for implementing smart mobile
                                                                                 applications by considering two application samples that have
                                                                                 been developed on top of JaCa-Android.
Fig. 1. Abstract representation of the JaCa-Android platform – with in
evidence the different agent technologies on which the platform is based –               IV. E VALUATION THROUGH P RACTICAL E XAMPLES
and of generic applications running on top of it.
                                                                                    The first example aims at showing how the approach al-
                                                                                 lows for easily realising context-sensitive mobile applications.
                                                                                 For this purpose, we consider a JaCa-Android application
   To see this in practice, we developed a porting of JaCa
                                                                                 inspired to Locale8 , one of the most famous Android ap-
on top of Android – referred as JaCa-Android – available as
                                                                                 plications and also one of the winners of the first Android
open-source project7 . Fig. 1 shows an abstract representation
                                                                                 Developer Contest9 . This application (JaCa-Locale) can be
of the levels characterising the JaCa-Android platform and
                                                                                 considered as a sort of intelligent smart-phone manager re-
of a generic applications running on top of it.
                                                                                 alised using a simple Jason agent. The agent during its
   The platform includes a set of predefined types of artifacts
                                                                                 execution uses some of the built-in JaCa-Android artifacts
(BroadcastReceiverArtifact,             ActivityArtifact,
                                                                                 described in Section III and two application-specific artifacts:
ContentProviderArtifact,                  ServiceArtifact)
                                                                                 a PhoneSettingsManager artifact used for managing the
specifically designed to build compliant Android components.
                                                                                 device ringtone/vibration and the ContactManager used for
So, standard Android components become fully-fledged
                                                                                 managing the list of contacts stored into the smart-phone
artifacts that agents and agent developers can exploit without
                                                                                 (this list is an observable property of the artifact, so directly
worrying and knowing about infrastructural issues related to
                                                                                 mapped into agents beliefs). The agent manages the smart-
the Android SDK. This makes it possible for developers to
                                                                                 phone behaviour discriminating the execution of its plans on
conceive and realise mobile applications that are seamlessly
                                                                                 the basis of a comparison among its actual context information
integrated with the Android SDK, possibly interacting/re-
                                                                                 and a set of user preferences that are specified into the agent’s
using every component and application developed using the
                                                                                 plans contexts. TABLE I reports a snipped of the Jason
standard SDK. This integration is fundamental in order to
                                                                                 agent used in JaCa-Locale, in particular the plans shown in
guarantee to developers the re-use of existing legacy – i.e.
                                                                                 TABLE I are the ones responsible of the context-dependent
the standard Android components and applications – and for
                                                                                 management of the incoming phone calls.
avoiding the development of the entire set of functionalities
                                                                                    The behaviour of the agent, once completed the initialisation
required by an application from scratch.
                                                                                 phase (lines 00-07), is governed by a set of reactive plans. The
   Besides, the platform also provides a set of artifacts that                   first two plans (lines 9-15) are used for regulating the ringtone
encapsulate some of the most common functionalities used                         level and the vibration for the incoming calls on the basis of
in the context of smart mobile applications. In detail these                     the notifications provided by the CalandarArtifact about
artifacts are:                                                                   the start or the end of an event stored into the user calendar.
  •   SMSManager/MailManager,         managing    sms/mail-                      Instead, the behaviour related to the handling of the incoming
    related functionalities (send and receive sms/mail,                          calls is managed by the two reactive plans incoming_call
    retrieve stored sms/mail, etc.).                                             (lines 17-28). The first one (lines 17-19) is applicable when
  • GPSManager, managing gps-related functionalities (e.g.                       a new incoming call arrives and the phone owner is not
    geolocalisation of the device).                                              busy, or when the incoming call is considered critical. In
  • CallManager, providing functionalities for handling –                        this case the agent normally handles the incoming call – the
    answer/reject – phone calls.                                                 ringtone/vibration settings have already been regulated by the
  • ConnectivityManager, managing the access to the                              plans at lines 9-15 – using the handle_call operation pro-
    different kinds of connectivity supported by the mobile                      vided by the CallManager artifact. The second plan instead
    device.
                                                                                     8 http://www.twofortyfouram.com/
  7 http://jaca-android.sourceforge.net                                              9 http://code.google.com/intl/it-IT/android/adc/




                                                                                51
 00   !init.
 01
 02   +!init
 03     <- focus("SMSManager"); focus("MailManager");
 04        focus("CallManager"); focus("ContactManager");
 05        focus("CalendarArtifact");
 06        focus("PhoneSettingsManager");
 07        focus("ConnectivityManager").
 08
 09   +cal_event_start(EventInfo) : true
 10     <- set_ringtone_volume(0);
 11        set_vibration(on).
 12
 13   +cal_event_end(EventInfo) : true
 14     <- set_ringtone_volume(100);
 15        set_vibration(off).
 16
 17   +incoming_call(Contact, TimeStamp)
 18     : not busy(TimeStamp) | is_call_critical(Contact)
 19     <- handle_call.
 20
 21   +incoming_call(Contact, TimeStamp)
 22     : busy(TimeStamp) & not is_call_critical(Contact)
 23     <- get_event_description(TimeStamp,EventDescription);
 24        drop_call;
 25        .concat("Sorry, I’m busy due
 26          to", EventDescription, "I will call you back
 27          as soon as possible.", OutStr);
 28        !handle_auto_reply(OutStr).
 29
 30   +!handle_auto_reply(Reason) : wifi_status(on)
 31     <- send_mail("Auto-reply", Reason).
 32
 33   +!handle_auto_reply(Reason): wifi_status(off)
 34     <- send_sms(Reason).
                             TABLE I
      S OURCE CODE SNIPPET OF THE J AC A -L OCALE Jason AGENT



(lines 21-28) is applicable when the user is busy and the call
does not come from a relevant contact. In this case the phone
call is automatically rejected using the drop_call operation            Fig. 2. Screenshot of the SmartNavigator application that integrate in its
of the CallManager artifact (line 24), and an auto-reply mes-           GUI some of the Google Maps components for showing: (i) the user current
sage containing the motivation of the user unavailability is sent       position, (ii) the road directions, and (iii) the route to the designed destination.
back to the contact that performed the call. This notification is
                                                                        can fully separate the code that defines the control logic of
sent – using one of the handle_auto_reply plans (lines 30-
                                                                        the application (into agents) from the reusable functionalities
34) – via sms or via mail (using respectively the SMSManager
                                                                        (embedded into artifacts) that are need by the application,
or the MailManager) depending on the current availability
                                                                        making agents’ source code more dry.
of the WiFi connection on the mobile device (availability
                                                                           The second application sample – called SmartNavigator
checked using the wifi_status observable property of the
                                                                        (see Fig. 2 for a screenshot) – aims at showing the effective-
ConnectivityManager). It is worth remarking that busy
                                                                        ness of the approach in managing asynchronous interactions
and is_call_critical refer to rules – not reported in the
                                                                        with external resources, such as – for example – Web Services.
source code – used for checking respectively: (i) if the phone
                                                                        This application is a sort of smart navigator able to assist
owner is busy – by checking the belief related to one of the
                                                                        the user during his trips in an intelligent way, taking into the
CalendarArtifact observable properties (current_app) –
                                                                        account the current traffic conditions.
or (ii) if the call is critical – by checking if the call comes from
                                                                           The application is realised using a single Jason agent
one of the contact in the ContactManager list considered
                                                                        and four different artifacts: (i) the GPSManager used for the
critical: e.g. the user boss/wife.
                                                                        smart-phone geolocalisation, (ii) the GoogleMapsArtifact,
   Generalising the example, context-sensitive applications can
                                                                        an artifact specifically developed for this application, used for
be designed and programmed in terms of one or more agents
                                                                        encapsulating the functionalities provided by Google Maps
with proper plans that are executed only when the specific
                                                                        (e.g. calculate a route, show points of interest on a map,
context conditions hold.
                                                                        etc.), (iii) the SmartNavigatorGUI, an artifact developed on
   The example is useful also for highlighting the benefits             the basis of the ActivityArtifact and some other Google
introduced by artifact-based endogenous environments: (i) it            Maps components, used for realizing the GUI of the appli-
makes it possible to represent and exploit platform/device              cation and (iv) an artifact, TrafficConditionsNotifier,
functionalities at an agent level of abstractions – so in terms         used for managing the interactions with a Web site10 that
of actions and perceptions, modularised into artifacts; (ii) it
provides a strong separation of concerns, in that developers                10 http://www.stradeanas.it/traffico/




                                                                       52
                                                                         00   preferences([...]).
provides real-time traffic information.                                  01   relevance_range(10).
                                                                         02
   TABLE II shows a snippet of the agent source code.                    03   !assist_user_trips.
The agent main goal assist_user_trips is managed by                      04
                                                                         05   +!assist_user_trips
a set of reactive plans that are structured in a hierarchy               06     <- focus("GPSManager");
of sub-goals – handled by a set of proper sub-plans. The                 07        focus("GoogleMapsArtifact");
                                                                         08        focus("SmartNavigatorGUI");
agent has a set of initial beliefs (lines 00-01) and an initial          09        focus("TrafficConditionsNotifier").
plan (lines 5-9) that manages the initialisation of the arti-            10
                                                                         11   +route(StartLocation, EndLocation)
facts that will be used by the agent during its execution.               12     <- !handle_navigation(StartLocation, EndLocation).
The first plan, reported at lines 11-12, is executed after               13
                                                                         14   +!handle_navigation(StartLocation, EndLocation)
the reception of an event related to the modification of                 15     <- ?relevance_range(Range); ?current_position(Pos);
the SmartNavigatorGUI route observable property – a                      16        -+leaving(StartLocation);-+arriving(EndLocation);
                                                                         17        calculate_route(StartLocation,
property that contains both the starting and arriving locations          18          EndLocation, OutputRoute);
provided in input by the user. The handling of this event is             19        -+route(OutputRoute);
                                                                         20        subscribe_for_traffic_condition(OutputRoute,
managed by the handle_navigation plan that: (i) retrieves                21          Range);
(line 15) and updates the appropriate agent beliefs (line 16             22        set_current_position(Pos);
                                                                         23        update_map.
and 19), (ii) computes the route using an operation provided             24
by the GoogleMapsArtifact (calculate_route lines 17-                     25   +new_traffic_info(TrafficInfo)
                                                                         26     <- ?preferences(Preferences);
18), (iii) makes the subscription – for the route of interest            27        ?leaving(StartLocation); ?arriving(EndLocation);
– to the Web site that provides the traffic information using            28        !check_info_relevance(TraffincInfo,Preferences);
                                                                         29        !update_route(StartLocation, EndLocation,
the TrafficConditionsNotifier (lines 20-21), and finally                 30          TrafficInfo, NewRoute);
(iv) updates the map showed by the application (using the                31        !update_subscription(NewRoute);
                                                                         32        update_map.
SmartNavigatorGUI operations set_current_position                        33
and update_map, lines 22-23) with both the current position              34   +current_position(Pos)
                                                                         35     <- ?route(Route);
of the mobile device (provided by the observable property                36        !check_position_consistency(Pos, Route);
current_position of the GPSManager) and the new route.                   37        set_current_position(Pos);
                                                                         38        update_map.
   In the case that no meaningful changes occur in the traf-             39
fic conditions and the user strictly follows the indications             40   -!check_position_consistency(Pos, Route)
                                                                         41     : arriving(EndLocation)
provided by the SmartNavigator, the map displayed in                     42     <- !handle_navigation(Pos, EndLocation).
the application GUI will be updated, until arriving to the                                         TABLE II
designed destination, simply moving the current position of               S OURCE CODE SNIPPET OF THE S MART N AVIGATOR J ASON AGENT
the mobile device using the plan reported at lines 34-38.
This plan, activated by a change of the observable property          reactive behaviour of a JaCa-Android application – in this
current_position, simply considers (using the sub-plan
                                                                     example the asynchronous reception of information from a
check_position_consistency instantiated at line 36, not
                                                                     certain source – with its pro-active behaviour — assisting the
reported for simplicity) if the new device position is consistent    user during his trips. This integration allows to easily modify
with the current route (retrieved from the agent beliefs at          and adapt the pro-active behaviour of an application after the
line 35) before updating the map with the new geolocation            reception of new events that can be handled by proper reactive
information (line 37-38). In the case in which the new position      plans: in this example, the reception of the traffic updates can
is not consistent – i.e. the user chose the wrong direction – the    lead the SmartNavigator to consider a new route for the
sub-plan check_position_consistency fails. This fail is              trip on the basis of the new information.
handled by a proper Jason failure handling plan (lines 40-42)
                                                                                   V. O PEN I SSUES AND F UTURE W ORK
that simply re-instantiate the handle_navigation plan for
computing a new route able to bring the user to the desired             Besides the advantages described in previous section, the
destination from his current position (that was not considered       application of current agent programming technologies to the
in the previous route).                                              development of concrete software systems such as mobile
   Finally, the new_traffic_info plan (lines 25-32) is worth         applications have been useful to focus some main weaknesses
of particular attention. This is the reactive plan that manages      that these technologies currently have to this end. Here we
the reception of the updates related to the traffic conditions.      have identified three general issues that will be subject of
If the new information are considered relevant with respect          future work:
to the user preferences (sub-plan check_info_relevance                  (i) Devising of a notion of type for agents and artifacts
instantiated at line 28 and not shown) then, on the basis of         — current agent programming languages and technologies
this information, the current route (sub-plan update_route           lack of a notion of type as the one found in mainstream
instantiated at lines 29-30), the Web site subscription (sub-plan    programming languages and this makes the development of
update_subscription instantiated at line 31), and finally            large system hard and error-prone. This would make it possible
the map displayed on the GUI (line 32) are updated.                  to detect many errors at compile time, allowing for strongly
   So, this example shows how it is possible to integrate the        reducing the development time and enhancing the safety of



                                                                    53
the developed system. In JaCa we have a notion of type just                                       R EFERENCES
for artifacts: however it is based on the lower OO layer and         [1] A. Battestini, C. Del Rosso, A. Flanagan, and M. Miettinen. Creating
so not expressive enough to characterise at a proper level of            next generation applications and services for mobile devices: Challenges
abstraction the features of environment programming.                     and opportunities. In EEE 18th Int. Symposium on Personal, Indoor and
                                                                         Mobile Radio Communications (PIMRC), 2007, pages 1 –4, 3-7 2007.
   (ii) Improving modularity in agent definition — this is a         [2] F. L. Bellifemine, G. Caire, and D. Greenwood. Developing Multi-Agent
main issue already recognised in the literature [7], [8], [9],           Systems with JADE. Wiley, 2007.
where constructs such as capabilities have been proposed             [3] M. Berger, S. Rusitschka, D. Toropov, M. Watzke, and M. Schlichte.
                                                                         Porting distributed agent-middleware to small mobile devices. In
to this end. Jason still lacks of a construct to properly                AAMAS Workshop on Ubiquitous Agents on Embedded, Wearable and
modularise and structure the set of plans defining an agent’s            Mobile Devices.
behaviour —a recent proposal is described here [12].                 [4] R. Bordini, M. Dastani, J. Dix, and A. E. F. Seghrouchni, editors. Multi-
                                                                         Agent Programming: Languages, Platforms and Applications (vol. 1).
   (iii) Improving the integration with the OO layer — To                Springer, 2005.
represent data structures, Jason – as well as the majority of        [5] R. Bordini, J. Hübner, and M. Wooldridge. Programming Multi-Agent
agent programming languages – adopts Prolog terms, which                 Systems in AgentSpeak Using Jason. John Wiley & Sons, Ltd, 2007.
                                                                     [6] R. H. Bordini, M. Dastani, J. Dix, and A. El Fallah Seghrouchni, editors.
are very effective to support mechanisms such as unification,            Multi-Agent Programming: Languages, Platforms and Applications (vol.
but quite weak – from an abstraction and expressiveness                  2). Springer Berlin / Heidelberg, 2009.
point of view – to deal with complex data structures. Main           [7] L. Braubach, A. Pokahr, and W. Lamersdorf. Extending the capability
                                                                         concept for flexible BDI agent modularization. In Programming Multi-
agent frameworks (not languages) in Agent-Oriented Software              Agent Systems, volume 3862 of LNAI, pages 139–155. Springer, 2005.
Engineering contexts – such as Jade [2] or JACK11 – adopt            [8] M. Dastani, C. Mol, and B. Steunebrink. Modularity in agent program-
object-oriented data models, typically exploiting the one of             ming languages: An illustration in extended 2APL. In Proceedings of
                                                                         the 11th Pacific Rim Int. Conference on Multi-Agent Systems (PRIMA
existing OO languages (such as Java). By integrating Jason               2008), volume 5357 of LNCS, pages 139–152. Springer, 2008.
with CArtAgO, we introduced a first support to work with an          [9] K. Hindriks. Modules as policy-based intentions: Modular agent
object-oriented data model, in particular to access and create           programming in GOAL. In Programming Multi-Agent Systems, volume
                                                                         5357 of LNCS, pages 156–171. Springer, 2008.
objects that are exchanged as parameters in actions/percepts.       [10] F. Koch, J.-J. C. Meyer, F. Dignum, and I. Rahwan. Programming
However, it is just a first integration level and some important         deliberative agents for mobile services: The 3apl-m platform. In
aspects – such as the use of unification with object-oriented            PROMAS, pages 222–235, 2005.
                                                                    [11] B. König-Ries. Challenges in mobile application development. it -
data structures – are still not tackled.                                 Information Technology, 51(2):69–71, 2009.
   Finally, concerning the specific mobile application context,     [12] N. Madden and B. Logan. Modularity and compositionality in Jason.
                                                                         In Proceedings of Int. Workshop Programming Multi-Agent Systems
JaCa-Android is just a prototype and indeed needs further                (ProMAS 2009). 2009.
development for stressing more in depth the benefits provided       [13] C. Muldoon, G. M. P. O’Hare, R. W. Collier, and M. J. O’Grady. Agent
by agent-oriented programming compared to mainstream non-                factory micro edition: A framework for ambient applications. In Int.
                                                                         Conference on Computational Science (3), pages 727–734, 2006.
agent platforms. Therefore, in future works we aim at improv-       [14] A. Omicini, A. Ricci, and M. Viroli. Artifacts in the A&A meta-model
ing JaCa-Android in order to tackle some other important fea-            for multi-agent systems. Autonomous Agents and Multi-Agent Systems,
tures of modern mobile applications such as the smart use of             17 (3), Dec. 2008.
                                                                    [15] A. S. Rao. Agentspeak(l): Bdi agents speak out in a logical computable
the battery and the efficient management of the computational            language. In MAAMAW ’96: Proceedings of the 7th European workshop
workload of the device.                                                  on Modelling autonomous agents in a multi-agent world : agents
                                                                         breaking away, pages 42–55, Secaucus, NJ, USA, 1996. Springer-Verlag
                      VI. C ONCLUSION                                    New York, Inc.
                                                                    [16] A. Ricci, M. Piunti, L. D. Acay, R. Bordini, J. Hübner, and M. Das-
   To conclude, we believe that agent-oriented programming –             tani. Integrating artifact-based environments with heterogeneous agent-
                                                                         programming platforms. In Proceedings of 7th International Conference
including multi-agent programming – would provide a suitable             on Agents and Multi Agents Systems (AAMAS08), 2008.
level of abstraction for tackling the development of com-           [17] A. Ricci, M. Piunti, M. Viroli, and A. Omicini. Environment pro-
plex software applications, extending traditional programming            gramming in CArtAgO. In R. H. Bordini, M. Dastani, J. Dix, and
                                                                         A. El Fallah-Seghrouchni, editors, Multi-Agent Programming: Lan-
paradigms such as the Object-Oriented to deal with aspects               guages, Platforms and Applications, Vol. 2, pages 259–288. Springer,
such as concurrency, reactiveness, asynchronous interaction              2009.
managements, dynamism and so on. In this paper, in particular,      [18] A. Ricci, A. Santi, and M. Piunti. Action and perception in multi-agent
                                                                         programming languages: From exogenous to endogenous environments.
we showed the advantages of applying such an approach to                 In Proceedings of the Int. Workshop on Programming Multi-Agent
the development of smart mobile applications on the Google               Systems (ProMAS’10), Toronto, Canada, 2010.
Android platform, exploiting the JaCa integrated platform.          [19] A. Ricci, M. Viroli, and A. Omicini. The A&A programming model &
                                                                         technology for developing agent environments in MAS. In M. Das-
However, we argue that in order to stress and investigate                tani, A. El Fallah Seghrouchni, A. Ricci, and M. Winikoff, editors,
the full value of the agent-oriented approach to this end,               Programming Multi-Agent Systems, volume 4908 of LNAI, pages 91–
further work is need to extend current agent languages and               109. Springer Berlin / Heidelberg, 2007.
                                                                    [20] Y. Shoham. Agent-oriented programming. Artificial Intelligence,
technologies – or to devise new ones – tackling main aspects             60(1):51–92, 1993.
that have not been considered so far, being not related to AI
but to the principles of software development. This is the core
of our current and future work.
  11 http://www.agent-software.com




                                                                   54