A Context Realization Framework for Ubiquitous Applications with ...

1 downloads 296 Views 728KB Size Report
pingHelper mobile application can help to shortlist ... text frameworks have been developed for simpli- ... application context engine (ACE), which supports.
ZHU LAYOUT

8/22/11

3:10 PM

Page 132

COMMUNICATIONS MIDDLEWARE FOR MOBILE DEVICES AND APPLICATIONS

A Context Realization Framework for Ubiquitous Applications with Runtime Support Jian Zhu, Hung Keng Pung, Mohammad Oliya, and Wai Choong Wong, National University of Singapore

ABSTRACT Context awareness, as one of the key techniques applied in ubiquitous computing, makes information technology invisible and seamless to people’s daily living. As a result, numerous context frameworks have been developed for simplifying the development of context-aware applications by providing low-level context data operations such as acquisitions and simple aggregations in terms of APIs or toolkits. These frameworks are still falling short in requiring developers to explicitly deal with context-related tasks such as constraint enforcement in the application code. In this article, we present a framework to bridge the gap. More specifically, an application context model (ACM) is proposed for developers to specify their requirements on the context-related tasks. At application runtime, the ACM is instantiated for automatic context realization by the application context engine (ACE), which supports the full life cycle of each ACM instance (initialization, execution, and termination). We validate the concept of the framework through a case study, and present the experimental results based on the system prototype.

INTRODUCTION The recent advancement of ubiquitous technologies (e.g., radio frequency identification [RFID] tagging, GPS, and wireless sensors) has enabled the provision of adaptive computing services anywhere, anytime. The resulting computing paradigm, known as ubiquitous computing (UbiComp) [1], has been identified as the next-generation information technology (IT) that would greatly improve people’s living experience. One of the key techniques of UbiComp is context awareness, which effectively enables application intelligence by adapting to people’s contexts (as defined by A. K. Dey in [2]). Consider the following scenario: Alice loves shopping. On a recent business trip to Singapore, she plans to visit Orchard Road, a wellknown shopping paradise. However, her tight sched-

132

0163-6804/11/$25.00 © 2011 IEEE

ule simply does not allow her to visit every shop for goodies. Fortunately, her newly installed ShoppingHelper mobile application can help to shortlist and recommend to her those shops in the vicinity of her current location that match her preferences. Moreover, shopping experiences shared by others are easily accessible even on the move to further influence her decision on the shops to eventually visit. The above application relies on contexts such as Alice’s location and preferences for decision making. Although the application scenario is trivial, it has typical features of ubiquitous applications, so we can use it to illustrate the following design considerations and challenges: 1 What are the contexts in the application? How could they be described in a machinereadable format? (context modeling) 2 How are the contexts gathered and retrieved for the application? (context management and retrieval) 3 How does the application leverage on the contexts and embed contextawareness into its application design? (context realization) To simplify the above tasks for ubiquitous application development, numerous context frameworks including toolkits and middleware have been proposed in the last decade. Their context models are mainly designed for the acquisition of context data. This enables the development of a common middleware (e.g., Solar [3] and SOCAM [4]) for the management and retrieval of context data. Although these middleware examples are fairly generic and hence can be used by any application, they do not provide capabilities to deal with higher-level context-related tasks such as runtime constraint enforcement, which are desirable from the application developer’s point of view. Consequently, developers have to explicitly implement these logics in the application code, for example, calling the API to retrieve context data (e.g., shop’s location and type) and enforcing constraints (e.g. nearby shops that match Alice’s preferences) by using if/else statements. This results in a tightbinding model for application implementation. In case there are changes in the requirements or

IEEE Communications Magazine • September 2011

ZHU LAYOUT

8/22/11

3:10 PM

Page 133

constraint1.txt ShopService.name

The proposed context model, called the application context model (ACM), is a conceptual graph model that defines a set of elements, including ApplicationEntities, ContextEntities, ContextAttributes, ContextRelationships, StartingContexts, and EndingContexts.

Box 1. the underlying context frameworks, application developers have to rewrite and redeploy the whole application. In this article, we define context logics as the set of context-related tasks required by a ubiquitous application. They involve application adaptation — the situation or event when the application is triggered/terminated; constraint enforcement — checking on the validity of application entities involved and their context statuses; context flow — the transition of the context data among application entities. We present a framework to facilitate the realization of these tasks; therein the context logic is decoupled from the application layer, and its formulation is shifted to the design time rather than during the implementation phase. This approach reduces the complexity of application implementation and further provides flexibility in handling requirement changes for evolving applications. To achieve this, an application context model (ACM) is introduced to allow application developers to specify their context logic. The ACM is then registered with the application context engine (ACE), which handles the full life cycle — initialization, execution, and termination — of each ACM instance at application runtime. As a proof of concept we illustrate the use of the framework through a case study and present experimental results derived from a prototype.

ACM: CONCEPTUAL MODEL FOR APPLICATION CONTEXTS We adopt a model-driven approach to develop our context model. The proposed context model, the ACM, is a conceptual graph model that defines a set of elements, including Application-

IEEE Communications Magazine • September 2011

Entities, ContextEntities, ContextAttributes, ContextRelationships, StartingContexts, and EndingContexts. The ApplicationEntities are entities involved in the application scenarios. They execute application logic such as message sending and processing. The ContextEntities are abstractions of the ApplicationEntities that act as virtual context sources in the application. We define them based on the ContextAttributes they possess, and a collection of ApplicationEntities having similar attributes are abstracted to the same ContextEntity. The ContextRelationships define the types of context relations among the entities in the model. It is further divided into three types: ContextBelongings between ContextAttributes and ContextEntities; ContextAbstractions between ApplicationEntities and ContextEntities; and ContextFlows among ApplicationEntities. Among them, the most important element is ContextFlows, as they determine what context data is relevant to which ApplicationEntity and under what situation the data can be derived from the relevant ApplicationEntity. They follow the form name:constraint#data syntax, where name is the ContextFlow name, constraint specifies the qualifications for participating ApplicationEntities or their ContextAttributes, and data refers to the context data being passed in the form of either ContextAttributes or constant values. Both the constraint and data may be omitted, and for retrieving data, the ContextFlow name is used for reference. The last two elements, StartingContexts and EndingContexts, indicate the situations when the application should be triggered or terminated. With regard to the processes of context realization, they refer to when the ACM should be instantiated or destroyed. They are specified by a set of constraints over Application-

133

ZHU LAYOUT

8/22/11

3:10 PM

The ACM reflects the context logics embedded in an

Page 134

StartingContexts equal(User.id, “alice”) Ie(distance(ShopService.location, User.location), “100”) match(ShopService.type, User.preferences)

EndingContexts equal(APPLICATION.Status, “FINISH”)

application. For

ExpIndexing Server

instance, the cf2: #ShopService.name

StartingContexts and EndingContexts are for application

cf1: equal(User.id, “alice”) Ie(distance(ShopService.location, User.location), “100”) match(ShopService.type, User.preferences) # ShopService.name

cf3:#ExpProvider.id cf4: friend(User.id, ExpProvider.id) # User.id, ShopService.name

adaptation; constraints in ContextFlows are for

ShopService

constraint enforce-

User ,

type

preferences

ExpProvider

ment; and the edges between Applicatio-

name

nEntities are for

SHOP

id

location

PERSON

location

context flow. ApplicationEntity

ContextAttribute

ContextAbstraction StartingEntity

IndependentEntity

ContextEntity

ContextBelonging

ContextFlow

DependentEntity

EndingEntity

Figure 1. An example of the ACM, constructed for the ShoppingHelper application described in the Introduction. Operator le means less than or equal to.

Entities, which is similar to those for ContextFlows. The example ACM shown in Fig. 1 illustrates the graphical notations used. This model has four ApplicationEntities represented by rectangles. They are derived based on the ShoppingHelper application described earlier. As the application itself is simple, the derivation is skipped here. Three of the ApplicationEntities are abstracted as ContextEntities, shown in pentagons. Both User and ExpProvider are abstracted to PERSON as they share the common ContextAttributes id, location, and preferences (shown in circles). The respective ContextRelationships are indicated using different types of edges. When describing the ContextAttribute of a particular ApplicationEntity, the operator “.” is used (e.g. User.id). To express constraints in ContextFlows, StartingContexts, and EndingContexts, rules are applied. In addition, highlevel operators such as “distance()” and “match()” are supplied to help developers specify constraints in a more intuitive way. The detailed constraints could be either specified in the model directly or referenced to a text file. In our current implementation, the ACM specification is ontology-based and marked up using W3C’s OWL language. Box 1 illustrates part of the OWL specification for the ACM in Fig. 1. The ACM reflects the context logic embedded in an application. For instance, the StartingContexts and EndingContexts are for application adaptation; constraints in ContextFlows are for constraint enforcement; and the edges between ApplicationEntities are for context flow. By separating them from the application logic, it is flexible to modify any logic parameter without reimplementing and redeploying the application.

134

For instance, in Fig. 1 we could easily add another constraint (i.e., in cf4) to the ACM for retrieving shopping experience from the ExpProvider; that is, only if the ExpProvider is a friend of Alice do we retrieve the ExpProvider’s data for Alice.

ACE: APPLICATION INDEPENDENT ENGINE FOR CONTEXT REALIZATION To automate the process of context realization for ubiquitous applications, we have developed an application-independent engine, named the application context engine (ACE), to process their ACMs. More specifically, the engine is able to automatically trigger the application with its registered ACM and provides runtime support for each ACM instance. The detailed functional components of ACE and their relationships are shown in Fig. 2. At first, the ACM specified by the application developer is registered to the ACE through the ACE interface; thereafter, the ACM manager extracts the application contexts (i.e. all the ACM elements) and pass them to the application context interpreter, which is in charge of constructing the ACM-specific ontology as well as parsing and transforming rules in the StartingContexts, EndingContexts, and ContextFlows of the ACM. To enable automatic contextual events triggering and termination of each ACM instance, the ContextAttributes involved in the StartingContexts and EndingContexts are subscribed through the context handler, which in turn interacts with an underlying context framework to get the related context facts updated. When an ACM instance is created, it is initialized with an application scenario table (AST), which is used to track all the relevant instances of ApplicationEntities

IEEE Communications Magazine • September 2011

ZHU LAYOUT

8/22/11

3:10 PM

Page 135

ApplicationEntities: User, ExpProvider, ShopService ......

Application context engine (ACE) interface ACM registration

ACM instance query

Application context interpreter Application contexts

ACM manager

ACM instance

Parse

Ontology parser

Update

ACM ontology

Load

Application scenario table (AST)

Rule parser Creation Updating/ retrieval

ACM parsing

Removal

Transform Realize

Application contexts

Initialization

Application context interpretation

Execution

Termination

Rule transformer

Event subscriber

Instance initialization/ enforcement/ termination

Realize

Subscribe Notify

ACM instance

Infer ContextEntities: PERSON, SHOP ......

Application context interpreter

Upper ontology

Retrieval Subscription Context handler

Context handler

Inference engine Subscribe Update Realize

Update

Infer

Context fact base Update Context fact updater

Figure 2. The functional components of the ACE and the application context interpreter.

involved in all possible application scenarios. The table is also updated along with the execution of the application instance.

APPLICATION CONTEXT INTERPRETER The application context interpreter with its functional components is shown in Fig. 2. Once the application contexts are passed, its ontology parser constructs the specific ACM ontology. For instance, the OWL concepts (Box 2) about the applicationEntities in Fig. 1 are updated. In addition, constraints specified in the ACM have to be parsed by the rule parser and converted to the format processable by the underlying inference engine. Our current rule syntax is extended from the Generic Rule Language (GRL) of Jena,1 which defines a rule by a list of body terms (premises) and a list of head terms (conclusions). The premises are used for indications of constraints in the ACM, with each term represented in a triple pattern (subject, property, object). For the detailed specification, developers may use primitive operators interpretable by the inference engine (e.g., “equal()”). Alternatively, they could use high-level operators such as “distance()” and “friend().” The rule parser is responsible for converting them to the terms and those primitive operators. Box 3 shows the conversion for the operator friend() to the premises in GRL. After the rule parsing, the rule transformer marks up the rules to satisfy different needs: if the rules are for constraints in ContextFlows, they are marked up by using the specific ACM ontology (e.g., acm:User) and will be enforced by the ACM instance at application runtime; otherwise, if the rules are for StartingContexts and

IEEE Communications Magazine • September 2011



Box 2. friend(User.id, ExpProvider.id) → (?v1 rdf:type acm:User) (?v2 rdf:type acm:User.Friend.ID) (?v1 acm:hasContextAttribute ?v2) (?v2 acm:hasContextValueS ?v3) (?v4 rdf:type acm:ExpProvider) (?v5 acm:type acm:ExpProvider.ID) (?v4 acm:hasContextAttribute ?v5) (?v5 acm:hasContextValueS ?v6) equal(?v3 ?v6)

Box 3. EndingContexts, they are marked up using the upper ontology for ContextEntities (e.g., acm:PERSON) and subscribed to the event subscriber. Box 4 illustrates the ontology for ContextEntity “PERSON.” The event subscriber fulfills two tasks: • It subscribes via the context handler the ContextEntities that need to be updated (e.g., PERSON, SHOP). • It interacts with the inference engine to check for occurrence of an event.

1 http://jena.sourceforge.net/.

135

ZHU LAYOUT

8/22/11

3:10 PM

Page 136



Box 4. Depending on the event type, if the StartingContexts for an ACM are satisfied, the corresponding ACM instance is initialized, and meanwhile, the notifications are sent to those ApplicationEntities labeled with StartingEntity as illustrated in Fig. 1; otherwise, if the EndingContexts are satisfied, then the corresponding ACM instance is terminated and ApplicationEntities labeled with EndingEntity are notified. These events are derived by the inference engine that performs the computation and reasoning tasks as requested by both the event subscriber and the ACM instance. At this stage, our framework deploys both Jena and Jess,2 which are the two most well-known rule engines. At the bottom of the application context interpreter is the context fact base together with the context fact updater. The context fact base consists of a set of context facts (i.e. information about a ContextEntity and its ContextAttributes), wherein each of them is marked up by the upper ontology. The context updater is in charge of feeding fact data to the inference engine through the context fact base. Depending on the type of the engine deployed, it updates the data in different formats (e.g. triples for Jena and slot-value pairs for Jess). The context updater is invoked by the context handler that gets the actual data by either subscribing with or retrieving directly from an underlying context acquisition framework, such as a middleware likes Solar or SOCAM. Box 5 illustrate the context facts related to Alice’s name and preferences in the context fact base when using Jena.

CONTEXT FACT MANAGEMENT As the management of context data is extremely important for efficient data processing as well as context reasoning, the following two schemes are applied to help improve memory usage and reduce the size of the data for inference. Selective Context Attribute Update: In reality, there are numerous context facts to be updated in the context fact base. However, not all the information (i.e. ContextAttributes) is useful. For instance, to infer those shops within a certain proximity, only the context fact regarding the location of the shop should be updated. As mentioned in the previous section, the event subscriber in the application context interpreter

is able to subscribe to the context handler only for those attributes required by the ACM. Therefore, the context facts will be selectively updated. Two-Level Application Context Management: In addition to the context fact base, each ACM instance has its own application context base that stores the context facts relevant to its application usage. The application context base is marked up by the specific ACM ontology. An update to this context base is required when utilizing data from the context fact base. For instance, a triple statement (acm:alice rdf:type acm:User) is inserted to the application context base to allow Alice’s context facts (e.g. name and preferences) in the context fact base to be used by the ACM instance. Such a scheme allows the isolation of application context management, and context facts in the context fact base can be utilized among all the ACM instances.

ACM INSTANCE INITIALIZATION Once an ACM instance is created, the application scenario table (AST) is initialized. The AST is used to keep track of all the possible ApplicationEntities and their context facts at application runtime. At first, only ApplicationEntities labeled with IndependentEntity (as illustrated in Fig. 1) are instantiated to fill the AST. ApplicationEntities labeled with DependentEntity are not instantiated right now, as their attributes can be instantiated during application execution and certain attributes may be derived from the application logics, for example, ExpProvider.id from the matching process by ExpIndexingServer. We differentiate these two types of ApplicationEntities so to improve the speed of context realization and the efficiency of memory usage. They are automatically differentiated by checking whether there is any ContextAttribute of the ApplicationEntity that is not derived from the ApplicationEntity itself but is involved in any ContextFlow. For instance, in Fig. 1, ShopService and User are IndependentEntities; ExpIndexingServer is not of either type since it is not abstracted to any ContextEntity; ExpProvider is a DependentEntity as its ContextAttribute — ExpProvider.id is not derived by itself. Once all the possible ApplicationEntities are instantiated and the corresponding context facts are stored in the application context base, the available rules from the ACM ontology are applied on these facts. Only those satisfied application scenarios are filled in the AST (as shown in Fig. 3a).

ACM INSTANCE EXECUTION After ApplicationEntities labeled with StartingEntity are notified by the ACE, the application logics start execution. They cater to applicationlevel processes such as data storage and communication, and may be distributed to several

(acm:alice rdf:type acm:PERSON) (acm:alice.PERSON.Name rdf:type acm:PERSON.Name) (acm:alice.PERSON.Name acm:hasContextValueS “Alice”^^xsd:string) (acm:alice.PERSON.Preferences rdf:type acm:PERSON.Preferences) (acm:alice.PERSON.Preferences acm:hasContextValueS “clothing,bags,shoes”^^xsd:string) (acm:alice acm:hasContextAttribute acm:alice.PERSON.Name) (acm:alice acm:hasContextAttribute acm:alice.PERSON.Preferences) 2 http://www.jessrules.com/.

136

Box 5.

IEEE Communications Magazine • September 2011

ZHU LAYOUT

8/22/11

3:10 PM

Page 137

Application scenario table ShopService

User

ExpProvider

id

Location

Preferences

Name

Location

Type

“alice”

(1296373, 103783642)

Clothing, shoes, jewelry

“This Fashion”

(1296371, 103783646)

Clothing

“alice”

(1296373, 103783642)

Clothing, shoes, jewelry

“Channel”

(1296368, 103783650)

Clothing

“alice”

(1296373, 103783642)

Clothing, shoes, jewelry

“Cartier”

(1296369, 103783647)

Jewelry

“PC zone”

(1296369, 103783747)

Computer

“Lee Hwa”

(1296369, 103783747)

Jewelry

......

Filtered!

(a) Scenario update table ShopService

ExpProvider

Name

id

“This Fashion”

“John Smith”

“This Fashion”

“Kate Hudson”

“Channel”

“John Smith”

“Channel”

“John Smith”

Application scenario table User

ShopService .name

ShopService

id

Location

Preferences

Name

Location

Type

“alice”

......

......

“This Fashion”

......

......

“alice”

......

......

“Channel”

......

......

“alice”

......

......

“Cartier”

......

......

(b)

Figure 3. Illustration of the initialization and updating operations for the AST created for the instance of the ACM shown in Fig. 1. The data stored in the AST are all derived from the Application Context Base of the ACM instance: a) initializing the AST: the first two rows represent the ApplicationEntities and their ContextAttributes; the rest of rows are filled by the values after instantiation (the values are represented without showing their ontology markups for better clarity). The constraint that the shops are within 100m from Alice and matching her preferences is enforced. The ContextAttributes of ExpProvider are not instantiated at this moment as ExpProvider is a DependentEntity; b) updating the AST: the left table is constructed after filtering ExpProviders that are not friends of Alice. We do the JOIN operation based on the matched ShopService.name to complete all the possible application scenarios for the AST.

ApplicationEntities, but with the ACE, they no longer need to take context logics, such as context constraints, into consideration. For instance, when Alice’s smart phone is notified, it could simply call “retrieve(‘ShopService.name’)” from the ACE interface to retrieve the names of the nearby shops that match her interests (Note that the type of data to be retrieved is restricted by the data indicated in the ContextFlow that is incoming to the ApplicationEntity). The semantics of “nearby shops that match interests” are realized by the ACE but not embedded in the application logic. The same thing occurs when Alice’s smart phone wants to get experience data from ExpProviders: it calls “retrieve(‘ExpProvider.id’)” from the ACE interface, with the constraint that the provider must be a friend of Alice is automatically enforced in the returning results. To achieve this, • Each AST is identified with a unique ID that is assigned during the initialization of

IEEE Communications Magazine • September 2011

the corresponding ACM instance. The application logics should know which AST to interact with during their executions; hence, the ID of the AST is provided as the additional parameter in all the interactions with the ACE interface. • The AST should be updated along with the execution of application logics so that other ApplicationEntities are working with the latest application scenarios. For instance, once ExpIndexingServer gets ShopService.name from User, it updates the AST by invoking “update(shop_service, exp_provider)” to the ACE interface, where shop_service may refer to “Channel” and exp_provider refers to the person who has experience on the shop service, e.g. “John Smith”. However, due to the constraint (i.e. ExpProvider must be a friend of Alice) indicated in the ACM, the ACE will filter those irrelevant ExpProviders. The IDs of the remaining ExpProviders are then

137

ZHU LAYOUT

8/22/11

3:10 PM

As the management of context data is extremely important

Page 138

filled in the AST by doing the JOIN operation based on the matched shops (Fig. 3b). By doing so, the ShopService.name is provided as the right parameter to the right ExpProvider for each application scenario in the AST.

for efficient data

ACM INSTANCE TERMINATION

processing as well as

The termination of an ACM instance can be explicitly invoked by the application, so that the “APPLICATION.Status” becomes “FINISH.” Alternatively, it can be terminated by indicating the EndingContexts in the ACM. Similar to the StartingContexts, they are subscribed by the event subscriber in the application context interpreter. Once the conditions are satisfied, the EndingEntities are notified, and the ACM instance together with its ACM ontology, application context base, and AST are destroyed in the ACE.

context reasoning, the following two schemes are applied to help improve memory usage and reduce the size of the data for inference: Selective Context Attribute Update and Two-Level Application Context Management.

ACE DEPLOYMENT The proposed ACE can be deployed in a flexible manner: if there is a management system (e.g. a middleware such as Solar and SOCAM) managing large-scale context sources, the ACE can be deployed on top of it and be provisioned as part of the middleware service for applications to interact with. Alternatively, for small-scale applications which usually have their own context management schemes (e.g. a relational database hosted by one of the ApplicationEntities), the ACE can be co-hosted in the computer system hosting the corresponding ApplicationEntity. For instance, the host of the ExpIndexingServer is such a suitable place to co-host the ACE in the illustrated ShoppingHelper application. Nevertheless, in both cases, the underlying context management framework should support the retrieval and subscription tasks of the context handler in the application context interpreter, say, by mapping of ContextAttributes of ContextEntities to column attributes in the database.

A CASE STUDY As a proof of concept, we present the use of our context realization framework for the development of the exemplar ShoppingHelper application. The middleware, CAMPH [5], is leveraged to support the retrieval of context facts and subscription of contextual events. Figure 4a shows the sequence diagram of our previous implementation for the application logics running on different participants, and Fig. 4b presents the application flow of the new implementation with the deployment of the context realization framework (The interactions between the ACE and CAMPH are omitted). By comparing the two figures, we can summarize the following advantages for developing ubiquitous application with our context realization framework: • The triggering of the application is no longer initialized by the application itself, i.e. by constantly checking the condition (the Loop structure in Fig. 4a); rather it can be notified by the ACE by registering its ACM. This approach is useful in mobile computing where power consumption is a major concern for applications running on mobile devices • The context logics embedded in the application are taken care of by the ACE but not the application logics running on different

138

ApplicationEntities. This improves processing efficiency and saves power consumption. • Once the context logics are extracted from the application layer, it is flexible to modify them. For instance, in addition to the proximity and type constraints, the ACM can be easily modified to add in the crowd level consideration (i.e. if the shop is too crowd, then it would not be appropriate for her tight schedule). The new ACM can be uploaded to the ACE and the modification immediately takes effect for the next instance initialization; while the application running on Alice’s mobile device is not affected, and the whole updating process is transparent to the ubiquitous application users. We have carried out preliminary experiments to evaluate the performance of the ACE prototype in terms of the updating overheads of its AST operation and the reasoning delay of the inference support during the running of application. The prototype is implemented in Java on a 32-bit Intel Core2 Duo @3.0GHz PC with 4 Gbytes of RAM. The AST updating involves the scenario update table and the application scenario table as illustrated in Fig. 3b. Upon receiving all the updating context facts from the ApplicationEntity (e.g., ExpIndexingServer), the scenario update table is constructed. It is merged with the AST to derive the application scenarios that involve all the relevant instances of ApplicationEntities for further execution of the application. In all of our tests, we found the JOIN operation on the two tables has taken less than one second. For the inference support, the reasoning efficiency over the fact data is measured. The tests are carried out for constraint in “cf1” of Fig. 1. Two test patterns are applied: “N-1” and “N-N”. The first pattern represents Many ShopServices and One User; that is, in the ACE there are context facts regarding many instances of ShopService but only one instance of User (i.e. Alice). While the second pattern represents Many ShopServices and Many Users, i.e. by excluding the constraint “User.id=“alice”.” Up to 10K instances of User are emulated in the “N-N” pattern. For all the test cases, the reasoning delay, defined as the time spent for the inference engine to get the potential User and his relevant ShopServices, is measured. Table 1 presents the results by using Jena and Jess. As observed, Jena is not a good choice for real-time reasoning despite of its better features such as direct support for RDF/OWL. Jess, on the other hand, has no semantic support and requires preprocessings such as RDF triple transformation (i.e. to its template format). Nevertheless, its reasoning speed is much faster than Jena. In the tests, we have also tried both engines in backward-chaining inference mode. Generally speaking, the reasoning speed of Jena is boosted up as compared to that in forward-chaining mode. However, the current implementation of Jena in backward-chaining mode does not support complex rules that involve more than 15 variables. In fact, as nested functions are not supported in Jena, the variable number limitation will be quickly exhausted by using temporary variables to hold the returned values of functions, for example, for the computation of “distance().”

IEEE Communications Magazine • September 2011

ZHU LAYOUT

8/22/11

3:10 PM

Page 139

User:Alice CAMPH

User:Alice

ExpIndexingServer

ExpProvider

The new ACM can be uploaded to the

Loop (No ShopService within 100 m and matches User preferences = true)

ACE and the modifi-

Get ShopService based on User.location

cation immediately takes effect for the

Return ShopService.name

next instance initialization; while the

Filter ShopService based on distance and type

application running on Alice’s mobile device is not affect-

Get ExpProvider.id based on ShopService.name

ed, and the whole updating process is

Return ExpProvider.id

transparent to the ubiquitous application users.

Filter ExpProvider based on id Get experience data based on ShopService.name Return experience data

(a)

User:Alice

User:Alice ACE

ExpIndexingServer

ExpProvider

Notify there is ShopService within 100m and matching preferences Get ShopService.name Return ShopService.name from the AST

Get ExpProvider.id based on ShopService.name Update ExpProvider.id to the AST

Get ExpProvider.id

Update the AST

Return ExpProvider.id from the AST Get experience data based on ShopService.name Return experience data (b)

Figure 4. a) sequence diagram for ShoppingHelper application in the original implementation. Note that the context logic such as context retrieval and filtering is all realized in the application logic running on Alice’s smart phone; b) sequence diagram for ShoppingHelper application with our proposed context realization framework. Note that the context logic is separated from the application logic running on Alice’s smart phone.

IEEE Communications Magazine • September 2011

139

ZHU LAYOUT

8/22/11

3:10 PM

Over the last decade, many researchers have been working on development support for contextaware applications. Their primary focus has been on the simplification of contextrelated tasks such as context management and retrieval so that developers could focus more on the application itself.

Page 140

Pattern

N–1

Test case

100 – 1

1K – 1

10K – 1

Jena

2832 ms

∼ 45 min

>5h

Jess

10 ms

21 ms

131 ms

Pattern

N–N

Test case

100 – 100

1K – 1K

10K – 10K

Jena

∼ 8 min

OOM

OOM

Jess

45 ms

2652 ms

~ 6 min

Table 1. The reasoning delay for inference engines Jena and Jess. Forward-chaining inference mode is applied for both of them. OOM stands for out of memory when the maximum Java heap size set to 1 Gbyte.

RELATED WORK Over the last decade, many researchers have been working on development support for contextaware applications. Their primary focus has been on the simplification of context-related tasks such as context management and retrieval so that developers could focus more on the application itself. Numerous context frameworks including toolkits and middlewares have been developed. The representative ones are Context Toolkit [6], Solar [3], a CAPpella [7], CoBrA [8], SOCAM [4], iCAP [9], Software Engineering Framework [10], VisualRDK [11], Hydra [12], CAMPH [5] and OPEN [13]. Due to space limitation, we will not present their details here. To compare with our ACE framework, Table 2 summarizes their key properties. As shown in the table, most of these frameworks only consider programming support at a low level: context data retrieval and application triggering. Frameworks such as a CAPpella, iCAP and VisualRDK, although give graphical user interfaces to let developers implement their applications visually, they are typically restricted by the functions allowed for applications and only meant for prototyping. In frameworks such as Context Toolkit, SOCAM and CAMPH, various APIs are provided to simplify context-related tasks for developers; however, this also results in a hard binding model during the application implementation. Besides, they only consider the triggering of the application at the right context but without catering for its context requirements (e.g. constraints) at runtime. As some applications can be complex and involve multiple real-world entities, efficient realization of those requirements along with the application execution is necessary to reduce implementation complexity and to improve application flexibility. Our proposed framework ACE is targeting to address this issue. It aims to help application developers to specify their context requirements easily at design time and automatically realize them at runtime in a soft integration fashion. The closest framework to our proposal is the Software Engineering Framework in [10]. Howev-

140

er, their context model is application dependent; hence, context facts describing the same entity for different applications may be duplicated, which results in large sized context repository and incurs additional maintenance overhead. In our approach, we allow the mapping of entities in the application level to entities in the context level through abstraction so that the same set of context facts can be used in reasoning for different application triggering. In addition, their approach does not consider the application lifecycle in the management of context facts. Indeed, context facts can be generated or determined during the application execution (i.e., by the application itself); therefore, context realization at application runtime is necessary. In spite of the proposed branching model in their approach, they have not addressed the problem adequately.

CONCLUSION AND FUTURE WORK In this article, we have presented a framework of context realization for ubiquitous applications. The fundamental goal is to ease the task for application developers in embedding context logics (i.e. application adaptation, constraint enforcement and context flow) in their application design. To achieve this, we have proposed the Application Context Model (ACM) that considers context logics required by the application and allows the developer to specify them easily at design time. The defined ACM is then managed by the Application Context Engine (ACE) at runtime. The detailed context realization for each ubiquitous application instance is carried out on the corresponding ACM instance automatically. With context logics extracted from the application layer, the whole framework provides flexibility such as in modifications to context constraints. We have done a case study to demonstrate the use of the framework. Preliminary experiments have also been carried out. As observed, the reasoning delay from the underlying inference engine imposes the biggest challenge for the effectiveness of the framework. Indeed, context reasoning is a common problem in UbiComp. The issue is how to handle reasoning over large-scale context data that may frequently change. In spite of optimizing the inference engine itself, a more practical way is to distribute the data over multiple machines and carry out distributed reasoning. We are currently working toward that direction, and we believe the two-level application context management scheme and the flexible ACE deployment plan as mentioned earlier serve as a good starting point. In addition, a more rigorous evaluation of the framework system such as through a field trial involving real users will be carried out in the near future.

ACKNOWLEDGMENTS This work is partially supported by project grant NRF2007IDM-IDM002-069 on “Life Spaces” from the IDM Project Office, Media Development Authority of Singapore.

REFERENCES [1] M. Weiser, “The Computer for the 21st Century,” Sci. Amer., 1991, pp. 66–75. [2] A. K. Dey, “Understanding and Using Context,” Personal Ubiquitous Computing, vol. 5, no. 1, 2001, pp. 4–7.

IEEE Communications Magazine • September 2011

ZHU LAYOUT

8/22/11

3:10 PM

Page 141

Programming support

Integration method

Technique

Context Toolkit, Solar

Context retrieval, event subscription

Implementation (hard integration)

Context modeling (attribute-value model)

a CAPpella

Application prototyping, application triggering

Design (UI-based)

Context modeling (attribute-value model), context reasoning (machine learning)

CoBrA

Context retrieval, application triggering

Implementation (hard integration)

Context modeling (ontology-based model), context reasoning (rule-based)

SOCAM, CAMPH

Context retrieval, event subscription, application triggering

Implementation (hard integration)

Context modeling (OWL-based model), context reasoning (rule-based)

iCAP

Application prototyping, application triggering

Design (UI-based)

Based on Context Toolkit, context reasoning (rule-based)

Software Engineering Framework

Application triggering, context branching at runtime

Design (CML-based), implementation (soft integration)

Context modeling (object-role model), context reasoning (rule-based), context branching (preference model)

VisualRDK

Application prototyping, application execution at runtime

Design (UI-based)

Context modeling (attribute-value model), context branching (event- based)

Hydra

Context retrieval for mobile users

Implementation (hard integration)

Context modeling (attribute-value model)

OPEN

Application triggering

Design (for normal user), implementation (for expert)

Context modeling (OWL-based model), context reasoning (rule-based)

ACE

Application triggering, context constraint enforcement at runtime

Design (OWL-based), implementation (soft integration)

Context modeling (application context model), context reasoning (rule-based)

Table 2. Summarization of the context frameworks for context-aware application development. [3] G. L. Chen and D. Kotz, “Solar: An Open Platform for Context-Aware Mobile Applications,” Pervasive Computing, 2002, pp. 41–47. [4] T. G, H. K. Pung, and D. Q. Zhang, “A Service-Oriented Middleware for Building Context-Aware Services,” Network and Comp. Apps., vol. 28, no. 1, 2005, pp. 1–18. [5] H. K. Pung et al., “Context-Aware Middleware for Pervasive Elderly Homecare,” IEEE JSAC, vol. 27, no. 4, 2009, pp. 510–24. [6] A. K. Dey, G. D. Abowd, and D. Salber, “A Conceptual Framework and A Toolkit for Supporting the Rapid Prototyping of Context-Aware Applications,” Human-Computer Interaction, vol. 16, no. 2, 2001, pp. 97–166. [7] A. K. Dey et al., “a CAPpella: Programming by Demonstration of Context-Aware Applications,” SIGCHI Conf. Human Factors in Computing Sys., 2004, pp. 33–40. [8] H. Chen, An Intelligent Broker Architecture for Pervasive Context-Aware Systems, Ph.D. thesis, University of Maryland, Baltimore County, Maryland, 2004. [9] A. K. Dey et al., “iCAP: Interactive Prototyping of Context-Aware Applications,” Pervasive Computing, 2006, pp. 254–71. [10] K. Henricksen and J. Indulska, “Developing ContextAware Pervasive Computing Applications: Models and Approach,” Pervasive Mobile Computing, vol. 2, no. 1, 2006, pp. 37–64. [11] T. Weis et al., “Rapid Prototyping for Pervasive Applications,” Pervasive Computing, vol. 6, no. 2, 2007, pp. 76–84. [12] T. Caus, S. Christmann, and S. Hagenhoff, “Hydra — An Application Framework for the Development of Context-Aware Mobile Services,” Business Info. Sys., vol. 7, no. 14, 2008, pp. 471–81. [13] B. Guo, D. Q. Zhang, and M. Imai, “Toward A Cooperative Programming Framework for Context-Aware Applications,” Personal Ubiquitous Computing, vol. 15, no. 3, 2011, pp. 221–33.

IEEE Communications Magazine • September 2011

BIOGRAPHIES JIAN ZHU ([email protected]) is a Ph.D. candidate in the Department of Computer Science, National University of Singapore. He received his B.Sc. degree in computer science from National University of Singapore in 2005. His research interests are ubiquitous computing, context-aware service organization, discovery, and matching. H UNG K ENG P UNG ([email protected]) is an associate professor in the Department of Computer Science, National University of Singapore. He received his Ph.D. in 1986 from the University of Kent at Canterbury, United Kingdom. He heads the Network Systems and Services Laboratory as well as being a research scientist at the Institute for Infocomm Research (I2R). His areas of research are context-aware systems, service-oriented computing, quality of service management, protocol design, and networking. MOHAMMAD OLIYA ([email protected]) is a Ph.D. candidate in the Department of Computer Science, National University of Singapore. He received his B.Sc. degree in computer engineering from Iran University of Science and Technology in 2008. His research interests are distributed systems and semantic web. WAICHOONG WONG ([email protected]) is a professor in the Department of Electrical and Computer Engineering, National University of Singapore. He received his Ph.D. degree from Loughborough University, United Kingdom, in 1980. He is currently holding the position of deputy director at the Interactive and Digital Media Institute (IDMI) in National University of Singapore. His research interests include wireless networks and systems, multimedia networks, and source matched transmission techniques.

141