Modeling and generating context-aware agent-based ...

13
Modeling and generating context-aware agent-based applications with amended colored Petri nets Oh Byung Kwon * College of Management and International Relations, Kyunghee University, YongIn, Kyunggi Do, 449701 YonginSi, South Korea Abstract Context-awareness is become more crucial in mobile distributed computing systems. However, sophisticated modeling methods to analyze context-aware systems are still very few. Among those, the Colored Petri Net (CPN) is promising because it is proven to be useful for modeling system dynamics and concurrency control in more efficient ways. However, to support managing multiple configurations of components of context-aware applications, some features need to be added to specialize the CPNs. To address these challenges, our research has two idea: (a) to decompose a system into several meaningful subsystems, each of which we will call a pattern, and (b) to separate context from the patterns to realize context-pattern independence. Hence, we propose a modeling methodology to represent and analyze a context- aware agent-based system, which tends to be highly complex. We introduce CPNs as a method of capturing the dynamics of this contextual change. We define CPNs and a way to apply them in context-aware agent-based systems. We also describe a prototype system that we have developed called CPN Generator, which translates CPN specification into Java programs. q 2004 Elsevier Ltd. All rights reserved. Keywords: Context-awareness; Colored Petri nets; Multi-agent system; Mobile distributed computing; Modeling and simulation 1. Introduction Context-aware computing is becoming a crucial element in mobile distributed computing systems. Context-aware systems themselves tend to be complex mainly because the context information is dynamic and acquired from multiple distributed sources. Because of this complexity, representing and analyzing the system is quite difficult. Designers for context-aware applications may find it difficult to enumerate the set of contextual states, know what information could accurately determine a contextual state within that set, and state what appropriate action should be taken from a particular state (Greenberg, 2001). Context-aware systems may be categorized as routine and recurring systems, or as non-routine or infrequent systems. Examples of routine systems that can be automated or programmed include reserving restaurants for dinner at a fixed time, or library services when the user’s location is in a library. Many context-aware systems are routine. However, because context-aware systems are exponentially complex as the number of contextual sensors increases, it becomes difficult to handle the system. Hence, among those systems, we are interested in routine yet complex context- aware systems. Moreover, we are also interested in the separating contextual dimension: i.e. a behavior of a system recurs when a sort of contextual situation recurs. This implies that if we successfully decompose a system into several subsystems, then we will get more chances to analyze complex context-aware systems, which might mitigate development and maintenance costs. However, sophisticated modeling methods to analyze or optimize context-aware systems are still very few (Anhalt, 2001; Jersak, Henia, & Ernst, 2004; Tandler, 2004). Among those, Petri Nets have been recognized as promising technologies. They have been proven to be useful for modeling system dynamics because context-aware systems are very dynamic. Petri Nets have been typically applied to model and analyze dynamically changing systems. More- over, since the contextual information is acquired from many sources such as sensors, Petri Nets will become more 0957-4174/$ - see front matter q 2004 Elsevier Ltd. All rights reserved. doi:10.1016/j.eswa.2004.06.008 Expert Systems with Applications 27 (2004) 609–621 www.elsevier.com/locate/eswa * Tel.: C82-31-201-2306; fax: C82-31-204-8114. E-mail address: [email protected].

Transcript of Modeling and generating context-aware agent-based ...

Modeling and generating context-aware agent-based applications

with amended colored Petri nets

Oh Byung Kwon*

College of Management and International Relations, Kyunghee University, YongIn, Kyunggi Do, 449701 YonginSi, South Korea

Abstract

Context-awareness is become more crucial in mobile distributed computing systems. However, sophisticated modeling methods to analyze

context-aware systems are still very few. Among those, the Colored Petri Net (CPN) is promising because it is proven to be useful for

modeling system dynamics and concurrency control in more efficient ways. However, to support managing multiple configurations of

components of context-aware applications, some features need to be added to specialize the CPNs. To address these challenges, our research

has two idea: (a) to decompose a system into several meaningful subsystems, each of which we will call a pattern, and (b) to separate context

from the patterns to realize context-pattern independence. Hence, we propose a modeling methodology to represent and analyze a context-

aware agent-based system, which tends to be highly complex. We introduce CPNs as a method of capturing the dynamics of this contextual

change. We define CPNs and a way to apply them in context-aware agent-based systems. We also describe a prototype system that we have

developed called CPN Generator, which translates CPN specification into Java programs.

q 2004 Elsevier Ltd. All rights reserved.

Keywords: Context-awareness; Colored Petri nets; Multi-agent system; Mobile distributed computing; Modeling and simulation

1. Introduction

Context-aware computing is becoming a crucial element

in mobile distributed computing systems. Context-aware

systems themselves tend to be complex mainly because the

context information is dynamic and acquired from multiple

distributed sources.

Because of this complexity, representing and analyzing

the system is quite difficult. Designers for context-aware

applications may find it difficult to enumerate the set of

contextual states, know what information could accurately

determine a contextual state within that set, and state what

appropriate action should be taken from a particular state

(Greenberg, 2001).

Context-aware systems may be categorized as routine

and recurring systems, or as non-routine or infrequent

systems. Examples of routine systems that can be automated

or programmed include reserving restaurants for dinner at a

fixed time, or library services when the user’s location is in

0957-4174/$ - see front matter q 2004 Elsevier Ltd. All rights reserved.

doi:10.1016/j.eswa.2004.06.008

* Tel.: C82-31-201-2306; fax: C82-31-204-8114.

E-mail address: [email protected].

a library. Many context-aware systems are routine.

However, because context-aware systems are exponentially

complex as the number of contextual sensors increases, it

becomes difficult to handle the system. Hence, among those

systems, we are interested in routine yet complex context-

aware systems.

Moreover, we are also interested in the separating

contextual dimension: i.e. a behavior of a system recurs

when a sort of contextual situation recurs. This implies that

if we successfully decompose a system into several

subsystems, then we will get more chances to analyze

complex context-aware systems, which might mitigate

development and maintenance costs.

However, sophisticated modeling methods to analyze or

optimize context-aware systems are still very few (Anhalt,

2001; Jersak, Henia, & Ernst, 2004; Tandler, 2004). Among

those, Petri Nets have been recognized as promising

technologies. They have been proven to be useful for

modeling system dynamics because context-aware systems

are very dynamic. Petri Nets have been typically applied to

model and analyze dynamically changing systems. More-

over, since the contextual information is acquired from

many sources such as sensors, Petri Nets will become more

Expert Systems with Applications 27 (2004) 609–621

www.elsevier.com/locate/eswa

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621610

complex as a number of contexts to consider in modeling a

system increase.

Meanwhile, context-aware systems often handled by

agent system. However, even though Petri nets have been

used to model agent systems before, experiences of

modeling agent system for context-aware system have

been very few (Burkhard, 2002; Kohler, Moldt, & Rolke,

2001; Kwon & Lee, 2001; Weyns & Holvoet, 2002).

Hence, these concerns have lead to main areas of focus in

our research: (a) to decompose a system into several

meaningful subsystems, each of which we will call pattern,

and (b) to separate context from the patterns to realize

context-pattern independence. The first aspect is not that

original; decomposition is widely considered in conven-

tional Petri Net approaches such as a hierarchical Petri Net

or an Object-oriented Petri Net (Simon, 1981). For the

second aspect, a contextual change mechanism should be

separated from the context-aware system and identified as

another dimension. By doing so, it achieves a considerable

simplification of the way complicated systems are modeled

and verified. Current Petri Net modeling approaches tend to

let the dynamics of context be implicitly embedded

somewhere in context-aware system. Typically the

dynamics are embedded in agents or stored in an

information base (Ren & McGuire, 1999). In this way,

however, the changing mechanism of contexts may not be

analyzed well.

Hence, this paper proposes a modeling methodology to

represent and analyze context-aware systems that are

routine yet complex. To explicitly capture the dynamics

of the contextual change, we newly introduce Amended

Colored Petri Nets (Amended CPNs) (Jensen, 1992).

Amended CPN is an extended net of colored and

hierarchical Petri net that supports context-awareness.

Amended CPNs consist of multiple Colored Petri Nets,

each of which we call patterns, which correspond to a

contextual state, and another dimensional Petri Net, context

net, which shows the dynamic contextual changes.

Moreover, by dividing a context-aware system into

patters and context net, to automatically generate concurrent

systems from Amended CPN specifications becomes easier.

We have developed a prototype system, CPN Generator that

converts Amended CPN into executable Java code that

includes threads that can be compiled.

The rest of this paper is organized as follows: Section

2 reviews existing research on managing context-aware

systems and Petri Nets. In Section 3, we describe how

CPN can be applied to context-aware agent modeling

with some examples. In Section 4, to show the

usefulness of the CPN, we present some modeling and

analysis of context-aware agent-based systems. In Section

5, we describe our prototype system, CPN Generator, and

show how CPN can be used to analyze context-aware

agent-based systems with experiments. Our concluding

remarks are in Section 6.

2. Literature review

2.1. Context-aware computing

As Steve Mann first used the term humanistic intelli-

gence, successful implementation has appeared since the

late 1990 (Dey & Abowd, 1999; Mann, 1998). Context is a

powerful concept in human-computer interaction. More

specifically, user context ‘is any information that can be

used to characterize the situation of an entity’ (Dey &

Abowd, 1999). Context includes but is not limited to the

location of use, the collection of nearby people and objects,

accessible devices, and changes to these objects over time. It

may include lighting, noise level, network connectivity,

communication costs, communication bandwidth, and even

social situations.

The term context-aware computing is commonly

understood by those working in ubiquitous/pervasive

computing, where it is felt that context is key in their

efforts to disperse and transparently weave computer

technology into our lives (Chen, 2003). One goal of

context-aware computing is to acquire and utilize

information about the context of a device in order to

provide services that are appropriate to the particular

people, place, time, events, etc.

Context-aware computing is becoming more crucial in

mobile distributed computing systems. These systems aim

to provide people with ubiquitous access to information,

communication and computation. For example, CAMP

(Context-Aware Mobile Portal) is a modular mobile Internet

portal enhanced with context awareness features, such as

user preferences, location and temperature (Mandato,

Kovacs, Hohl, & Amir-Alikhani, 2002). Location-aware

applications are other examples of context-awareness which

take advantage of location-awaking sensors. Some excellent

work in this area includes PARCTab at Xerox PARC (Want,

Hopper, Falcao, & Gibbons, 1992), the InfoPad project at

Berkeley (Long, Aust, Abowd, & Atkeson, 1996), the

Olivetti Active Badge system (Schilit, 1995) and the

Personal Shopping Assistant proposed at AT&T (Asthana,

Cravatts, & Krzyzanouski, 1994).

Context-aware systems have been designed to allow

current systems to take action autonomously, and to

accurately recognize the context and determine the appro-

priate action, which requires considerable intelligence

(Erickson, 2002).

Automatic contextual reconfiguration and context-

triggered actions are core categories in context-aware

applications (Schilit, Adams, & Want, 1994). Automatic

reconfiguration is the process of autonomously adding

new components and removing existing components,

based on contextual information. Context-triggered action

means that certain actions, which we define as patterns in

this paper, are activated according to the change of

context. Schilit used IF THEN rules to implement the

feature.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621 611

2.2. Modeling context-aware system

In short, sophisticated modeling methods to analyze or

optimize context-aware systems are still very few (Anhalt,

2001). However, when we regard that these systems are

likely to have an ‘event-driven’ structure, where context

changes are represented as events. Therefore, event-driven

modeling methods can potentially be adopted in modeling

context-aware systems.

Typically, Petri net has been regarded as excellent to

model and verify dynamic and event-based system. Based

on this reputation and capability, Petri nets is believed to be

very appropriate in modeling context-aware system, which

is a sort of dynamic system. Among those, Trellis, based on

colored, timed Petri nets, has been written about extensively

(Furuta & Stotts, 2000; Zurawski & Zhou, 1994). The goal

of Trellis was to explicitly visualize the semantics of a

system rather than the system implementation. Trellis

associates content with places and links with transitions;

when a place is marked, the corresponding content is

displayed. caT(Context-Aware Trellis) is an extension to

Trellis that support context awareness (Na & Furuta, 2000).

However, the main focus of caT and Trellis were modeling

hypermedia-based context-awareness. So far they are not

applied to system modeling under multiple contexts.

Moreover, dealing with dynamic change of context-aware

system configuration has not been addressed yet.

Statecharts is an alternative of Petri net. Statecharts has

been used to model hierarchy and synchronization of

information, and provide mechanisms for specifying access

structures, access controls, multiple tailored versions, and

hierarchical views. These features allows verification of

system reachability and valid paths (Harel, 1987). In

general, statechart-based systems do not support adaptive,

shared readings of a statecharts specification since there is

no identity of each reader (like colored token markings in

Petri nets) in the specification. Therefore, they may not be

appropriate for the authoring of adaptive hypertext docu-

ments, including cooperative documents (Na, 2001).

Operator graph is the dynamic combination of all

applications’ subscription trees (Chen and Kotz, 2002).

Here, an operator is an object that subscribes to and

processes one or more input event streams, and publishes

another event stream. The operator graph consists of three

kinds of nodes: sources, operators, and applications. The

sources have no subscriptions. They are wrappers for

context sensors. Operators are functions of their input

events and only publish events when they receive an input

event. Applications are sinks of the graph. However, the

operator graph does not describe inside of the applications,

which we will represent them as patterns. Even though the

graph is more on modeling context-aware system by

identifying specific components such as sensors and event

stream, the graph is too simple to be used to generate

applications or even analyze the applications.

2.3. Colored Petri nets

CPNs model is capable of description and analysis of

large and complex systems Even the model size problem,

which obstructs the wider use of Petri nets, can be resolved

by CPNs, because color in a CPN refers to the type of data

associated with tokens and is comparable to data type in

programming languages (Yan & Gan, 2001). CPNs have

typically been used to represent and estimate agent

behaviors, since the Petri Net is a natural representation

for parallel action and synchronization (Yen et al., 2001).

CPN offers two mechanisms that are of special interest

for architectural modeling. First is the flexibility of token

definition and manipulation. It is possible to use tokens to

model various contextual elements such as weather,

location, etc. Second is the concept of sub-page. Sub-

pages can be used as a module definition mechanism for

various purposes (Xu & Kuusela, 1998).

A well-formed net CPNZhS,P,T,A,N,C,G,E,Ii is made

of:

S is a finite set of non-empty types, called color sets.

P is a finite set of places.

T is a finite set of transactions.

A is a finite set of arcs such that: PhTZPhAZThAZF

N is a node function. It is defined from A into P$TZT$P.

C is a color function. It is defined from P into Si.

G is a guard function. It is defined from T into

expressions such that: ct 2T : ½TypeðGðtÞÞZBoTypeðVarðGðtÞÞÞ4S�:

E is an arc expression function. It is defined from A into

expressions such that:ca2A : ½TypeðEðaÞÞZCðpðaÞÞMS

oTypeðVarðEðaÞÞÞ4S� where p(a) is a place of N(a).

I is an initialization function. It is defined from P into

closed expressions such that: cp2P : ½TypeðIðpÞÞZCðpÞMS�

3. Amended colored Petri nets for context-aware agent

modeling

We have incorporated CPN to model and analyze multi-

variant context-aware systems more efficiently. Amended

CPN is an extension of CPN by partially adopting

hierarchical Petri net. The term ‘amended’ comes form

the intuition that the context-aware system is like a piled

slides, each of which is a pattern of service or life. For

example, in case of campus life, John like sunny day and

when it is sunny, he is more likely to get out of the library

and play tennis. He usually is at home to watch TV and cook

for himself on the gloomy holiday. When he is out of

campus with his friend, he used to go to the movie and have

dinner in a splendid restaurant. Even though these patterns

may be look like so complicated if we regard contexts as

Fig. 1. Overview of Amended CPN.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621612

random and hence too complicated, our routine life such as

activities on campus unexpectedly consists of a finite set of

patterns. The pattern of contextual changes is beyond the

patterns, which need to be identified as different dimension.

However, the flow of this dimension is not simply sequential

like time dimension, we will represent the flow as an

independent CPN: a context net. Therefore, 3D is composed

of two-dimensional patterns and one additional dimension

on contextual change, all of which are represented as CPNs.

An overview of Amended Colored Petri net (Amended

CPN) is shown in Fig. 1. The Amended CPN consists of one

context net (NC) and one, or two, or more patterns

(PATTERN).

We give the definition of Amended CPNs and formalize

the enabling and firing of a transition instance.

Definition 1. Amended CPN is a well formed netZhNC,PATTERN1,PATTERN2,.PATTERNni

Definition 2. Context net NC is a well formed CPNZhXC,SC,PC,TC,AC,NC,CC,GC,EC,ICi satisfying the

requirements below:

XC is a set of context providers.

SC is a finite set of non-empty types, called color sets

such that: SC4gniZ1Si:

PC is a finite set of places such that: c i, PChPiZF.

TC is a finite set of transactions such that i, TChTiZF.

AC is a finite set of arcs such that: ACZAC0 CAC

1 CAC

2 C/CACn where AC

0 satisfies: PChTCZPChAC0 Z

TChAC0 ZF and c iR1, AC

i satisfies: ci;PihTCZPi hAC

i ZTChACi ZF

NC0 is a node function. It is defined from AC

0 into

PC$TCZTC$PC.

c iR1,NCi is a node function. It is defined from AC

i into

Pi$TCZTC$Pi.

CC is a color function. It is defined from PC into SC.

GC is a guard function. It is defined from TC into

expressions such that: ct 2TC : ½TypeðGCðtÞÞZBCoTypeðVarðGCðtÞÞÞ4SC�:

EC is an arc expression function. It is defined from AC

into expressions such that: ca2AC : ½TypeðECðaÞÞZ

CCðpðaÞÞMS oTypeðVarðECðaÞÞÞ4SC� where p(a) is a

place of NC(a).

IC is an initialization function. It is defined from PC into

closed expressions such that: cp2PC : ½TypeðICðpÞÞZCCðpÞMS�:

The context net is a pattern of pattern changes. It is

essential for developing large-sized context-aware appli-

cations with Petri net since it reduces graphical complexity

problems that are common to graph-based modeling tools.

Definition 3. PATTERNi is a well formed CPNZhSi,Pi,Ti,

Ai,Ni,Ci,Gi,Ei,Iii satisfying the requirements below:

Si is an ith finite set of non-empty types, called color sets.

Each of color has its brightness and chroma.

Pi is an ith finite set of places.

Ti is an ith finite set of transactions.

Ai is an ith finite set of arcs such that: PihTiZPihAiZTihAiZF

Ni is an ith node function. It is defined from Ai into Pi!TiZTi!Pi.

Ci is an ith color function. It is defined from Pi into Si.

Gi is an ith guard function. It is defined from Ti into

expressions such that: ct 2Ti : ½TypeðGiðtÞÞZBioTypeðVarðGiðtÞÞÞ4Si�

Ei is an ith arc expression function. It is defined from Ai

into expressions such that: ca2Ai : ½TypeðEiðaÞÞZCiðpðaÞÞMS oTypeðVarðEiðaÞÞÞ4Si� where p(a) is a

place of Ni(a).

Ii is an ith initialization function. It is defined from Pi into

closed expressions such that: cp2Pi : ½TypeðIiðpÞÞZCiðpÞMS�:

The Amended CPN has enhanced properties in addition

to the one it shares with the CPN and typical hierarchical

Petri nets as follows:

Context providers. To explicitly specify the source of

contexts involved, context providers are added to the

context net. A provider can be a component, web service,

or agent. In the net, only the names of providers will be

specified: the interfaces of invoking the context providers

are defined in a separate document.

Initiate/terminate arc. Context net and patterns are in

themselves CPNs, between which are connected with

initiate/terminate arcs. According to the change of

contexts, the context net at any times can initiate or

terminate patterns. In case of these changes, current

tokens of the patterns are disappeared at once when the

patterns are terminated by the context net. The

Initiate/terminate arcs are represented as dotted arrows.

Brightness and chroma in color token. Privacy concern is

very crucial to develop context-aware applications

because it becomes more possible to detect private data

using context-aware sensors such as user location,

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621 613

calendar, activity, etc. Hence, sometimes there are trade-

offs between system efficiency and security. Especially,

when we consider agent-based autonomous system, the

access levels must be different according to the mission

of the agents: user specific agent may have more access

right than general task specific agents. Thus, to stress the

importance of privacy concern, context data (chroma)

and privacy-related data (brightness) are identified in the

Amended CPN.

4. Modeling agent-based context-aware systems

with amended CPNs

4.1. Context-aware agent architecture

Fig. 2 shows the context-aware agent architectures of a

mobile service.

The user agent resides in a mobile device or desktop

computer of a corresponding user and communicates with

other servers via a wireless or wired network connection. A

database server manages the user’s ‘e-wallet.’ A user may

create his/her own resource query agents, as well as task

specific agents if necessary. If so, a corresponding agent

generator on a server generates skeleton code, which is

refined through the communication between user agent and

the generator. It is natural that the task specific agents will

be distributed in the world; therefore, these agents can reside

on many different servers (as indicated in Fig. 2). Context

agents, however, are placed in one server for efficiency

reasons.

Fig. 2. Agent-based Mobile

The context agents will:

Ser

allow task specific agents to register and maintain

membership lists,

query contextual information from outside, if available,

monitor contextual information: e.g. location, social

context, and weather,

retrieve contextual information from the e-wallet, a

working memory, and

send contextual information to a task specific agent.

The task specific agent will:

receive requests from the user interface at any time, and

plan how to resolve the problem.

The agent server has its own generator with an agent

template. When a user wants to create his/her own agent, the

generator recevies specifications from the user and gen-

erates agent codes by putting the specifications into the

agent template.

4.2. Amended CPN modeling

Let us give a scenario on mobile campus Members of the

community engage in a broad range of activities from

working and studying to socializing, practicing sports,

attending a variety of events, shopping, eating, etc.

Information relevant to these activities is accessible through

a variety of online services. Students living in dorms often

go for several days or longer without leaving campus. The

diversity of campus life, related Internet services, and the

time spent by many members of the community on campus,

vice Architecture.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621614

makes it a particularly rich and challenging environment

when it comes to supporting context-aware mobile services.

The services, which are being made accessible from PDAs

over Carnegie Mellon’s wireless LAN, combine location

information (using location-tracking technology running on

top of the wireless LAN), calendar information, weather

information, social context information along with personal

preferences, including context-sensitive preferences (e.g.

“When in class, I don’t want to be disrupted by promotional

messages”, “When it rains, I don’t like to go out”, “If it’s

sunny and past 4pm, I’m happy to have members of my

volleyball team see where I am on campus”).

Three contexts are assumed to exist: location, social, and

weather. They are identified as colors in Amended CPN, and

therefore context is a set of them. Contextual information

can be represented as a set of colors as follows:

Fig

the

Color LocationZ{(on, off, *), (high)};

Color SocialZ{(alone, accompanied, *), (moderate)};

Color WeatherZ{(sunny, gloomy, *), (low)};

Color ContextZLocation * Social * Weather;

Var lZLocation;

Var sZSocial

Var wZWeather;

The first element of the color is a set of case of the

corresponding context, which we call chroma in Amended

CPN. For example, (on, alone, sunny) means that the user is

now on campus alone and the weather is sunny. The ‘*’

indicates that there is no change of corresponding color. For

example, (on, alone, *) means that weather is not changed:

(on, alone, *) can be (on, alone, sunny) or (on, alone,

gloomy). Hence, (*,*,*) indicates that there is no contextual

change at all. The second element of the color is a level of

permission, which we declare as brightness. The value is

varying according to the user who will be served by the

context-aware application.

The relationship between contexts, patterns, and agents

are shown in Fig. 3. As seen, pattern identification and

. 3. Relationship among context net, patterns, and task specific agents in

example application.

triggering task agents are determined by contexts in context

net, which is a set of events.

The number of contexts in our system is 2*2*2Z8.

Among those, we assume that in case of two contexts (off,

alone, sunny) and (off, accompanied, sunny) there is no

pattern change. Let us assume there are four patterns in our

system. Pattern(pZ1) indicates typical student life on

campus. Pattern(pZ2) assumes that the user is accompanied

with his/her friend. Pattern(pZ3) happens when the user is

off campus on a sunny day. They will go picnic by car or go

to restaurant for dinner and go to movie with friends. When

the user is alone and the weather is gloomy, the user will be

at home to cook or watch TV (Pattern(pZ4)). Let us assume

that four agents are connected with our system: Librarian,

Restaurant Concierge, TV Guide, and Cook Guide.

Fig. 4 shows how the communications of the agents

shown in Fig. 2 is represented as a Amended CPN.

The internal behavior of a transition in a task specific

agent may be active or passive. An active transition, colored

gray in Fig. 4, performs a service for a subscribing user, the

results of which will be applied to the corresponding user

interface. For example, a task specific agent ‘TV Guide’ in

Pattern(pZ4) is active if the transition performs a TV Guide

or program reservation function. A passive transition, on the

other hand, does nothing but delay the time with a

distribution function.

4.3. Conversion of Amended CPN into java code

To make the Amended CPN specification executable, we

adopted a translation approach to automatic programming

We choose Java as a programming language since it is

outstanding in representing concurrent systems, such as

context-aware systems. The basic mapping from Amended

CPN to Java code for the agent is briefly listed in Table 1.

The main parts of the Java code are initiator, context net,

and patterns. In more detail, the pseudo-code of generating

Java code with Amended CPN shown as follows:

Component[1]: Generate initiator

Inputs: number of contexts(context, contextproperty) name of context number of properties of each context interarrival time probability of the contexts(context,context property) Outputs:

mapping function (context)

context information (context_name,num_of_context_properties,interarrival_time) Logic: Get num_of_contexts; Loop (i!Znum_of_contexts)

Fig. 4. Amended CPN for the interaction of the agent architecture shown in Fig. 2.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621 615

{Get context_information(context_name, num_of_context_properties,interarrival_time);Loop (j!Znum_of_context_properties[i]){Color[i,j]ZGetcontext_property[i,j];Get mapping_function;Get context_probability[i,j];

}

}

Component[2]: Generate Context net

Inputs:

Name of contexts

Number of contexts

Color

Interarrival time

Probability of the contexts(context,context property)

Mapping function (context)

Table 1

Outputs: From Amended CPN to Agent Java code Context net code

Amended CPN Java program

Initiator code

Color Parameters (contextual information)

Logic:

Transition Thread run, wait, notify

//Generate Context_net Arc from place to transition Thread ready

Arc from transition to place Thread dead

Node function Control statement

Pattern name Initiator class

{Initiator.generate(name_of_contexts,num_of_context);Context[i].generateThread(Color,

context_probability,,interarrival_time);ContextNet.generate(Color,MappingFunction);

}

Component[3]: Generate patterns

Inputs:

Number of patterns

Number of agents

Name of agents

Service time distribution

Pre-condition

Post-condition

Agent information

Outputs:

Pattern codes

Agent behavior code (not agent program)

Logic:

//Generate Patterns

Get num_of_patterns;

Fig. 5. Example generated pseudo code (Pattern(pZ4)).

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621616

Loop (k!Znum_of_patterns)

{Get num_of_agents;Loop (m !Znum_of_agents){Get agent_information(name_of_agent, service_time_distribution,pre-condition, post-condition);agent[m,k].generateThread(agent_information);

}pattern[k].generate(name_of_agent);

}

For example, the Pattern(cZ4) and the TV Guide service

working in the pattern can be transformed to the Java codes

as shown Figs. 5 and 6, respectively.

Note that the generated Java code actually does not

perform service for actual user, the Java code is a simulator

for the efficient design of a target context-aware application.

Therefore, the agent code does not contain any service

logics but has simulation-related information such as time

distribution function.

Fig. 6. Example generated pseudo code of

4.4. Concurrency

One of the important aspects of verifying context-aware

system is concurrency test. Petri Nets (PNs) are one of the

best ways to represent concurrency. (Agha, Cindio, &

Rozenberg, 2001; Donatelli & Kleijn, 1999; Shen, Norrie, &

Barthes, 2001). PNs have proven to be useful for describing

concurrent interrelated activities (Schach, 1997). Research-

ers have proposed Petri Nets (Murata, 1989) as a framework

to model concurrency and contention. In recent years,

substantial progress has been made in the theory and

application of PNs. Petri Nets have also been applied to

static analyses examining behavioral characteristics of

systems (Murata, Shenker, & Shatz, 1989; Shatz &

Cheng, 1988; Shatz & Murata, 1990), to dynamic analyses

evaluating a proposed system’s performance (Marsan, 1989;

Molloy, 1982), and to system complexity measurement

impacting the assessment of system quality (Shatz, 1990)1.

In Java, concurrency is modeled with threads. Java

uses shared memory as the basic model for communi-

cations among threads. In addition, threads can affect the

execution of other threads in a number of other ways,

TV Guide agent in Pattern(pZ4)).

Fig. 7. Structure of Java programs generated by Amended CPN Generator.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621 617

such as dynamically starting a thread or joining with

another thread, which blocks the caller thread until the

other thread finishes.

To implement a Java-based system, it is natural to apply

Petri Nets as a specification tool (Schach, 1997). This means

Fig. 8. Example Interface of A

that Petri Nets may be transformed into Java source code.

Thus, we use a semi-automatic transformation approach to

implement concurrency of context-aware systems.

5. Amended CNPGenerator: implementation

We developed a prototype system, Amended CPN

Generator, to generate Java code, especially Java threads,

based on Amended CPN specifications. Our proposed

prototype was implemented using Java application under

JDK1.3.1 on a PC platform. The module of the Java

programs generated by Amended CPN Genreator is shown

in Fig. 7. The main module, initiator, declares color token

types and its’ properties to generate threads of the

service providers: WeatherMan, LocationGuide, and Social.

The gray-colored unit indicates a context provider. Then the

module runs context net program. The context net receives

the contextual data from the providers and figure out

whether contexts are changed. If any changes detected, then

the context net triggers corresponding patterns and submits

tokens with parameters: number and content of contexts,

and timestamp. The patterns begin to run when token arrives

gent Communication.

Fig. 9. Example change of workload of agents.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621618

from context net, and eventually triggers task agents as

threads by sending messages on context of context. Since

the agent program here is just a part of simulator, the

program does not actually perform anything on behalf of

the user: the task agent only contains time like ‘Thread.-

Thread.sleep(estimated service time)’ and security check

logics. The task agent program put log data to the

system logs for simulation analysis. Examples of generated

source code for Java-based simulators are listed in

Appendix A.

An example interface of agent communication using

compiled Java programs is shown in Fig. 8. Restaurant

Concierge system, an example prototype system of

MyCampus built by Carnegie Mellon University, is

selected as a domain context-aware system (Sadeh,

Chan, Van, Kwon, & Takizawa, 2003). The number

after ‘at’ is a timestamp, and number within ‘( )’ is time

of a corresponding agent is created. The timestamp is

generated by Java.

Scenario-based analyses are performed as the input

parameter values are changed. For example, we can observe

the effect of a user’s mobility on agent workload as we

change the distribution function for the location-changing

probability. Fig. 9 shows the how the ratio of being off

campus affects the workloads of the four agents: librarian,

restaurant concierge, TV guide, and cook guide as shown in

Figs. 4 and 7.

The workload analysis also enables the load balancing of

the agents in the application to be developed, by considering

the number of users to be served, network configurations,

Fig. 10. Example comparison of workload.

and the capabilities and numbers of all agents. For example,

in cases where we increment the number of Librarian agent

to two, the workload of the agent is changed also, as shown

in Fig. 10:

This analysis will contribute to the scalability of the

system.

6. Concluding remarks

The main contribution of this paper to research is to

apply a refined Petri net, Amended CPN, to context-aware

system modeling and analysis. Amended CPN aims to

represent the status and transition of a context aware system

and decompose the modeling into a context net and pattern

nets. By using Amended CPN, we found several advantages.

Firstly, we can explicitly visualize the dynamics of contexts

and patterns more efficiently. The context and patterns are

separated and implemented at different dimensions. Sec-

ondly, Amended CPNs provide more straightforward and

effective techniques to ensure context-aware behavior.

Lastly, concurrency is well-detected by Amended CPNs.

Amended CPNs are expected to be beneficial in

formulating and evaluating strategies in electronic and

mobile commerce. In real situations, individuals, groups or

organizations may have several behavior patterns or

strategies. The patterns and strategies are changeable

according to the dynamic change of contextual stimulus.

The strategic planning taking contextual information into

account is crucial for negotiation and coordination in

electronic commerce. This kind of competition2 naturally

leads us to think of the fitness to the contextual environment

when formulating strategies or policies and making

decisions. Hence, it should be quite useful to investigate

how an organizational unit is matching their own strategies

to the contextual change, and then to evaluate how well the

matches are working. Since Amended CPNs can provide

context-pattern independence, it allows investigation and

evaluation to be more efficient.

It is our view to connect between contexts and Amended

CPN states, which make it possible to take the step from a

model to a executable code: Java program. To realize this,

we have developed a prototype system, Amended CPN

Generator, which leads the Amended CPN to be useful

enough to be used to generate context-aware agent-based

systems. This approach would provide scalability of the

Amended CPN coping with the dynamic nature of context-

aware system. However, performance evaluation of the

agent systems generated by Amended CPN Generator has

not been performed yet since it is outside the scope of our

research. Detailed agent behavior has also been omitted in

our prototype since its main mission is how Amended CPNs

can be used to model context-aware agent-based systems.

These remain as a part of future works.

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621 619

Appendix A. Generated Codes

(1) Sample Java code of Initiator

public class Initiator {

static int systimeZ0;

static int tcolor[ ]Znew int[4];public static void main(String args[ ]){tcolor[1]Z1;tcolor[2]Z1;tcolor[3]Z1;

HoldIntegerUnsynchronized hZnewHoldIntegerUnsynchronized( );LocationGuide lZnew LocationGuide(h, systime, tcolor);WeatherMan wZnew WeatherMan(h,systime, tcolor);Social sZnew Social(h, systime,tcolor);l.start( );w.start( );s.start( );

}

}

(2) Sample Java code of ContextNet

public class ContextNet {public static void run(int c_num, intcont[ ], int t){if (cont[1]ZZ1) && (cont[2]ZZ1)Pattern1.run(c_num, cont, t);

if (cont[1]ZZ1) && (cont[2]ZZ2)Pattern2.run(c_num, cont, t);}

if ((cont[1]ZZ2) && (cont[2]ZZ2)&& (cont[3]ZZ1))Pattern3.run(c_num, cont, t);

if ((cont[1]ZZ2) && (cont[2]ZZ1)&& (cont[3]ZZ2))Pattern4.run(c_num, cont, t);

}

}

(3) Sample Java code of context

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621620

(4) Sample Java code of Agent

O. Byung Kwon / Expert Systems with Applications 27 (2004) 609–621 621

References

Agha, G. A., Cindio, F. D., & Rozenberg, G. (2001). Concurrent object-

oriented programming and Petri Nets: advances in Petri Nets. Berlin:

Springer.

Anhalt, J. (2001). Toward context-aware computing: experiences and

lessons. IEEE Intelligent Systems, 16(3), 38–46.

Asthana, A., Cravatts, M., & Krzyzanouski, P. (1994). An indoor wireless

system for personalized shopping assistance. In L. F. Cabrera, &

M. Sattyanarayanan (Eds.), Workshop on mobile computing systems

and applications.

Burkhard, H. D. (2002). Software-architectures for agents and mobile

robot. Fourth Workshop and Tutorial on Practical Use of Coloured Petri

Nets and the CPN Tools (MOCA’2002).

Chen, G., & Kotz, D. (2002). Context aggregation and dissemination in

ubiquitous computing systems. Proceedings of the Fourth IEEE

Workshop on Mobile Computing Systems and Applications , 105–114.

Chen, H. (2003). An intelligent broker architecture for context-aware

systems. PhD dissertation proposal, the University of Maryland

Baltimore County, USA.

Dey, A. K. &, Abowd, G. D. (1999). Towards a better understanding of

context and context-awareness, GVU tech. rep. GIT-GVU-99-22,

College Comp., GA Inst. Tech.

Donatelli, S., & Kleijn, J. (1999). Application and theory of Petri nets.

Proceedings of the ICATPN’99, Williamsburg, Virginia, USA , USA.

Erickson, T. (2002). Some problems with the notion of context-aware

computing. Communications of the ACM, 45(2), 102–104.

Furuta, R., & Stotts, P. D. (2000). Trellis: a formally-defined hypertextual

basis for integrating task and information. In G. M. Olson, J. B. Smith,

& T. W. Malone (Eds.), Coordination theory and collaboration

technology.

Greenberg, S. (2001). Context as a dynamic construct. Human–Computer

Interaction, 16, 257–268.

Harel, D. (1987). Statecharts: a visual formalism for complex systems.

Science of Computer Programming, 8(3), 231–274.

Jensen, K. (1992). Coloured Petri nets: basic concepts, analysis methods

and practical use volume 1. New York: Springer.

Jersak, M., Henia, R., & Ernst, R. (2004). Context-aware performance

analysis for efficient embedded system design. Design, Automation and

Test in Europe Conference and Exhibition Volume II (DATE’04), Paris,

France, 16–20.

Kohler, M., Moldt, D., & Rolke, H. (2001). Modelling the structure and

behaviour of Petri net agents. Proceedings of 22nd International

Conference on Applications and Theory of Petri Nets, 224–242.

Kwon, O. B., & Lee, J. J. (2001). A multi-agent intelligent system for

efficient ERP maintenance. Expert Systems with Applications, 21(4),

191–202.

Long, S., Aust, D., Abowd, G. D., & Atkeson, C. G. (1996). Rapid

prototyping of mobile context-aware applications: the cyberguide case

study. Proceedings of the 1995 conference on Human Factors in

Computing Systems—CHI’96, 1995, 96.

Mandato, D., Kovacs, E., Hohl, F., & Amir-Alikhani, H. (2002). CAMP: a

context-aware mobile portal. IEEE Communications Magazine, 40(1),

90–97.

Mann, S. (1998). Humanistic intelligence: ‘WearComp’ as a new frame-

work and application for intelligent signal processing. Proceedings of

the IEEE, 86(11), 2123–2151.

Marsan, M. (1989). The effect of execution policies on the semantics and

analysis of stochastic Petri nets. IEEE Transactions on Software

Engineering, 15(7), 832–845.

Molloy, M. (1982). Performance analysis using stochastic Petri nets. IEEE

Transactions on Computers, C-31(9), 913–917.

Murata, T. (1989). Petri Nets: properties, analysis and applications.

Proceedings of the IEEE, 77(4), 541–580.

Murata, T., Shenker, B., & Shatz, S. (1989). Detection of Ada static

deadlocks using Petri net invariants. IEEE Transactions on Software

Engineering, 15(3), 314–326.

Na, J. C., & Furuta, R. (2000). Context-aware hypermedia in a dynamically-

changing environment, supported by a high-level Petri net. Proceedings

of the 11th ACM on Hypertext and Hypermedia , 222–223.

Na, J. C. (2001). Context-aware hypermedia in a dynamically changing

environment, supported by a high-level Petri net. PhD Dissertation,

Texas A&M University.

Ren, A., & McGuire, G. Q. (1999). A smart network with active services for

wireless context-aware multimedia communications Emerging technol-

ogies symposium on wireless communications and systems, Dallas, TX.

Sadeh, N. M., Chan, T. C., Van, L., Kwon, O. B., & Takizawa, K. (2003).

Creating an open agent environment for context-aware M-commerce. In

Burg, Dale, Finin, Nakashima, Padgham, Sierra, & Willmott (Eds.),

Argentcities: Challenges in open agent environments, LNAI (pp. 152–

158). Berlin: Springer.

Schach, S. R. (1997). Software Engineering with Java. Irwin.

Schilit, B. N., Adams, N., & Want, R. (1994). Context-aware computing

applications. Proceedings Workshop on Mobile Computing Systems and

Applications, 85–90.

Shatz, S., & Cheng, W. (1998). A Petri net framework for automated static

analysis of Ada tasking behavior. Journal of Systems and Software, 8,

343–359.

Shatz, S. (1990). Design and implementation of a Petri net based toolkit for

Ada tasking analysis. IEEE Transactions on Parallel and Distributed

Systems, 1(4), 424–441.

Shen, W., Norrie, D. H., & Barthes, J. A. (2001). Multi-agent systems for

concurrent intelligent design and manufacturing. Florence, KY: Taylor

and Francis.

Schilit, W. N. (1995). System architecture for context-aware mobile

computing. PhD thesis, Columbia University.

Simon, H. A. (1981). The sciences of the artificial. Cambridge, MA: MIT

Press.

Tandler, P. (2004). The BEACH application model and software frame-

work for synchronous collaboration in ubiquitous computing environ-

ments. Journal of Systems and Software, 69(3), 267–296.

Tu, S., Shatz, S., & Murata, T. (1990). Applying Petri net reduction to

support Ada tasking deadlock detection. Proceedings of the 10th

International Conference on Distributed Computing Systems, 96–103.

Want, R., Hopper, A., Falcao, V., & Gibbons, J. (1992). The active badge

location system. ACM Transactions on Information Systems, 10(1), 91–

102.

Weyns, D., & Holvoet, T. (2002). A coloured petri net for a multi agent

application. Fourth Workshop and Tutorial on Practical Use of

Coloured Petri Nets and the CPN Tools (MOCA’2002).

Xu, J., & Kuusela, J. (1998). Modeling execution architecture of software

system using colored Petri nets. Proceedings of the first international

workshop on Software and performance, Santa Fe, New Mexico, United

States, 70–75.

Yan, Z., & Gan, R. (2001). Modeling of SET protocol based on UML and

colored Petri net. Proceedings of the ICII, Beijing, 6, 124–129.

Yen, J., Yin, J., Loerger, T. R., Miller, M., Xu, D., & Volz, R. A. (2001).

CAST: collaborative agents for simulating teamwork. Proceedings of

the Seventeenth International Joint Conference on Artificial Intelli-

gence (IJCAI-01), Seattle, WA, 1135–1142.

Zurawski, R., & Zhou, M. (1994). Petri nets and industrial applications: a

tutorial. IEEE Transactions on Industrial Electronics, 41(6), 567–583.