=Paper=
{{Paper
|id=None
|storemode=property
|title=Exploiting Agent-Oriented Programming for Developing Android Applications
|pdfUrl=https://ceur-ws.org/Vol-621/paper07.pdf
|volume=Vol-621
|dblpUrl=https://dblp.org/rec/conf/woa/SantiGR10
}}
==Exploiting Agent-Oriented Programming for Developing Android Applications==
Exploiting Agent-Oriented Programming for
Developing Android 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 So, in this paper we discuss the application of an agent-
effective level of abstraction for tackling the programming oriented programming platform called JaCa to the develop-
of mainstream software applications, in particular those that ment of smart nomadic applications. Actually JaCa is not
involve complexities related to concurrency, asynchronous events
management and context-sensitive behaviour. In this paper we a new platform, but the integration of two existing agent
support this claim in practice by discussing the application of programming technologies: Jason [5] agent programming
AOP technologies – Jason and CArtAgO in particular – for the language and platform, and CArtAgO [17] framework, for
development of smart nomadic applications based on the Google programming and running the environments where agents
Android platform. work. JaCa is meant to be a general-purpose programming
platform, so useful for developing software applications in
I. I NTRODUCTION
general. In order to apply JaCa to nomadic computing, we
The value of Agent-Oriented Programming (AOP) [20] is developed a porting of the platform on top of Google Android,
often remarked and evaluated in the context of Artificial which we refer as JaCa-Android. Google Android is an open-
Intelligence (AI) and Distributed AI problems. This is evi- source software stack for mobile devices provided by Google
dent, for instance, by considering existing agent programming that includes an operating system (Linux-based), middleware,
languages (see [4], [6] for comprehensive surveys) – whose SDK and key applications.
features are typically demonstrated by considering toy prob- Other works in literature discuss the use of agent-based
lems such as 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 agent-oriented programming level of abstrac-
actions, concurrency, up to those involving different degrees tion for the development of complex nomadic applications.
of autonomy and intelligence. Following this view, one of The remainder of the paper is organised as follows: in
our current research lines investigates the adoption and the Section II we provide a brief overview of the JaCa platform
evaluation of existing agent-based programming languages and – which we consider part of the background of this paper;
technologies for the development of applications in some of then, in Section III we introduce and discuss the application
the most modern and relevant application domains. In this of JaCa for the development of smart nomadic applications
context, a relevant one is represented by next generation on top of Android, and in Section IV we describe two practical
nomadic applications. Applications of this kind are getting a application samples useful to evaluate the approach. Finally,
strong momentum given the diffusion of mobile devices which in Section V we briefly discuss some open issues related to
are more and more powerful, in terms of computing power, JaCa and, more generally, to the use of current agent-oriented
memory, connectivity, sensors and so on. Main examples are programming technologies for developing applications and
smart-phones such as the iPhone and Android-based devices. related future works.
On the one side, nomadic applications share more and more
features with desktop applications, and eventually extending II. AGENT-O RIENTED P ROGRAMMING FOR M AINSTREAM
such features with capabilities related to context-awareness, A PPLICATION D EVELOPMENT – T HE J AC A A PPROACH
reactivity, usability, and so on, all aspects that are important An application in JaCa is designed and programmed as
in the context for Internet of Things and Ubiquitous Com- a set of agents which work and cooperate inside a com-
puting scenarios. All this increases – on the other side – mon environment. Programming the application means then
the complexity required for their design and programming, programming the agents on the one side, encapsulating the
introducing aspects that – we argue – are not suitably tackled logic of control of the tasks that must be executed, and
by mainstream programming languages such as the object- the environment on the other side, as first-class abstraction
oriented ones. providing the actions and functionalities exploited by the
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 at
environments. runtime. Actually an agent can explicitly select which artifacts
Being a concrete implementation of an extended version to observe, by means of a specific action called focus. By ob-
of AgentSpeak(L) [15], Jason adopts a BDI (Belief-Desire- serving an artifact, artifacts’ observable properties are directly
Intention)-based computational model and architecture to de- mapped into beliefs in the belief-base, updated automatically
fine the structure and behaviour of individual agents. In that, each time the observable properties change their value. So a
agents are implemented as reactive planning systems: they run Jason agent can specify plans reacting to changes to beliefs
continuously, reacting to events (e.g., perceived changes in the that concern observable properties or can select plan according
environment) by executing plans given by the programmer. to the value of beliefs which refer to observable properties.
Plans are courses of actions that agents commit to execute Artifacts’ signals instead are not mapped into the belief base,
so as to achieve their goals. The pro-active behaviour of but processed as non persistent percepts possibly triggering
agents is possible through the notion of goals (desired states plans—like in the case of message receipt events. Finally, the
of the world) that are also part of the language in which plans Jason data-model – essentially based on Prolog terms – is
are written. Besides interacting with the environment, Jason extended to manage also (Java) objects, so as to work with data
agents can communicate by means of speech acts. exchanged by performing actions and processing percepts.
On the environment side, CArtAgO – following the A&A A full description of Jason language/platform and
meta-model [14], [19] – adopts the notion of artifact as first- CArtAgO framework – and their integration – is out of the
class abstraction to define the structure and behaviour of scope of this paper: the interested reader can find details in
environments and the notion of workspace as a logical con- literature [17], [16] and on Jason and CArtAgO open-source
tainer of agents and artifacts. Artifacts explicitly represent the web sites12 .
environment resources and tools that agents may dynamically
instantiate, share and use, encapsulating functionalities de- III. P ROGRAMMING A NDROID A PPLICATIONS WITH J AC A
signed by the environment programmer. In order to be used by In this section we describe how JaCa’s features can be
the agents, each artifact provides a usage interface composed effectively exploited to program smart nomadic applications
by a set of operations and observable properties. Operations on top of Android, providing benefits over existing non-agent
correspond to the actions that the artifact makes it available approaches. First, we briefly sketch some of the complexities
to agents to interact with such a piece of the environment; related to the design and programming of such a kind of
observable properties define the observable state of the artifact, applications; then, we describe how these are addressed in
which is represented by a set of information items whose value JaCa-Android—which is the porting of JaCa on Android,
(and value change) can be perceived by agents as percepts. extended with a predefined set of artifacts specifically designed
Besides observable properties, the execution of operations for exploiting Android functionalities.
can generate signals perceivable by agents as percepts, too.
As a principle of composability, artifacts can be assembled A. Programming Nomadic Applications: Complexities
together by a link mechanism, which allows for an artifact to Mobile systems and nomadic applications have gained a lot
execute operations over another artifact. CArtAgO provides a of importance and magnitude both in research and industry
Java-based API to program the types of artifacts that can be over the last years. This is mainly due to the introduction
instantiated and used by agents at runtime, and then an object- of mobile devices such as the iPhone3 and the most modern
oriented data-model for defining the data structures used in Android4 -based devices that changed radically the concept of
actions, observable properties and events. smartphone thanks to: (i) hardware specifications that allow
The notion of workspace is used to define the topology to compare these devices to miniaturised computers, situated
of complex environments, that can be organised as multiple – thanks to the use of practically every kind of known
sub-environments, possibly distributed over the network. By connectivity (GPS, WiFi, bluetooth, etc.) – in a computational
default, each workspace contains a predefined set of artifact network which is becoming more and more similar to the
created at boot time, providing basic actions to manage the vision presented by both the Internet of Things and ubiquitous
overall set of artifacts (for instance, to create, lookup, link to- computing, and (ii) the evolution of both the smartphone O.S.
gether artifacts), to join multiple workspaces, to print message (Apple iOS, Android, Meego5 ) and their related SDK.
on the console, and so on.
1 http://jason.sourceforge.net
JaCa integrates Jason and CArtAgO so as to make the 2 http://cartago.sourceforge.net
use of artifact-based environments by Jason agents seamless. 3 http://www.apple.com/it/iphone/
To this purpose, first, the overall set of external actions that a 4 http://www.android.com/
Jason agent can perform is determined by the overall set of 5 http://meego.com
These innovations produce a twofold effect: on the one structure applications; however – being the framework fully
side, they open new perspectives, opportunities and application based on an object-oriented virtual machine and language such
scenarios for these new mobile devices; on the other side, as Java – they do not shield programmers from using callbacks,
they introduce new challenges related to the development threads, and low-level synchronisation mechanisms as soon as
of the nomadic applications, that are continuously increasing applications with complex reactive behaviour are considered.
their complexity [1], [11]. These applications – due to the For instance, in classic Android applications asynchronous
introduction of new usage scenarios – must be able to address interactions with external resources are still managed using
issues such as concurrency, asynchronous interactions with dif- polling loops or some sort of mailbox; context-dependent
ferent kinds of services (Web sites/Services, social-networks, behaviour must be realised staining the source code with
messaging/mail clients, etc.) and must also expose a user- a multitude of if statements; concurrency issues must be
centric behaviour governed by specific context information addressed using Java low-level synchronisation mechanisms.
(geographical position of the device, presence/absence of So, more generally, we run into the problems that typically
different kinds of connectivity, events notification such as the arise in mainstream programming languages when integrating
reception of an e-mail, etc.). one or multiple threads of control with the management of
To cope with these new requirements, Google has developed asynchronous events, typically done by callbacks.
the Android SDK6 , which is an object-oriented Java-based In next section we discuss how agent-oriented programming
framework meant to provide a set of useful abstractions for and, in particular, the JaCa programming model, are effective
engineering nomadic applications on top of Android-enable to tackle these issues at a higher-level of abstraction, making
mobile devices. Among the main coarse-grain components it possible to create more clear, terse and extensible programs.
introduced by the framework to ease the application devel- B. An Agent-oriented Approach based on JaCa
opment we mention here:
By adopting the JaCa programming model, a mobile An-
• Activities: an activity provides a GUI for one focused
droid application can be realised as a workspace in which
endeavor the user can undertake. For example, an activity Jason agents are used to encapsulate the logic and the control
might present a list of menu items users can choose, list of tasks involved by the mobile application, and artifacts are
of contacts to send messages to, etc. used as tools for agents to seamlessly exploit available Android
• Services: a service does not have a GUI and runs in the
device/platform components and services.
background for an indefinite period of time. For example, From a conceptual viewpoint, this approach makes it pos-
a service might play background music as the user attends sible to keep the same level of abstraction – based on agent-
to other matters. oriented concepts – both when designing the application and
• Broadcast Receiver: a broadcast receiver is a component
when concretely implementing it using Jason and CArtAgO.
that does nothing but receive and react to broadcast In this way we are able to provide developers a uniform
announcements. Many broadcasts originate in system guideline – without conceptual gaps between the abstractions
code - for example, announcements that the timezone has used in the analysis and implementation phases – that drives
changed, that the battery is low, etc. the whole engineering process of a mobile application.
• Content providers: a content provider makes a specific set
From a programming point of view, the agent paradigm
of the application’s data available to other applications. makes it possible to tackle quite straightforwardly some of
The data can be stored in the file system, in an SQLite the main challenges mentioned in previous sections, in partic-
database, etc. ular: (i) task and activity oriented behaviours can be directly
In Android, interactions among components are managed mapped onto agents, possibly choosing different kinds of
using a messaging facility based on the concepts of Intent concurrent architectures according to the need—either using
and IntentFilter. An application can request the execution of multiple agents to concurrently execute tasks, or using a single
a particular operation – that could be offered by another agent to manage the interleaved execution of multiple tasks;
application or component – simply providing to the O.S. an (ii) agents’ capability of adapting the behaviour on the basis of
Intent properly characterised with the information related to the current context information can be effectively exploited to
that operation. So, for example, if an application needs to realise context-sensitive and context-dependent applications;
display a particular Web page, it expresses this need creating (iii) asynchronous interactions can be managed by properly
a proper Intent instance, and then sending this instance to the specifying the agents’ reactive behaviour in relation to the
Android operating system. The O.S. will handle this request reception of particular percepts (e.g. the reception of a new
locating a proper component – e.g. a browser – able to manage e-mail).
that particular Intent. The set of Intents manageable by a To see this in practice, we developed a porting of JaCa
component are defined by specifying, for that component, a on top of Android – referred as JaCa-Android – available as
proper set of IntentFilters. open-source project7 . Fig. 1 shows an abstract representation
Generally speaking, these components and the Intent-based of the levels characterising the JaCa-Android platform and
interaction model are useful – indeed – to organise and of a generic applications running on top of it.
6 http://developer.android.com/sdk/index.html 7 http://jaca-android.sourceforge.net
JaCa-Android app JaCa-services
shared workspace workspace can be shared among different applications—
ActivityGUI SMSManager
MyArtifact promoting, then, the modularisation and the reuse of the
functionalities provided by JaCa-Android applications.
Calendar In the next section we discuss more in detail the benefits
GPSArtifact
of the JaCa programming model for implementing smart
nomadic applications by considering two samples that have
been developed on top of JaCa-Android. These applications
JaCa
JaCa Android artifacts are quite simple and their aim is to show how it is possible
(Jason+CArtAgO) to address some – e.g concurrency issues are not addressed –
Android Framework of the relevant aspects of smart nomadic applications devel-
(Dalvik Virtual Machine + Libraries)
opment with JaCa-Android.
Linux kernel
IV. E VALUATION THROUGH P RACTICAL E XAMPLES
The first example aims at showing how the approach allows
Fig. 1. Abstract representation of the JaCa-Android platform – with in for easily realising context-sensitive nomadic applications.
evidence the different agent technologies on which the platform is based – For this purpose, we consider a JaCa-Android application
and of generic applications running on top of it.
inspired to Locale8 , one of the most famous Android ap-
plications and also one of the winners of the first Android
The platform includes a set of predefined types of artifacts Developer Contest9 . This application (JaCa-Locale) can be
(BroadcastReceiverArtifact, ActivityArtifact,
considered as a sort of intelligent smartphone manager re-
ContentProviderArtifact, ServiceArtifact)
alised using a simple Jason agent. The agent during its
specifically designed to build compliant Android components. execution use some of the built-in JaCa-Android artifacts
So, standard Android components become fully-fledged described in Section III and two application-specific artifacts:
artifacts that agents and agent developers can exploit without a PhoneSettingsManager artifact used for managing the
worrying and knowing about infrastructural issues related to device ringtone/vibration and the ContactManager used for
the Android SDK. This makes it possible for developers to managing the list of contacts stored into the smartphone (this
conceive and realise nomadic applications that are seamlessly list is an observable property of the artifact, so directly mapped
integrated with the Android SDK, possibly interacting/re- into agents beliefs). The agent manages the smartphone be-
using every component and application developed using the haviour discriminating the execution of its plans on the basis
standard SDK. This integration is fundamental in order to ofa comparison among its actual context information and a
guarantee to developers the re-use of existing legacy – i.e. set of user preferences that are specified into the agent’s plans
the standard Android components and applications – and for contexts. TABLE I reports a snipped of the Jason agent used
avoiding the development of the entire set of functionalities in JaCa-Locale, in particular the plans shown in TABLE I are
required by an application from scratch. the ones responsible of the context-dependent management of
Besides, the platform also provides a set of artifacts that the incoming phone calls.
encapsulate some of the most common functionalities used The behaviour of the agent, once completed the initialisation
in the context of smart nomadic applications. In detail these phase (lines 00-07), is governed by a set of reactive plans.
artifacts are: The first two plans (lines 9-15) are used for regulating the
ringtone level and the vibration for the incoming calls on the
• SMSManager/MailManager, managing sms/mail-
basis ofthe notifications provided by the CalandarArtifact
related functionalities (send and receive sms/mail,
about the start or the end of an event stored into the user
retrieve stored sms/mail, etc.).
calendar. Instead, the behaviour related to the handling of
• GPSManager, managing gps-related functionalities (e.g.
the incoming calls is managed by the two reactive plans
geolocalisation of the device).
incoming_call (lines 17-28). The first one (lines 17-19)
• CallManager, providing functionalities for handling –
is applicable when a new incoming call arrives and the
answer/reject – phone calls.
phone owner is not busy, or when the incoming call is
• ConnectivityManager, managing the access to the
considered critical. In this case the agent normally handles
different kinds of connectivity supported by the mobile
the incoming call – the ringtone/vibration settings have al-
device.
ready been regulated by the plans at lines 9-15 – using
• CalendarArtifact, providing functionalities for man-
the handle_call operation provided by the CallManager
aging the built-in Google calendar.
artifact. The second plan instead (lines 21-28) is applicable
These artifacts, being general purpose, are situated in a when the user is busy and the call does not come from a
workspace called jaca-services (see Fig. 1) which is shared relevant contact. In this case the phone call is automatically
by all the JaCa-Android applications—being stored and
executed into a proper Android service installed with the 8 http://www.twofortyfouram.com/
JaCa-Android platform. More generally, any JaCa-Android 9 http://code.google.com/intl/it-IT/android/adc/
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 J ASON AGENT
rejected using the drop_call operation of the CallManager
artifact (line 24), and an auto-reply message containing the
motivation of the user unavailability is send back to the Fig. 2. Screenshot of the SmartNavigator application that integrate in its
contact that performed the call. This notification is sent – GUI some of the Google Maps components for showing: (i) the user current
using one of the handle_auto_reply plans (lines 30-34) position, (ii) the road directions, and (iii) the route to the designed destination.
– via sms or via mail (using respectively the SMSManager
(embedded into artifact) 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 its 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.
smartphone 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, etc.),
context conditions hold. (iii) the SmartNavigatorGUI, an artifact developed on the
The example is useful also for highlighting the benefits basis ofthe ActivityArtifact and some other Google Maps
introduced by artifact-based endogenous environments: (i) it components, used for realizing the GUI of the application
makes it possible to represent and exploit platform/device and (iv) an artifact, TrafficConditionsNotifier, used for
functionalities at an agent level of abstractions – so in terms managing the interactions with a Web site10 that provides real-
of actions and perceptions, modularised into artifacts; (ii) it time traffic information.
provides a strong separation of concerns, in that developers TABLE II shows a snippet of the agent source code.
can fully separate the code that defines the control logic of
the application (into agents) from the reusable functionalities 10 http://www.stradeanas.it/traffico/
00 preferences([...]).
The agent main goal assist_user_trips is managed by 01 relevance_range(10).
02
a set of reactive plans that are structured in a hierarchy 03 !assist_user_trips.
of sub-goals – handled by a set of proper sub-plans. The 04
05 +!assist_user_trips
agent has a set of initial beliefs (lines 00-01) and an initial 06 <- focus("GPSManager");
plan (lines 5-9) that manages the initialisation of the arti- 07 focus("GoogleMapsArtifact");
08 focus("SmartNavigatorGUI");
facts that will be used by the agent during its execution. 09 focus("TrafficConditionsNotifier").
The first plan, reported at lines 11-12, is executed after 10
11 +route(StartLocation, EndLocation)
the reception of an event related to the modification of 12 <- !handle_navigation(StartLocation, EndLocation).
the SmartNavigatorGUI route observable property – a 13
14 +!handle_navigation(StartLocation, EndLocation)
property that contains both the starting and arriving locations 15 <- ?relevance_range(Range); ?current_position(Pos);
provided in input by the user. The handling of this event is 16 -+leaving(StartLocation);-+arriving(EndLocation);
17 calculate_route(StartLocation,
managed by the handle_navigation plan that: (i) retrieve 18 EndLocation, OutputRoute);
(line 15) and updates the appropriate agent beliefs (line 16 19 -+route(OutputRoute);
20 subscribe_for_traffic_condition(OutputRoute,
and 19), (ii) computes the route using an operation provided 21 Range);
by the GoogleMapsArtifact (calculate_route lines 17- 22 set_current_position(Pos);
23 update_map.
18), (iii) makes the subscription – for the route of interest 24
– to the Web site that provides the traffic information using 25 +new_traffic_info(TrafficInfo)
26 <- ?preferences(Preferences);
the TrafficConditionsNotifier (lines 20-21), and finally 27 ?leaving(StartLocation); ?arriving(EndLocation);
(iv) updates the map showed by the application (using the 28 !check_info_relevance(TraffincInfo,Preferences);
29 !update_route(StartLocation, EndLocation,
SmartNavigatorGUI operations set_current_position 30 TrafficInfo, NewRoute);
and update_map, lines 22-23) with both the current position 31 !update_subscription(NewRoute);
32 update_map.
of the mobile device (provided by the observable property 33
current_position of the GPSManager) and the new route. 34 +current_position(Pos)
35 <- ?route(Route);
In the case that no meaningful changes occur in the traf- 36 !check_position_consistency(Pos, Route);
fic conditions and the user strictly follows the indications 37 set_current_position(Pos);
38 update_map.
provided by the SmartNavigator, the map displayed in 39
the application GUI will be updated, until arriving to the 40 -!check_position_consistency(Pos, Route)
41 : arriving(EndLocation)
designed destination, simply moving the current position of 42 <- !handle_navigation(Pos, EndLocation).
the mobile device using the plan reported at lines 34-38. TABLE II
This plan, activated by a change of the observable property S OURCE CODE SNIPPET OF THE S MART N AVIGATOR J ASON AGENT
current_position, simply considers (using the sub-plan
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 ofthe 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 nomadic
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 — current agent programming languages and technologies
ofthis 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
reactive behaviour of a JaCa-Android application – in this the developed system. In JaCa we have a notion of type just
example the asynchronous reception of information from a for artifacts: however it is based on the lower OO layer and
so not expressive enough to characterise at a proper level of and opportunities. In EEE 18th Int. Symposium on Personal, Indoor and
abstraction the features of environment programming. Mobile Radio Communications (PIMRC), 2007, pages 1 –4, 3-7 2007.
[2] F. L. Bellifemine, G. Caire, and D. Greenwood. Developing Multi-Agent
(ii) Improving modularity in agent definition — this is a Systems with JADE. Wiley, 2007.
main issue already recognised in the literature [7], [8], [9], [3] M. Berger, S. Rusitschka, D. Toropov, M. Watzke, and M. Schlichte.
where constructs such as capabilities have been proposed Porting distributed agent-middleware to small mobile devices. In
AAMAS Workshop on Ubiquitous Agents on Embedded, Wearable and
to this end. Jason still lacks of a construct to properly Mobile Devices.
modularise and structure the set of plans defining an agent’s [4] R. Bordini, M. Dastani, J. Dix, and A. E. F. Seghrouchni, editors. Multi-
behaviour —a recent proposal is described here [12]. Agent Programming: Languages, Platforms and Applications (vol. 1).
Springer, 2005.
(iii) Improving the integration with the OO layer — To [5] R. Bordini, J. Hübner, and M. Wooldridge. Programming Multi-Agent
represent data structures, Jason – as well as the majority of Systems in AgentSpeak Using Jason. John Wiley & Sons, Ltd, 2007.
agent programming languages – adopts Prolog terms, which [6] R. H. Bordini, M. Dastani, J. Dix, and A. El Fallah Seghrouchni, editors.
Multi-Agent Programming: Languages, Platforms and Applications (vol.
are very effective to support mechanisms such as unification, 2). Springer Berlin / Heidelberg, 2009.
but quite weak – from an abstraction and expressiveness [7] L. Braubach, A. Pokahr, and W. Lamersdorf. Extending the capability
point of view – to deal with complex data structures. Main concept for flexible BDI agent modularization. In Programming Multi-
Agent Systems, volume 3862 of LNAI, pages 139–155. Springer, 2005.
agent frameworks (not languages) in Agent-Oriented Software [8] M. Dastani, C. Mol, and B. Steunebrink. Modularity in agent program-
Engineering contexts – such as Jade [2] or JACK11 – adopt ming languages: An illustration in extended 2APL. In Proceedings of
object-oriented data models, typically exploiting the one of the 11th Pacific Rim Int. Conference on Multi-Agent Systems (PRIMA
2008), volume 5357 of LNCS, pages 139–152. Springer, 2008.
existing OO languages (such as Java). By integrating Jason [9] K. Hindriks. Modules as policy-based intentions: Modular agent
with CArtAgO, we introduced a first support to work with an programming in GOAL. In Programming Multi-Agent Systems, volume
object-oriented data model, in particular to access and create 5357 of LNCS, pages 156–171. Springer, 2008.
[10] F. Koch, J.-J. C. Meyer, F. Dignum, and I. Rahwan. Programming
objects that are exchanged as parameters in actions/percepts. deliberative agents for mobile services: The 3apl-m platform. In
However, it is just a first integration level and some important PROMAS, pages 222–235, 2005.
aspects – such as the use of unification with object-oriented [11] B. König-Ries. Challenges in mobile application development. it -
Information Technology, 51(2):69–71, 2009.
data structures – are still not tackled. [12] N. Madden and B. Logan. Modularity and compositionality in Jason.
Finally, concerning the specific mobile application context, In Proceedings of Int. Workshop Programming Multi-Agent Systems
JaCa-Android is just a prototype and indeed needs further (ProMAS 2009). 2009.
[13] C. Muldoon, G. M. P. O’Hare, R. W. Collier, and M. J. O’Grady. Agent
development for stressing more in depth the benefits provided factory micro edition: A framework for ambient applications. In Int.
by agent-oriented programming compared to mainstream non- 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
for multi-agent systems. Autonomous Agents and Multi-Agent Systems,
ing JaCa-Android in order to tackle some other important fea- 17 (3), Dec. 2008.
tures of modern nomadic applications such as the smart use of [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
on Modelling autonomous agents in a multi-agent world : agents
workload of the device. breaking away, pages 42–55, Secaucus, NJ, USA, 1996. Springer-Verlag
New York, Inc.
VI. C ONCLUSION [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
would provide a suitable level of abstraction for tackling the on Agents and Multi Agents Systems (AAMAS08), 2008.
development of complex software applications, extending tra- [17] A. Ricci, M. Piunti, M. Viroli, and A. Omicini. Environment pro-
ditional programming paradigms such as the Object-Oriented gramming in CArtAgO. In R. H. Bordini, M. Dastani, J. Dix, and
A. El Fallah-Seghrouchni, editors, Multi-Agent Programming: Lan-
to deal with aspects such as concurrency, reactiveness, asyn- guages, Platforms and Applications, Vol. 2, pages 259–288. Springer,
chronous interaction managements, dynamism and so on. In 2009.
this paper, in particular, we showed the advantages of applying [18] A. Ricci, A. Santi, and M. Piunti. Action and perception in multi-agent
programming languages: From exogenous to endogenous environments.
such an approach to the development of smart nomadic appli- In Proceedings of the Int. Workshop on Programming Multi-Agent
cations on the Google Android platform, exploiting the JaCa Systems (ProMAS’10), Toronto, Canada, 2010.
integrated platform. However, we argue that in order to stress [19] A. Ricci, M. Viroli, and A. Omicini. The A&A programming model &
technology for developing agent environments in MAS. In M. Das-
and investigate the full value of the agent-oriented approach to tani, A. El Fallah Seghrouchni, A. Ricci, and M. Winikoff, editors,
this end, further work is need to extend current agent languages Programming Multi-Agent Systems, volume 4908 of LNAI, pages 91–
and technologies – or to devise new ones – tackling main 109. Springer Berlin / Heidelberg, 2007.
[20] Y. Shoham. Agent-oriented programming. Artificial Intelligence,
aspects that have not been considered so far, being not related 60(1):51–92, 1993.
to AI but to the principles of software development. This is
the core of our current and future work.
R EFERENCES
[1] A. Battestini, C. Del Rosso, A. Flanagan, and M. Miettinen. Creating
next generation applications and services for mobile devices: Challenges
11 http://www.agent-software.com