Resource Driven Automata Nets 1. Introduction

6 downloads 0 Views 651KB Size Report
10 shows a a model of a doorman, conducting philosophers to the park and back to ... A different variant of a doorman and a doorway is more compact (Fig. 11).
223

Resource Driven Automata Nets Vladimir A. Bashkin∗ Yaroslavl State University Yaroslavl, 150000, Russia [email protected]

Irina A. Lomazova∗ Dept. of Software Engineering, Higher School of Economics Moscow, 105187, Russia i [email protected]

Abstract. A new formalism of Resource Driven Automata Nets (RDA-nets) is presented. A RDAnet has two levels: a system level is represented by a net of active resources, describing distribution of agents/resources and their interactions; agents in an object level are finite automata, communicating via ports and shared resources of a system level. RDA-nets are assigned for modeling mobility in multi-agent systems from the resource dependence perspective. We prove that RDA-nets have the same expressive power as Petri nets and give examples of modeling agent communications, dynamics and mobility. Keywords: multi-agent systems, Petri nets, automata, communication, mobility

1.

Introduction

Modeling distributed multi-agent systems with interacting mobile agents is a topical problem, actively studied in the literature. One of the most common formalisms for modeling distributed systems is a Petri net. However, the structure of classical Petri nets is static and not convenient for modeling complex dynamic multi-agent systems. To handle this, several formalisms were developed, providing their own

224

specific ways of dealing with a concept of an agent ([10, 7, 8, 9, 2, 4, 5]). Most of them use a “netwithin-net” approach, allowing to replace a Petri net token by a more complex object (a net). One of crucial points in representing distributed agents is modeling agent-agent communications. Two types of agent interactions can be recognized: the first is a direct interaction via synchronization of events or message passing, and the second is indirect interaction via persistent, observable changes to the common environment, specifically a resource sharing. The latter one, looking quite “Petri-Nets-stylish”, however, is not widely used in nets-within-nets formalisms. We think that the reason for this is in some sense a syntactical inconvenience. This would require a sophisticated syntax, for example, a notion of specialized communication ports [9], or results in Turing power models, like in [5]. The structure of a Petri net is explicitly divided into two classes of elements: places and transitions. Places correspond to the passive component of the system (resources), transitions – to it’s active component (actions / events / agents). However, this is not the only way of Petri net graphical representation – there can be nets without places or transitions. In [6] K.Lautenbach introduced a notion of dual place/transition nets, where transitions are marked by special tokens just as places. So, a place in a net can be enabled and fired in the dual way. In [3] M.K¨ohler and H.R¨olke introduced Super-Dual nets for modeling dynamic refinement of events. In this formalism transitions are also marked by special tokens called “pokens”, but these pokens enable transition firings. Places in Super-Dual nets can also fire. In [1] we introduced nets of active resources (AR-nets), which can be considered as a dualized definition of a Petri net. In Petri nets there are two types of nodes, while in AR-nets there are untyped nodes and two types of arcs: input arcs and output arcs. Each node in an AR-net may contain tokens. A token in a node may fire, consuming some tokens through input arcs and producing some other tokens through output arcs. So the same token may be considered as a passive resource (produced or consumed by agents) as well as an active agent (producing or consuming resources). It was proved that AR-nets are expressively equivalent to Petri nets. However, the specific syntax provides the specific modeling perspective feasible for straight representing mobile and dynamic resources. In this paper we extend AR-nets in the line of net-within-net approach to Resource Driven Automata Nets (RDA-nets). A RDA-net has two levels. A system level is defined by a flat AR-net. Tokens in nodes of a system net are agents, represented by finite automata. During its run an agent may consume and produce local resources, being simultaneously a potential resource for its neighbors. Thus a system net can be considered as a “map” with roads (arcs) labeled by input and output ports connecting different system nodes. The agent may use these arcs to interact with system resources (produce/consume), residing in adjacent nodes. So an agent may natively produce/consume/copy/move other agents through these ports (or even use itself as a resource). Generally speaking, the net-within-net approach can be systematically applied to AR-nets by defining multilevel systems: AR-nets with tokens being AR-nets. Here we restrict systems to two levels and reduce tokens to finite automata. The ground for this is that RDA-nets are enough expressive and applicable in modeling aspects and, at the same time, are expressively equivalent to Petri nets, thus meeting decidability of typical net problems. Note, that contrary to the reference semantics for object nets considered in [10, 4, 2, 9] in RDA-nets agents are not “spreaded on” a system net, but reside in a concrete place as in Nested Petri nets [7, 8]. The paper is organized as follows. In section 2 we present the motivating example of a multi-agent system (a classical problem of Dining Philosophers and introduce our new modeling method. In section 3 we recall the definitions of Petri nets and nets of active resources. In section 4 we give formal definitions

225

 



$&%('&)+* ,

  

 

!" #



z|{~}CE€ ‚VƒR„(…=†ˆ‡=‰Š ‹CŒEŽ

-./01

 

´¶µ·[¸ˆ¹Vº¼»½¿¾ÁÀÂÄÃÅTÆÈÇÊÉ=ˈÌnÍ=Î

Figure 1.

3 4 56 7 89 : ;=@? ACBED(FEG

H I JKL M N OPRQTSVURWYX[Z]\C^E_T`Ea

bdcfeCgEh i jkRlnmpoqCrtsu vCwExty ’‘“”ˆ• –—C˜V™dš›fœž ŸV ¢¡£n¤p¥C¦§(¨©dª=«C¬­&®¯t° ±T² ³

Dining philosophers – informal representation

of RDA-nets and their semantics. Then in subsection 4.2 we discuss modeling facilities of RDA-nets. In subsection 4.3 it is proved that RDA-nets are expressively equivalent to Petri nets. Section 5 contains a more elaborate modeling with the new formalism: we continue to study a problem of dining philosophers and it’s modifications with RDA-nets.

2.

Motivation

Let us consider a well-known Dining philosophers problem. This classical problem, being quite simple, comprises all basic elements of distributed systems: sequential and parallel composition, choice, conflict and synchronization. Philosophers (in our case, there are four of them) are sitting at a dinner table with a common dish of spaghetti in the middle. Between each of two philosophers there is a fork on the table. Spaghetti can be eaten only with two forks, so there is a potential conflict between neighbors. Each philosopher can be in one of four states: he is either Thinking (having no forks), Eating (having two forks), having a fork only in his right hand (RFork), or only in his left hand (LFork). In the state Eating the philosopher can also perform an action “eat” (taking spaghetti from the dish). Consider an informal graphical representation of the problem in Fig. 1. The left part of the picture shows the “spatial” distribution of places (chairs, forks and spaghetti) on a specific “map”. The right part represents a behavior of a single philosopher as a simple transition diagram. A classical Petri net modeling of this problem is shown in Fig. 2. In some way it is obtained by “flattening” the model via incorporating fragments, representing philosopher’s behavior, into the system scheme. The model is obviously not agent-oriented. To overcome this deficiency a number of high-level techiques, using a “net-within-net” concept, were introduced such as [2, 4, 7, 9, 10]. Compare this model with a two-level nested Petri net representation of the problem in Fig. 3. Here we introduce a separate “object level” of the system – an object net phi . Objects transitions are synchronized with system transitions by the use of special synchronization labels: for example, the transition, labeled

226 K4L6MHNPO 0 (the node v is not empty) and ∀w ∈ V M (w) ≥ I(w, v) (there are enough tokens in all it’s input nodes). An active node v may fire yielding a new marking M 0 s.t. ∀w ∈ V M 0 (w) =def M (w) − I(w, v) + O(v, w). Some definitions and notions: Let i ∈ I and i = (v1 , v2 ). Then the arc i is called an input arc for the node v2 and a consuming arc for the node v1 . A token in the node v1 may be consumed through the arc i, a token in the node v2 can consume through the arc i. Let o ∈ O and o = (v1 , v2 ). Then the arc o is called an output arc for the node v1 and a producing arc for the node v2 . A token in the node v1 can produce through the arc o, a token in the node v2 may be

230

produced through the arc o. It is not allowed to define consuming output and producing input. The token may be producing, consuming, produced and consumed at the same time (through different incident arcs). It can be even self-produced or self-consumed. The syntax of AR-nets differs from the syntax of Petri nets. However, it is proved, that they define the same class of systems: Theorem 3.1. ([1]) Nets of active resources are equivalent to Petri nets, i.e. for each AR-net there exists a Petri net with a homomorphic state transition system and vice versa.

4. 4.1.

Resource Driven Automata Nets (RDA-nets) Definitions

RDA-nets will be defined as AR-systems with tokens (resources) being a specialized extension of finite state machines, called resource driven automata. Thus we refine tokens in AR-nets by defining their own behavior. In the course of its running an automaton token may consume and produce resources-tokens from/to the nodes adjacent to the node it resides in. We label arcs in AR-net with port names to indicate nodes with accessible resources. Let Ω be a finite set of types, Const be a finite set of typed individual objects. We call these objects constants. The type of a constant c ∈ Const is denoted by T ype(c). For a ∈ Ω by Const(a) we denote the set of all constants of type a. Let then Π be a finite set of typed (by elements of Ω) ports (port names). The type of a port π ∈ Π is denoted by T ype(π). In a RDA-net an underlying AR-net with arcs labeled by port names is called a system net. Definition 4.1. A system net is a tuple SN = (V, I, O, π), where (V, I, O) is an AR-net, π : (I ∪ O) → Π is a function, labeling arcs by port names. Definition 4.2. A marking M of the system net SN is a function M : V → M(Const), that maps a multiset of objects to each node of the net. A marked system net is a pair (SN, M0 ) where SN = (V, I, O, π) is a system net and M0 is it’s initial marking. Now we come to defining resource driven automaton. Denote by V ar the set of variables typed with Ω-types. Let a ∈ Ω. We define a language L(a) of resource transformation expressions of type a as follows. Let π ∈ Π. An input term is a term of the form π?e, where e is a variable or a constant of type T ype(π). Similarly, an output term is a term of the form π!e with the same conditions on π and e. Now, a resource transformation expression is a term of the form α1 ; α2 ; . . . ; αk , where αj (j = 1, . . . , k) is either an input or an output term (types of subexpressions α1 , α2 , . . . , αk may differ). Definition 4.3. A resource driven automaton (RDA) of type a ∈ Ω is a tuple A = (SA , TA , lA ), where SA is a finite set of states, TA ⊆ SA × SA is a transition relation, and lA : TA → L(a) is a transition labeling.

231

Thus a RDA can is just a finite state machine with labeled transitions and no distinguished initial state. Further in RDA-nets resource driven automata will play a role of tokens in AR-nets. In a special case, when a RDA contains exactly one state with no transitions, such a token is just a usual colored token without its own states and behavior. We call such tokens elementary resources. The next definition concerns RDA-nets. Definition 4.4. Let Ω = {a1 , . . . , ak } be a finite set of types, and let A = (A1 , . . . , Ak ) be a finite set of RDAs, such 1. for S a type ai ∈ Ω the set Const(ai ) is defined as a set of all states of RDA Ai ; Const =def a∈Ω Const(a); 2. each Ai is a RDA of type ai over the set Ω of types, a set V ar of variables typed with Ω-types, a set Π of port names and a set Const of constants; A RDA-net RN = (Ω, SN, (A1 , . . . , Ak )) consists of a finite set of RDA (A1 , . . . , Ak ) with types from Ω as described above, and a system net SN over the set Ω of types, the set Const of constants, and the set Π of Ω-typed port names. A marking (a state) in a RDA-net is, by definition, a marking in its underlying system net. By abuse of notation we will not differ automaton A and its name/type a. From now we will write (a|s) for the constant denoting the state s of an automaton A of type a. Contextually we call a constant an agent, a resource, or just an object. We define an interleaving semantics for RDA-nets. A run in a RDA-net is a sequence of agent transition firings. Thus only agents may change a state of a system. Now we are ready to define an agent’s transition firing rule. Informally speaking, firing a transition t in an agent a requires resources listed in input subterms of the resource transformation expression, labeling t. Input subterm p?e describes a resource e, which should be obtained via a port p in the system net. A source node for this port arrow in a system net is a node, where this resource should be taken from. Similarly, if possible, a firing of an automaton transition consumes required resources and produces new resources in line with output subexpressions of the transition label. As usual, a mode of transition firing is determined by a variable binding. Definition 4.5. A (variable) binding is a function bind : V ar → Const such that for all ϕ ∈ V ar we have T ype(bind(ϕ)) = T ype(ϕ). Let M be a marking in a RDA-net RN = (Ω, SN, (A1 , . . . , Ak )), a|s – a RDA in a state s residing in a node v of RN in M , t – a transition in a|s. Let b be a variable binding. A transition t = (s, s0 ) with a label la (t) is enabled in M iff there is a one-to-one correspondence between input subterms in la (t) and objects in M s.t. for a subterm p?e there is an object e[b] in a node v 0 of RN in M with an input arrow (v 0 , v) labeled by p in RN . ˇ mapping a node v of RN to the mulThe correspondence described above defines a ’submarking’ M tiset of objects residing in v and singled out by input subterms of la (t). It includes all objects, consumed ˇ is defined nondeterministically. By by firing of t with binding b. Note, that for given t and b marking M in(t[b]) we will denote the set of all such markings.

232

H2

H2

H2

H2

get

get

Tube

Tank1 R|s1

Tube

Tank1

put

R|s2

put

H2O H2O

get

Tank3

O2

get

Tank3

O2

O2

Tank2

R (“reaction”):

Tank2

R (“reaction”):

get?H2+H2+O2; put!H2O+H2O

get?H2+H2+O2; put!H2O+H2O

s1

s1

s2

Figure 7.

s2

RDA-net example: chemical reaction

Similarly we define a set out(t[b]) of markings mapping a node v to objects produced by transition t with a binding b in line with output subterms of la (t). Definition 4.6. Let (a|s) be an agent, residing in a node v ∈ V by a system marking M , and t ∈ Ta be a transition with t = (s, s0 ). ˇ ∈ in(t[b]) s.t. for A transition t is enabled with a variable binding b iff there exists a marking M ˇ (u) ⊆ M (u). each u ∈ V : M An enabled binded transition may (nondeterministically) fire to a new marking M 0 s.t. for each node ˇ (u) + M ˆ , where M ˇ ∈ in(t[b]) and M ˆ ∈ out(t[b]). u ∈ V : M 0 (u) = M (u) − M

4.2.

Modeling

RDA nets allow modeling different aspects of systems with resources. First of all consider a simple example of modeling (Fig. 7). Here we can see a process of water syntheses. The only active agent (RDA) of this system – automaton R – defines the chemical reaction proper (“two molecules of hydrogen and one molecule of oxygen transmute into two molecules of water”). The system net represents a physical environment: three reservoirs and a tube, where the reaction takes place. Ports get and put link these two levels (or two aspects) of the system to each other. From the system’s point of view these ports are physical gates, from the agent’s point of view they are parameter names. The system level of the RDA-net is a labeled net of active resources, i.e. a labeled oriented graph with two types of arcs – input and output ports. However, the semantics here differs from AR-nets semantics. In AR-nets incident arcs define the resources that must be consumed and produced by an agent, situated in the node. In RDA-nets they identify places, that may be used as input or output storages by the agent. Consider another example (Fig. 8). Here we have a router that may obtain a packet from any of its input nodes and transfer it to any of its output nodes. This kind of nondeterminism is a specifics of RDA, based on the notions of variable

233

e c d 8 U f

VWYX[Z]\_^a` b T

9:!; ?A@CB0DE!FGHI&JK&LNMCOP!QSR Figure 8.

  !"$#&%&')( *+-,.0/ 1235476

RDA-net example: nondeterministic router

binding and resource disposition. Of course, in high-level Petri nets we can label an arc by a variable, so the binding nondeterminism also takes place. However, in Petri nets the binding completely defines the resourse disposition. In RDA-nets this is not the case – the model may be more flexible.

4.3.

Expressiveness

One can note, that RDA-nets is a formalism of local finite transformations of multisets without zerotesting. So it is quite easy to see that Theorem 4.1. RDA-nets are expressively equivalent to Petri nets. Proof: Since nets of active resources (AR-nets) are equivalent to Petri nets [1], it is sufficient to prove that RDA-nets are equivalent to AR-nets. (⊇) Sketch a process of transformation of AR-net into equivalent RDA-net. Assign to each arc a unique port name. For a particular node of the AR-net, replace each token in the node by a single-state and single-transition automaton (loop), labeling its transition by a resource transformation expression, corresponding to all adjacent input and output arcs (ports). Obviously, the firing of this transition is equivalent to the firing of the token in the original AR-net. (⊆) Sketch a process of transformation of RDA-net into equivalent AR-net. First note that each RDA has a finite number of states. The number of RDA types is also finite. Hence we can code any marking of a system node by a multiset over the same finite set. Replace a node v of a given system net by a set of places, corresponding to pairs (object type a, state s of the automaton A). The place will contain a number of agents of type a being in a state s, positioned in the node v of the original RDA-net. Second, note that for any transition of the RDA A, positioned in the place v of the system net, there are only finitely many variable bindings and input and output resource dispositions. For each possible combination add a new “transition” node to the AR-net (a node with a single token inside) and link it by input/output arcs with nodes, containing input/output resources of the corresponding binding and disposition (taking into account their placement in the system net). The firing of these “transition” nodes is equivalent to the firing of all agent transitions of a given RDA-net (w.r.t. bindings). t u

234

LFork

ph3 f

f

putl

putr getr

getl

ph2

ph4

getl getr putr

putl

f

f

ph1

RFork Forgetful philosopher

Rectangular table (long-armed philosophers?)

Figure 9.

5.

Dining philosophers – simple modifications

Model example: Dining Philosophers revisited

Separation of system and object levels allows us to model the hierarchical structure quite easily. We can change the upper and lower layers independently, obtaining new interesting models (Fig. 9). Here in the system net on the left we have added new ports for ph1 and ph3 , allowing them to reach all forks on the table. In the resource driven automata on the right we have added two new transitions, allowing a philosopher to shift fork from one hand to another. Each of modifications can lead to a situation, when there will be several forks on the same napkin. Note that the above modifications actually do not affect the synchronization mechanism (ports). Consider the more substantial improvement – “dining and walking philosophers”. Now the philosophers can walk to the park and back. Fig. 10 shows a a model of a doorman, conducting philosophers to the park and back to their chairs. A different variant of a doorman and a doorway is more compact (Fig. 11). Here we introduce a variable x of type philosopher to simplify a resource transformation. But this model has a serious FromChair3 ToChair3

Door ToPark FromPark

d

FromChair2 ToChair2

ph2

chair2

Park

FromChair4 ToChair4

FromChair1 ToChair1

Park, door and their ports (system net) Figure 10.

FromPark?ph1; ToChair1!ph1 FromPark?ph2; ToChair2!ph2 FromPark?ph3; ToChair3!ph3 FromPark?ph4; ToChair4!ph4

FromChair1?ph1; ToPark!ph1 FromChair2?ph2; ToPark!ph2 FromChair3?ph3; ToPark!ph3 FromChair4?ph4; ToPark!ph4

Doorman (object automaton d) Dining philosophers – a doorman

1

235

V.A. Bashkin, I.A. Lomazova / Resource Driven Automata Nets

FromChair ToChair

FromPark?x; ToChair!x

Door ToPark

b

FromPark

FromChair

ph2

ToChair

FromChair?x; ToPark!x

chair2

Park

FromChair ToChair

FromChair ToChair

Park, door and their ports (system net) Figure 11.

Blind doorman (object automaton b) Dining philosophers – a blind doorman

Fig. 1. Dining philosophers – blind doorman malfunction – the doorman is blind – he cannot determine whether a philosopher took a fork from the table or not (because the doorman cannot identify any constant of type philosopher). So in this model it is possible for the philosopher to walk away to the park with a fork in the hand. Moreover, the doorman cannot distinguish chairs (all his output ports has the same name), so he can conduct several philosophers to the same chair. The doorman mechanism models the situation with passive transportaton of objects. Philosophers are resources for the doorman, they do not take part in the decision making. Consider a situation where philosophers are actually moving (Fig. 12). Here we have a more complex agent, a “wandering” philosopher, able to move itself from one place to another. He also can occupy any unoccupied chair (not only his own). This is done by introducing a key token free, that marks unoccupied chairs. put!free; Leave?(phi|Thinking); ToPark!(phi|Walking) ToPark ToChair3 get3

Leave

Walking

get2?free; Leave?(phi|Walking); ToChair2!(phi|Thinking)

Leave ToPark ToChair2

Park ToPark ToChair4 get4

get2

get1?free; Leave?(phi|Walking); ToChair1!(phi|Thinking)

ph2

chair2

put

ToPark get1 ToChair1

get3?free; Leave?(phi|Walking); ToChair3!(phi|Thinking) get4?free; Leave?(phi|Walking); ToChair4!(phi|Thinking)

Philosopher phi («walking» fragment)

Doorway (system net) Elementary token «free» Figure 12.

Dining philosophers – wandering

Thinking

236

6.

Conclusion

In this paper we have presented a new formalism of RDA-nets for multi-agent systems modeling, which allows to represent agents, communicating via resource consuming/production. RDA-nets formalize indirect interaction of agents and allow modeling agent communications without the intermediate protocol layer, directly reflecting specific characters of an object domain. Agents can be moved, created, copied and destroyed by other agents (external mobility). They also can execute all these activities on their own initiative (internal mobility). The syntax of the new formalism is quite uniform and compact. It is proved, that RDA-nets are expressively equivalent to ordinary Petri nets. In the further work we plan to introduce a high-level concepts into RDA syntax, such as parameterization, guards etc.

References [1] V.A. Bashkin. Nets of active resources for distributed systems modeling Joint Bulletin of NCC&IIS, Comp. Science. Novosibirsk. 2008. V.28. P.43-54. [2] L. Bernardinello, N. Bonzanni, M. Mascheroni, and L. Pomello. Modeling Symport/Antiport P Systems with a Class of Hierarchical Petri Nets. Membrane Computing, LNCS 4860, 2007. P.124-137. [3] M. K¨ohler, H. R¨olke. Properties of Super-Dual Nets. Fundamenta Informaticae, 72(1-3), 2006. P. 245-254. [4] M. K¨ohler-Bußmeier. Hornets: Nets within Nets combined with Net Algebra. International Conference on Application and Theory of Petri Nets (ICATPN’2009), LNCS 5606, 2009. P.243-262. [5] M. K¨ohler-Bußmeier, and F. Heitmann. On the Expressiveness of Communication Channels for Object Nets. Fundamenta Informaticae, Vol.93, 2009. P.205-219. [6] K. Lautenbach. Duality of Marked Place/Transition Nets. Universitat Koblenz-Landau, Institut fur Informatik, Research Report 18, 2003. [7] I.A. Lomazova. Nested Petri nets – a Formalism for Specification and Verification of Multi-Agent Distributed Systems. Fundamenta Informaticae. 2000. V.43. P.195-214. [8] I.A. Lomazova. Nested Petri nets for adaptive process modeling. Pillars of Computer Science: Essays Dedicated to Boris (Boaz) Trakhtenbrot on the Occasion of His 85th Birthday, LNCS 4800,2008. P.413-426. [9] W. Pawlowski. Petri Hypernets with Constraints. Proc. of CS&P’2009. P.467–479. [10] R. Valk. Object Petri nets: Using the nets-within-nets paradigm. Advanced Course on Petri Nets 2003, LNCS 3098, 2003. P.819-848.