[IEEE 2011 IEEE/IPSJ 11th International Symposium on Applications and the Internet (SAINT) - Munich,...

4
A Framework for Context-aware Applications for Smart Spaces Natalia D´ ıaz Rodr´ ıguez Turku Centre for Computer Science ˚ Abo Akademi University Turku, Finland ndiaz@abo.fi Abstract—This paper presents an approach for developing context-aware intelligent applications for Smart Space-based infrastructure. The goal is to model and process context in- formation using our development tool and Nokia’s Smart-M3 architecture. We propose an adaptable and scalable context ontology, an ambient computing framework based on Smart Spaces and a rule based reasoning to infer higher level context. Our approach deals with several key issues in context aware ubiquitous computing such as adaptive and proactive changes in the environment, incorporation of novel sources of context infor- mation and automatic code generation from Context Ontologies to provide seamless interoperability. Keywords-Context-Aware; Smart Space; Ubiquitous Comput- ing; Application Development. I. I NTRODUCTION Context consists of any information that can be used to characterize the situation or state of an entity [7]. Entities can include anything: a person, an object, an application or device that is used to interact with the user. For example, physical context of a person can include his location, time etc.; his social context can include his social relations (family, friends...); his activity context can include is daily tasks (watching TV, listening to music, talking on phone...). In pervasive and context-aware computing, a user should be able to readily accomplish actions which can possibly include co- operation and collaboration with others using multiple devices and networks as he moves in the environment. In this way, the whole universe of intelligent applications automatically adapts to the user’s intention. For instance, your smart phone could notice that your favorite program starts in 5 min. based on your profile information or Facebook fan page and the broadcaster’s TV guide online. Then it could use GPS to find that you are not at home and start the Personal Video Recorder (PVR). This kind of intelligent applications need context information from different sources to adapt to the user’s preferences without involving human interactions and ensuring data interoperability. One way to enable the mentioned cross-domain scenario and solve the interoperability issue is through the notion of Smart Space. A Smart Space is an abstraction of space that encap- sulates both information in a physical space and the access to this information allowing devices to join and leave the space. In this way a Smart Space becomes a dynamic environment where a set of entities interact with it to share information. For example, communication between the mobile phone and the PVR in the above scenario does not happen point-to-point but through the common Smart Space where the phone and PVR are connected to. We have developed a programming interoperability solution for rapid application development in Smart Spaces that can be extended to support context-aware intelligent applications [10]. It is based on Nokia open source Smart-M3 architecture [4], an ideal choice for developing pervasive applications as it includes: 1) A blackboard software architecture which is cross-domain, cross-platform and enables knowledge share and reuse. 2) Ontology governance process (information stored in RDF) ensuring seamless information interoperability. II. SMART-M3 ARCHITECTURE The Smart-M3 (Multi part, Multi device and Multi vendor) architecture [11][4] provides a particular implementation of Smart Space where the central repository of information is the Semantic Information Broker (SIB). The information is accessed and processed by entities called Knowledge Pro- cessors (KPs). KPs interact with the M3 space by inserting, retrieving, updating or querying information in form of RDF Triples (Subject, Predicate, Object) using the Smart Space Access Protocol (SSAP). III. APPLICATION DEVELOPMENT FOR SMART-M3 We use an ontology-driven development approach for Smart-M3 for mapping ontologies to Object Oriented Programming[3][10]. Our system consists of two parts. The first part is the generator of a static Python API from an OWL ontology. This mapping generates classes, methods and declarations which can be used by the KP developer to access data in the SIB as structured and specified in the OWL ontol- ogy. The second part is the middleware layer which abstracts the communication with the SIB. Its aim is the handling of RDF Triples with the generated API by committing changes to the Smart Space. It provides functionality for synchronous and asynchronous queries enabling application developers to program new KPs without worrying about the SIB interface as the generated API takes care of the connection to the SIB each time an object is created. Several KPs may run on different devices and be grouped together to interact and be perceived as a single application. This coordination between KPs is done through data exchange with the SIB where KPs subscribe to. 2011 IEEE/IPSJ International Symposium on Applications and the Internet 978-0-7695-4423-6/11 $26.00 © 2011 IEEE DOI 10.1109/SAINT.2011.39 218 2011 IEEE/IPSJ International Symposium on Applications and the Internet 978-0-7695-4423-6/11 $26.00 © 2011 IEEE DOI 10.1109/SAINT.2011.39 218

Transcript of [IEEE 2011 IEEE/IPSJ 11th International Symposium on Applications and the Internet (SAINT) - Munich,...

Page 1: [IEEE 2011 IEEE/IPSJ 11th International Symposium on Applications and the Internet (SAINT) - Munich, Germany (2011.07.18-2011.07.21)] 2011 IEEE/IPSJ International Symposium on Applications

A Framework for Context-aware Applications forSmart Spaces

Natalia Dıaz Rodrıguez Turku Centre for Computer ScienceAbo Akademi University

Turku, [email protected]

Abstract—This paper presents an approach for developingcontext-aware intelligent applications for Smart Space-basedinfrastructure. The goal is to model and process context in-formation using our development tool and Nokia’s Smart-M3architecture. We propose an adaptable and scalable contextontology, an ambient computing framework based on SmartSpaces and a rule based reasoning to infer higher level context.Our approach deals with several key issues in context awareubiquitous computing such as adaptive and proactive changes inthe environment, incorporation of novel sources of context infor-mation and automatic code generation from Context Ontologiesto provide seamless interoperability.

Keywords-Context-Aware; Smart Space; Ubiquitous Comput-ing; Application Development.

I. INTRODUCTION

Context consists of any information that can be used tocharacterize the situation or state of an entity [7]. Entitiescan include anything: a person, an object, an application ordevice that is used to interact with the user. For example,physical context of a person can include his location, timeetc.; his social context can include his social relations (family,friends...); his activity context can include is daily tasks(watching TV, listening to music, talking on phone...). Inpervasive and context-aware computing, a user should be ableto readily accomplish actions which can possibly include co-operation and collaboration with others using multiple devicesand networks as he moves in the environment. In this way,the whole universe of intelligent applications automaticallyadapts to the user’s intention. For instance, your smart phonecould notice that your favorite program starts in 5 min. basedon your profile information or Facebook fan page and thebroadcaster’s TV guide online. Then it could use GPS tofind that you are not at home and start the Personal VideoRecorder (PVR). This kind of intelligent applications needcontext information from different sources to adapt to theuser’s preferences without involving human interactions andensuring data interoperability.

One way to enable the mentioned cross-domain scenario andsolve the interoperability issue is through the notion of SmartSpace. A Smart Space is an abstraction of space that encap-sulates both information in a physical space and the access tothis information allowing devices to join and leave the space.In this way a Smart Space becomes a dynamic environmentwhere a set of entities interact with it to share information.For example, communication between the mobile phone and

the PVR in the above scenario does not happen point-to-pointbut through the common Smart Space where the phone andPVR are connected to. We have developed a programminginteroperability solution for rapid application development inSmart Spaces that can be extended to support context-awareintelligent applications [10]. It is based on Nokia open sourceSmart-M3 architecture [4], an ideal choice for developingpervasive applications as it includes: 1) A blackboard softwarearchitecture which is cross-domain, cross-platform and enablesknowledge share and reuse. 2) Ontology governance process(information stored in RDF) ensuring seamless informationinteroperability.

II. SMART-M3 ARCHITECTURE

The Smart-M3 (Multi part, Multi device and Multi vendor)architecture [11][4] provides a particular implementation ofSmart Space where the central repository of information isthe Semantic Information Broker (SIB). The information isaccessed and processed by entities called Knowledge Pro-cessors (KPs). KPs interact with the M3 space by inserting,retrieving, updating or querying information in form of RDFTriples (Subject, Predicate, Object) using the Smart SpaceAccess Protocol (SSAP).

III. APPLICATION DEVELOPMENT FOR SMART-M3

We use an ontology-driven development approach forSmart-M3 for mapping ontologies to Object OrientedProgramming[3][10]. Our system consists of two parts. Thefirst part is the generator of a static Python API from anOWL ontology. This mapping generates classes, methods anddeclarations which can be used by the KP developer to accessdata in the SIB as structured and specified in the OWL ontol-ogy. The second part is the middleware layer which abstractsthe communication with the SIB. Its aim is the handling ofRDF Triples with the generated API by committing changesto the Smart Space. It provides functionality for synchronousand asynchronous queries enabling application developers toprogram new KPs without worrying about the SIB interfaceas the generated API takes care of the connection to the SIBeach time an object is created.

Several KPs may run on different devices and be groupedtogether to interact and be perceived as a single application.This coordination between KPs is done through data exchangewith the SIB where KPs subscribe to.

2011 IEEE/IPSJ International Symposium on Applications and the Internet

978-0-7695-4423-6/11 $26.00 © 2011 IEEE

DOI 10.1109/SAINT.2011.39

218

2011 IEEE/IPSJ International Symposium on Applications and the Internet

978-0-7695-4423-6/11 $26.00 © 2011 IEEE

DOI 10.1109/SAINT.2011.39

218

Page 2: [IEEE 2011 IEEE/IPSJ 11th International Symposium on Applications and the Internet (SAINT) - Munich, Germany (2011.07.18-2011.07.21)] 2011 IEEE/IPSJ International Symposium on Applications

Fig. 1. Context Ontology of a user

IV. CONTEXT ONTOLOGY MODEL

Context information can be modeled using key-value mod-els, graphical models, object oriented models, logic basedmodels and ontology based models [5]. We chose ontologybased context modeling firstly because Smart-M3 providesan interoperability architecture based on ontology modelsfrom which we can benefit for automatic code generationand ontology reasoning. Secondly, ontologies are the mostpromising and expressive models fulfilling information contextrequirements. Thirdly, ontology based models provide flexibil-ity, extendibility and genericity, key factors in context-awaresystems.

We divide the user’s context in two broad categories, atomiccontext and inferred context. Atomic context refers to thecontext data acquired directly from context providers whileinferred context refers to the information deduced from theobserved context data. We start modeling user’s context withsix dimensions (Time, Locality, Devices, Activity, Occupancyand Associations) able to describe most of the domains.

These basic terms and relations (upper ontology in Fig. 1)represent the core concepts modeling the user’s environmentwhile the lower ontology describes domain specific concepts.

V. SYSTEM ARCHITECTURE

Figure 2 shows the overall architecture of our context-awaresystem for support of domain-specific pervasive applications.It consists of:

Context Providers: Context provider KPs give atomic in-formation about the user’s context covering from low leveldata (obtained from sensors, GPS, RFID, WiFi, etc.) to datafrom web services or user profiles. Atomic context informationfrom these providers is used to infer new context informationat higher levels using inference rules and the context reasoner.

Context DataType Interpreter: Since information from het-erogeneous sources has diverse chronological features and dataformats, raw data needs to be converted to meaningful datawhich can be used by different services. This can be done byOWL-S [1](Web Ontology Language for Services) which hascapability to specify characteristics and functionalities of allsources of information.

Fig. 2. System architecture

Context Reasoner/Rules Interpreter: This module is respon-sible for inferring new higher level context from given/sensedatomic context information. The inference rules are defined byKP developers with the Python Rules module allowing to tailorspecific application scenarios. The reasoner can infer e.g. thatthe user’s activity is sleeping when the user is in his bedroomand the bed sensor is on.

Ontologies: OWL Ontologies define the context informationrepresenting both data directly sensed from context providersand inferred information from this data using inference rules.

Inference Rules: The reasoner’s inference process requires aset of deterministic inference rules to infer new context. Thesecan be general or domain specific rules.

A. Inference rules and context reasoning

The inference rules, based on logic programming, allowcontext information origination from the provided set of on-tologies. Its evolution/adaptation is caused by KPs taking partin the application. Rules can define how to infer the user’sactivity using the active context information from multiple KPse.g. how to handle emergency calls while being at a meetingor how to handle multiple requests to play different channelson a single TV at the same time.

We have defined a rule using a 3-clauses pattern:• With() Clause represents assumptions, assertions or dec-

larations about existence of individuals.• When() Clause represents conditions or events that must

hold before the KP’s rule is triggered.• Then() Clause represents actions to trigger, conclusions

representing the inferred information.Following there are few examples which illustrate the def-

inition of inference rules. The first rule states that if the useris in the meeting room (B4050) at a time between 13:00 to15:00 having more than one person there and the projector on,then the user’s activity is inferred as busy in a meeting.with U:- User(id="1", role="Student", name="Mohsin"),

R:- Room(room No.="B4050", location= "ICT"),P:- projector (id="101", type="ProModel")

when U.locatedIn (R, atTime"13:20"),

219219

Page 3: [IEEE 2011 IEEE/IPSJ 11th International Symposium on Applications and the Internet (SAINT) - Munich, Germany (2011.07.18-2011.07.21)] 2011 IEEE/IPSJ International Symposium on Applications

R.occupied("13:00-15:00"), P.locatedIn:- R,R.number of people > 1, P.statusON

then U.busyInMeeting

The following rule forwards incoming calls to the voice mailwithout interrupting the user if he is in a meeting.

with U:- User(id="1", role="Student", name="Mohsin"),Ph:- phone(id="10", type="Iphone", model="4G")

when Ph.incomingCall, U.busyInMeeting, Ph.owner:- Uthen Ph.activeVoicemail

There might be some emergency cases when the userdoes not want to ignore incoming calls. The following ruleoverwrites the result of the previous one when the callingperson is the user’s wife giving a beep to the user’s phone.The user’s relationship with the caller can be obtained fromexisting ontologies given to the system, such as Friend of aFriend ontology in this case.

with U:- User(id="1", role="Student", name="Mohsin"),Ph:- phone(id="10", type="Iphone", model="4G"),C:- Caller(name="Samra", association="wife")

when Ph.incomingCall, U.busyInMeeting,Ph.owner:- U, U.relation:- C

then Ph.beepOnce

VI. IMPLEMENTATION

We use Python’s meta-programming features to enablePython code which includes logic statements representinginference rules. These are inspired from the Event-Condition-Action (ECA) rules model which is a technology from activedatabases with the idea of supporting dynamic functionality[9]. The interpreter for the inference rules is in its early stageof development.

A. Development Framework

The first task is defining a script language to use OWL2allowing the user to express rules as last section showed.The second task is the integration of those ontology basedlogic expressions into a functional Object-Oriented language.Because of its versatility, meta programming opportunities andease of prototyping (easy to learn and use) we chose Python.Thus, given a context, the programmer could define in a simpleway the underlying rules that pervasively help the user dailyin his Smart Space.

The third task is the integration of first and second ap-proaches with the Smart-M3 Ontology to Python API Gen-erator framework [3], which makes more intuitive to theprogrammer the definition of applications providing automaticgeneration of a Python API for every OWL class as well assetters and getters among other methods to interact effortlesslywith the SIB through which all KPs communicate with eachother.

Given the functionality provided by the Smart-M3Ontology-Python framework, there is a need for designinga rule syntax language that allows users -with basic pro-gramming skills- easy definition of rules to model smartapplications. With this idea the need for learning OWL orquery languages is minimized or null.

B. Programming Knowledge Processors in Python

The main feature of the Python Rules Module is to encapsu-late, acting like a bind, the SIB interface. Our implementationapproach, inspired by Pythologic, Prolog syntax in Python [2],structures a rule as follows:

With() // When() >> Then()

In this way, the application programmer does not dealwith RDF Triples directly but mainly with logic Pythonexpressions. Thus, the programmer could embed into Pythoncode expressions like:

1 condition1 = lambda: user.isBusy()2 condition2 = lambda: meetingRoom.

isOccupiedBy(user)3 conditions = [condition1, condition2]4 action = lambda: user.setVoiceMail(True)5 myRule = With([user, meetingRoom]) // When(

conditions) >> Then(action)6 diem.addRule(myRule)

Listing 1. Rule definition with Python Rules Module

The underlying implementation of the Python Rules Moduletranslates Python logic expressions to the SIB API maininterface (Query, Subscribe, Insert, Remove, Update). PythonRules Module just needs to be imported as library to be usedin the KP class where the application is coded.

• With(): If instances in With() exist in the SIB (SIB-Query), proceeds to evaluate When().

• When(): If When() is true (SIB-Query), executes Then().If not, sets a SIB-Subscription to the attributes in Whenclause for knowing when certain attribute’s value haschanged so that the rule can be evaluated again. Thisway avoids unnecessary infinite query loops or trafficbottlenecks.

• Then(): If With() & When() satisfy, executes Then(),which translates into SIB-Update/ SIB-Add/ SIB-Remove/ SIB-Unsubscribe of RDF Triples.

A Knowledge Processor can be located in any device e.g.smart phones: an application for getting the local temperaturefrom the Internet or a sauna/thermostat activator. A KP can becreated and connected to the Smart Space (called ’x’ in thisexample) as follows:

7 app = QtGui.QApplication(sys.argv)8 smartSpace = (’x’, (TCPConnector, (’

127.0.0.1’, 10010)))9 KP = PhoneKP.create(smartSpace)

10 # Definition of Rules11 sys.exit(app.exec_())

Listing 2. KP Programming and Connection to the Smart Space ’x’

After the KP is created the user can define the Python rulesinvolving the existing KPs. Then the KPs are connected to theSmart Space to run.

If EmptyKP.py (generated by the Ontology to Pythondevelopment tool) is used, instance declarations automaticallytranslate to insertions of RDF Triples into the SIB. This allowsother KP applications connected to the same Smart Space toknow about those individuals’ existence to interact with them.At last, the With(), When() and Then() clauses translate its

220220

Page 4: [IEEE 2011 IEEE/IPSJ 11th International Symposium on Applications and the Internet (SAINT) - Munich, Germany (2011.07.18-2011.07.21)] 2011 IEEE/IPSJ International Symposium on Applications

Python statements to one of the implementation options givenby the Ontology-Python Generator (SIB calls in RDF or WQLlanguage). In our approach learning OWL or query languagesis not needed for connections with the SIB and interactionswith other devices’ KPs.

VII. RELATED WORK

The research in context-aware computing gives a number ofcontext-aware systems and approaches for application devel-opment. [7] is a toolkit based approach enabling applicationdevelopment with reusable components. In [6], an agent-based infrastructure for context modeling, context reasoningand knowledge sharing was proposed. They also provideprivacy control techniques. [8] introduces another architecturefor building context-aware services where a central serveror context interpreter gains context data through distributedcontext providers and processes it before sending it to theclients. In [12], the authors extend typical operating systemconcepts to include context-awareness. In comparison to theprevious systems, our approach for modeling and processingcontext addresses the challenge of context-aware ubiquitouscomputing using automated ontology code generation makingeasier the programming of Smart Spaces. Our idea is expres-sive enough to represent domain specific context as abstractcontext data.

VIII. CONCLUSIONS AND FUTURE WORK

In this paper, we expressed our ideas for context-awareapplications for Smart Spaces. We presented our contextualontology for modeling context information and the overallsystem architecture. The structure and syntax of inferencerules are described for an office domain scenario. We concludethat Smart Spaces are well suited for ambient applicationsto adapt to the user’s preferences because they can provideinformation about the physical environment which can beshared and reused by many dynamic applications. In the future,we aim to implement a context manipulation library for ourSmart-M3 tool to process contextual information. Other tasksto be tackled are SIB consistency related issues and extrafunctionality for implementing subscriptions more efficiently.

REFERENCES

[1] OWL-S Services: http://www.daml.org/services/owl-s/.[2] Pythologic, Prolog Syntax in Python:

http://code.activestate.com/recipes/303057-pythologic-prolog-syntax-in-python/.

[3] Smart-M3 Ontology to Python API Generator:http://sourceforge.net/projects/smart-m3/files/smart-m3-ontology to python-api generator v0.9.1beta.tar.gz/.

[4] Smart-M3 software at sourceforge.net, release 0.9.4beta, May 2010.[Online]. Available: http://sourceforge.net/projects/smart-m3/.

[5] M. Baldauf, S. Dustdar, and F. Rosenberg. A Survey on Context-Awaresystems. In International Journal of Ad Hoc and Ubiquitous Computing,volume 2, 2007.

[6] H. Chen, T. Finin, and A. Joshi. An Ontology for context-awarepervasive computing environments. In Proceedings of the Workshopon Ontologies in Agent Systems, 2003.

[7] A. K. Dey and G. D. Abowd. The Context Toolkit: Aiding thedevelopment of context-aware applications. In Workshop on SoftwareEng. for Wearable and Pervasive Computing, 2000.

[8] T. Gu, H. K. Pung, and D. Q. Zhang. A middleware for building context-aware mobile services. In Proceedings of IEEE Vehicular TechnologyConference (VTC), 2004.

[9] P. T. W. J. Bailey, A. Poulovassilis. An event-condition-action languagefor XML. In WWW ’02 Proceedings of the 11th international conferenceon World Wide Web, 2002.

[10] A. Kaustell, M. M. Saleemi, T. Rosqvist, J. Jokiniemi, J. Lilius, andI. Porres. Framework for Smart Space Application Development. InProceedings of the International Workshop on Semantic Interoperability,IWSI, 2011.

[11] I. Oliver and J. Honkola. Personal semantic web through a spacebased computing environment. In Proceedings of the 2nd InterntionalConference on Semantic Computing, 2008.

[12] M. Roman, C. Hess, R. Cerqueira, and A. Ranganathan. A middlewareinfrastructure for active spaces. In IEEE Pervasive Computing, 2002.

221221