=Paper= {{Paper |id=Vol-1213/paper2 |storemode=property |title=MAGPIE: an agent platform for the development of mobile applications for pervasive healthcare |pdfUrl=https://ceur-ws.org/Vol-1213/paper2.pdf |volume=Vol-1213 |dblpUrl=https://dblp.org/rec/conf/ecai/TorreBPS14 }} ==MAGPIE: an agent platform for the development of mobile applications for pervasive healthcare== https://ceur-ws.org/Vol-1213/paper2.pdf
          MAGPIE: An Agent Platform for the
         Development of Mobile Applications for
                 Pervasive Healthcare

           Albert Brugués1,2 , Stefano Bromuri1 , Josep Pegueroles2 , and
                                Michael Schumacher1
1
     University of Applied Sciences Western Switzerland (HES-SO), Sierre, Switzerland
                                 {name.surname}@hevs.ch
    2
      Universitat Politècnica de Catalunya - BarcelonaTech (UPC), Barcelona, Spain
                                josep.pegueroles@upc.edu




        Abstract. In this paper we present the Mobile computing with AGents
        and Publish subscribe for Intelligent pervasive hEalthcare (MAGPIE)
        platform. MAGPIE is an agent platform designed for the Android OS.
        The aim of the platform is to simplify the definition of Personal Health
        Systems (PHSs) to monitor chronic diseases. The agents running in the
        platform use a symbolic reasoning approach to formalize the events hap-
        pening to the patient. We show the formalization of this reasoning for
        the particular case of monitoring Gestational Diabetes Mellitus (GDM).



1     INTRODUCTION

The new advances in medicine are contributing to an increase of life expectancy,
which in turn increases the healthcare costs due to a major prevalence of age-
related chronic diseases. Pervasive Healthcare [1] is a scientific discipline that
tries to mitigate these issues by defining Personal Health Systems (PHSs). These
systems shift the paradigm of healthcare services, by moving them from a cen-
tralized approach focused on doctors to a decentralized one focused on patients;
that is a pro-active and preventive delivery model where people are active par-
ticipants in their own well-being.
    In the context of PHSs the use of mobile devices with sensors deployed on the
body gives the vision of healthcare to anyone, anytime and anywhere [5]. In the
recent years the market of smartphones and tablets has been well established.
Nowadays the smartphones hardware components offer powerful computation
capabilities that allow to perform the same tasks we do with a desktop com-
puter. Another factor that contributed to the establishment of this new scenario
for mobile computing is the apparition of operating systems specially designed
for handheld devices, like Android [2]. Android as it is offered as an open source
solution, can be used by different vendors in their products without adding
additional costs. Moreover, application developers can create and publish ap-
plications for this operating system and target a wide range of devices. In the

                                           6
particular case of PHSs there is a key fact in the new generation of mobile de-
vices that are the integrated sensors like accelerometers, GPS receiver, ambient
light, etc. that can provide information that complements the one provided by
the sensors deployed on the body.
    In this work we present the implementation directions of MAGPIE, an agent
platform for simplifying the development of mobile applications in Android with
the aim of monitoring chronic diseases. The platform is based on the concept
of agent environment as a first class abstraction [6], and it is designed with
the aim of tackle some of the technological challenges arising from the develop-
ment of PHSs like modeling the domain knowledge, their scalability and their
personalization.
    The agent environment concept, is becoming increasingly more important to
simplify the definition and deployment of multiagent applications, by mediating
the interaction between the agents and resources deployed in the system, by
hiding to the agents the complexity of dealing with the state of resources external
to the agent, and by providing standard interfaces and standard descriptions to
resources so that the agents can utilize them for their own goals.


2   THE MAGPIE AGENT PLATFORM

The aim of the MAGPIE agent platform is to help on the development of mobile
applications that can be used in a PHS for monitoring chronic diseases. In a PHS
patients with one or more chronic diseases are monitored by means of sensors
deployed on their body. In MAGPIE we link such sensors with the abstraction of
agent environment in multiagent systems [6]. The agents deployed in the agent
environment can perceive the events happening in the patient’s environment,
perform reasoning on these events and produce alerts of interest for the particular
disease being monitored.
    As shown in Figure 1 the MAGPIE agent platform consists on different com-
ponents. The central element of the platform is the environment where we can
deploy two main entities: agents and context entities. Agents are cognitive enti-
ties deployed on the agent environment and are composed by a declarative mind
called agent mind, which is the component in charge of the agent’s reasoning
abilities. The mind of an agent is situated in the environment through another
component called agent body. The agent body is the part of the agent that
receives and produces events from/to the agent environment, so it acts as an
interface between the agent mind and the agent environment.
    Context entities are connectors linking the real environment with the agent
environment. They encapsulate the communication with a source of information
from the real world. The goal of a context entity is to throw to the agent en-
vironment events related with physical measurements from the real world, so
that the agents can perceive them. There are different kinds of context entities
for the three different sources of the information we have. First, measurements
can come from Bluetooth sensors deployed on the body of the patient, which
can measure physiological values like the heart rate. Second, measurements can

                                        7
                          Fig. 1. MAGPIE class diagram



come from the sensors of the smartphone, which can provide for example the
GPS position of the patient. Last, measurements can be provided by the patient
itself through the user interface of a mobile application to report values that are
difficult to measure with sensors, like the amount of carbohydrates of a meal.
     The environment acts as a mediator for the interactions between the agents
and the context entities. The events produced by the context entities are iden-
tified by the kind of measurement they represent, and the agent environment
notifies the events to those agents interested on that particular measurement.
     The agents and the environment have a lifecycle that takes into consideration
the limited energy resources of smartphones. This limitation implies that in
Android it is not possible to consider a full multithreading approach for agents
as if multiple threads were to be run, then the battery life would decrease. The
environment lifecycle takes care of mainly two things after the initialization of the
Android application. Firstly, the environment dispatches events to the entities
deployed in it. Secondly, the environment works also as a scheduler for the agents.
For the sake of this contribution, the implementation of the environment entity
has a sequential scheduler to execute the existing agents. The agent lifecycle is
more complex. In a lifecycle an agent has to perceive the environment, to update
its internal state and then, if no modification of the model is necessary, to perform
actions in the environment, such as submitting alerts to the patient. When the
agent perceives an event of model modification, then the current agent mind is
discarded and modified with the new model, and the agent starts its cycle again
from perceiving the environment. Contrary to the environment and the agents,
the context entities are not active, so they are activated only when triggered by
an event, performing a purely reactive behavior.
    An important characteristic of the MAGPIE agent platform is its integra-
tion with the Android OS. We use two of the Android main components for that
purpose: activities and services. An activity represents a graphical interface that
the user can see on the screen, in MAGPIE activities are used as a communi-
cation channel between a mobile application and the patient. A service runs in
the background to perform long-running operations that do not interact with

                                         8
                        Initialization                Initialization




                         Notification                   Perceive




                                                                       New monitoring model
                                                        Is Model        loaded in the mind
                                                        Change?
                       Agent Execution


                                           Update

                                                                        Modify Model




                            Sleep           Act



                             (A)                           (B)




             Fig. 2. Lifecycles of the (a) environment, and the (b) agents


the user, in MAGPIE the environment, the agents and the context entities run
autonomously in a background service.


3    KNOWLEDGE REPRESENTATION
The knowledge used by the agents is based on the Event Calculus (EC) [4]. The
EC is a formalism defined in Prolog for representing actions and their effects,
so EC is suitable to model expert systems representing the evolution in time of
an entity, by means of the production of events. In this case, our EC reasoner is
embedded inside an agent, and models alerting rules applied by medical doctors
through a web interface. More specifically, the events produced in the agent
environment that are LogicTuples are automatically translated to a first order
logic representation that can be interpreted by the reasoner residing the agent
mind of MAGPIE agents.
    In this paper we are motivated by the use case of monitoring Gestational
Diabetes Mellitus (GDM); a condition affecting 3-4% of pregnant women due to
increased resistance to insulin caused by the growth of the baby. Such a condition
disappears just after delivery, but it is an indicator of the insurgence of diabetes
type 2 (DT2) later in life: about 40% of the women affected by GDM also develop
DT2 [3].
    We give an example on how we define rules to handle the detection of repeated
events such as hyperglycaemia events. The rule below is expressed in terms of
the domain independent predicate initiates at/2, which defines the conditions
holding in the context of GDM
initiates_at ( alert ( p o s t p r a n d i a l _ h y p e r g l y c a e m i a ) = active , T ) ←
    happens_at ( glucose ( V 1 ,P ) ,T ) ,
    last_week ( Time7days , T ) ,
    ( P = after_breakfast ;
    P = after_lunch ;
    P = after_dinner ) ,


                                                  9
     V 1 >=7 ,
     count (( happens_at ( glucose ( V 2 ,P ) ,T 2 ) ,
           T 2 > Time7days ,
           T 2 =7) ,C ) ,
     C >3.

    The predicate count/2 specifies the amount of times that the condition taken
in consideration holds. The rule states that an alert of hyperglycaemia after a
meal is triggered when in the last week more than three times the value of glucose
for postprandial periods was above 7 mmol/l.


4    CONCLUSIONS
In this paper we presented a prototype of MAGPIE, an agent platform to de-
velop mobile Android applications in the context of chronic illnesses monitoring.
MAGPIE allows the deployment of agents and context entities in an agent en-
vironment. Furthermore, MAGPIE allows to personalize for each patient the
behaviour of their agents by means of alerting rules. These rules are deployed in
the agent cognitive model in terms of an Event Calculus theory.
    As future work we plan: to develop a web interface for the doctors so that
they can define the monitoring rules for their patients remotely; study different
strategies to minimize the energy consumption of the mobile application using
MAGPIE; use a distributed event based system approach to notify the events
generated by the platform to doctors and relatives of the patient.


ACKNOWLEDGEMENTS
This research has been funded by the Hasler Foundation


References
1. Bardram, J.E.: Pervasive Healthcare as a Scientific Discipline. Methods of Informa-
   tion in Medicine 47(3), 178–185 (2008)
2. Butler, M.: Android: Changing the Mobile Landscape. Pervasive Computing, IEEE
   10(1), 4–7 (Jan 2011)
3. Kim, C., Newton, K.M., Knopp, R.H.: Gestational Diabetes and the Incidence of
   Type 2 Diabetes: A Systematic Review. Diabetes care 25(10), 1862–1868 (2002)
4. Kowalski, R., Sergot, M.: A Logic-based Calculus of Events. New Gen. Comput.
   4(1), 67–95 (Jan 1986)
5. Varshney, U.: Pervasive Healthcare and Wireless Health Monitoring. Mobile Net-
   works and Applications 12(2-3), 113–127 (2007)
6. Weyns, D., Omicini, A., Odell, J.: Environment as a First Class Abstraction in
   Multiagent Systems. Autonomous Agents and Multi-Agent Systems 14(1), 5–30 (Feb
   2007)




                                         10