Multi-Agent Implementation of Filtering Multiset Grammars

*Igor Sheremet*

#### **Abstract**

Chapter is dedicated to the application of multi-agent technology to generation of sets of terminal multisets (*TMS*) defined by filtering multiset grammars (*FMG*). Proposed approach is based on creation of multi-agent system (*MAS*), corresponding to specific *FMG* in such a way, that every rule of *FMG* is represented by independently acting agent. Such *MAS* provides high-parallel generation of *TMS* and may be effectively used in any proper hardware environment. Directions of further development of the proposed approach are discussed.

**Keywords:** multi-agent systems and technologies, multisets, multiset grammars, filtering multiset grammars, parallel computations

### **1. Introduction**

Filtering multiset grammars (*FMG*) were developed as a result of multiset-based deep integration and convergence of classical mathematical programming and modern knowledge engineering for compact, flexible and natural representation of wide spectrum of combinatorial problems and their solution by application of unified algorithmics [1–6].

One of the advantages of *FMG* is natural parallelism of generation of multisets (*MS*) due to the possibility of independent application of rules to the currently available *MS*. Such feature being supported by appropriate hardware is a very promising background for the effective implementation of *FMG* and hence effective solution of the aforementioned problems. However, the "brutal force" approach, demanding on the extensive parallelism, is not suitable here because of evident cost restrictions. More attractive looks such techniques which would be based on the "branches and bounds" logics providing cut off sets of multisets (*SMS*) which provably do not contain terminal multisets (*TMS*), defined by *FMG*, without their generation.

To develop such perspective approach we propose to apply multi-agent technology (*MAT*) [7–12] as a basis for implementation of the aforementioned techniques. The main idea of the suggested method of *TMS* generation is representation of the generating engine as a multi-agent system (*MAS*), which includes:

*N* agents, each corresponding to one rule from *FMG* scheme; one agent corresponding to *FMG* filter; one supervising agent, accumulating generated *TMS*, satisfying filter.

This *MAS* operates in such a way that every rule is applied (i.e. agent becomes active) as soon as there occurs multiset, matching this rule. By this approach maximally possible degree of parallelism is achieved.

Structure of the chapter is as follows. Section 2 contains main definitions and notions of the multigrammatical framework, necessary for further considerations. Proposed techniques of the multi-agent implementation of multisets generation is introduced in Section 3. Directions of future development of these techniques are discussed in the conclusion.

#### **2. Basic notions and definitions of the multigrammatical framework**

Classical theory of sets is based on notion of set as an unordered collection of mutually distinguishable elements. Basic assumption of theory of multisets is that aforementioned collection may contain indistinguishable (identical) elements:

$$v = \left\{ \underbrace{a\_1, \dots, a\_1}\_{n\_1 \text{ times}}, \dots, \underbrace{a\_i, \dots, a\_i}\_{n\_i \text{ times}}, \dots, \underbrace{a\_m, \dots, a\_m}\_{n\_m \text{ times}} \right\}. \tag{1}$$

Record (1) is usually represented as

$$\boldsymbol{\nu} = \{\boldsymbol{n}\_1 \cdot \boldsymbol{a}\_1, \dots, \boldsymbol{n}\_m \cdot \boldsymbol{a}\_m\},\tag{2}$$

*MS v*, which is included to *MS v*<sup>0</sup>

*DOI: http://dx.doi.org/10.5772/intechopen.93303*

*Multi-Agent Implementation of Filtering Multiset Grammars*

As seen, according to (5), *v*⊆*v*<sup>0</sup> and *v*⊂*v*<sup>0</sup>

where "�" denotes multiplication of integer numbers;

*v* þ *v*<sup>0</sup> ¼ ⋃

*v* � *v*<sup>0</sup> ¼ ⋃

*v* ∪ *v*<sup>0</sup> ¼ ⋃

*<sup>v</sup>* <sup>∩</sup> *<sup>v</sup>*<sup>0</sup> <sup>¼</sup> <sup>∪</sup> *<sup>a</sup>*∈*β*ð Þ*<sup>v</sup>* <sup>∪</sup> *<sup>β</sup> <sup>v</sup>*<sup>0</sup> ð Þ

We have used equivalence between *a* ∉ *v* and 0 � *a*∈*v* in (9).

**Example 2.** Let *v* and *v*<sup>0</sup> be as in **Example 1**. Then

*a*∈*β*ð Þ*v* ∪ *β v*<sup>0</sup> ð Þ *n*�*aϵv n*0 �*a* ∈*v*<sup>0</sup>

> *n*�*aϵv n*0 �*a* ∈*v*<sup>0</sup>

3 ∗ *v* ¼ f g 3 � ð Þ *eur* , 15 � ð Þ *usd* , 36 � ð Þ *eur* , *v* þ *v*<sup>0</sup> ¼ f g 7 � ð Þ *eur* , 10 � ð Þ *usd* , 24 � ð Þ *rur* , *v* � *v*<sup>0</sup> ¼ f g Ø , *v*<sup>0</sup> � *v* ¼ f g 5 � ð Þ *eur* ,

*a* ∈*β*ð Þ*v* ∪ *β v*<sup>0</sup> ð Þ *n*�*aϵv n*0 �*a* ∈*v*<sup>0</sup>

*a*∈*β*ð Þ*v* ∪ *β v*<sup>0</sup> ð Þ *n*�*aϵv n*0 �*a*∈*v*<sup>0</sup> *n*>*n*<sup>0</sup>

Along with these operations, we shall use set-theoretical operations on multisets – *join* and *intersection*, – denoted respectively by bold symbols ∪ and ∩, different

strictly included to *MS v*<sup>0</sup>

**Example 1.** Let

in brackets.

from ∪ and ∩:

**217**

, is called *submultiset* of *MS v*<sup>0</sup>

.

*n* þ *n*<sup>0</sup> f g ð Þ� *a* , (7)

*n* � *n*<sup>0</sup> f g ð Þ� *a :* (8)

max *n*, *n*<sup>0</sup> f g f g � *a* , (9)

min *n*, *n*<sup>0</sup> f g f g � *a* , (10)

, is called *strict submultiset* of *MS v*<sup>0</sup>

Let us illustrate introduced notions by the following example, where, as in all other examples, having place in this chapter, objects will be represented by strings

> *v* ¼ f g 1 � ð Þ *eur* , 5 � ð Þ *usd* , 12 � ð Þ *rur* , *v*<sup>0</sup> ¼ f g 6 � ð Þ *eur* , 5 � ð Þ *usd* , 12 � ð Þ *rur :*

.∎ Three basic operations on multisets are *multiplication by a constant*, *addition*, and *subtraction*, which are denoted by bold symbols ∗, + and � respectively. Semantics of these operations is defined by use of the well known set-theoretical operations (join and intersection), as well as arithmetic operations on integer numbers:

*n* ∗ f g *n*<sup>1</sup> � *a*1, … , *nm* � *am* ¼ f g ð Þ� *n* � *n*<sup>1</sup> *a*1, … ,ð Þ� *n* � *nm am* , (6)

; *MS v*, which is

where *v* is called *multiset*, *ni* � *ai* – *multiobjects* (*MO*), *ai* – *objects*, *ni*– their *multiplicities*, for all *i* ¼ 1, … , *m*. According to (2), multiset may be considered as a set of multiobjects, and, in fact, multiset 1f g � *a*1, … , 1 � *am* and set f g *a*1, … , *am* represent one and the same collection. Setf g *a*1, … , *am* , denoted as *β*ð Þ*v* , is called *basis* of multiset *v*. Both empty multiset and empty set are denoted as Øf g.

Zero multiplicity of some object is equivalent to the absence of this object in multiset, i.e.

$$\{n\_1 \cdot a\_1, \dots, n\_m \cdot a\_m, 0 \cdot a\_{m+1}\} = \{n\_1 \cdot a\_1, \dots, n\_m \cdot a\_m\}.\tag{3}$$

Fact, that object *a enters MS v* (or *MS v includes* object *a*), is denoted as *a*∈ *v*. Symbol "∈ " is also used to denote, that *MO n* � *a* enters *MS v* (*MSv* includes *MO n* � *a*):*n* � *a*∈ *v*. Structure of the left operand determines what kind of relation is referred in every particular case. Similarly, symbol " ∉ " is used to denote, that object *a* (multiobject *n* � *a*) does not enter multiset *v*. Due to (3), *a* ∉ *v* and 0 � *a*∈*v* are equivalent.

Number j j *v* ¼ *m* is called *dimensionality* of *MS v*, and number

$$|v| = \sum\_{i=1}^{m} n\_i,\tag{4}$$

is called *power* of *MS v*.

Two basic relations on multisets – *inclusion* ("⊆") and *strict inclusion* ("⊂") – are defined as follows.

*MS v* is *included* to *MS v*<sup>0</sup> , if

$$(\forall n \cdot a \in v)(\exists n' \cdot a \in v') \; n \le n',\tag{5}$$

i.e. for every *MO n* � *a* entering *MS v* there exists *MOn*<sup>0</sup> � *a*, which multiplicity *n*<sup>0</sup> is not less than *n*. There may be also *n*<sup>0</sup> � *a*<sup>0</sup> ∈*v*<sup>0</sup> such that *a*<sup>0</sup> ∉ *v* (as seen, this does not contradict (5), because0 � *a*<sup>0</sup> ∈ *v* and 0<*n*<sup>0</sup> ).

If *v*⊆*v*<sup>0</sup> and *v* 6¼ *v*<sup>0</sup> , then *MS v* is *strictly included* to *MS v*<sup>0</sup> , that is denoted *v*⊂*v*<sup>0</sup> . *Multi-Agent Implementation of Filtering Multiset Grammars DOI: http://dx.doi.org/10.5772/intechopen.93303*

*MS v*, which is included to *MS v*<sup>0</sup> , is called *submultiset* of *MS v*<sup>0</sup> ; *MS v*, which is strictly included to *MS v*<sup>0</sup> , is called *strict submultiset* of *MS v*<sup>0</sup> .

Let us illustrate introduced notions by the following example, where, as in all other examples, having place in this chapter, objects will be represented by strings in brackets.

**Example 1.** Let

Structure of the chapter is as follows. Section 2 contains main definitions and notions of the multigrammatical framework, necessary for further considerations. Proposed techniques of the multi-agent implementation of multisets generation is introduced in Section 3. Directions of future development of these techniques are

**2. Basic notions and definitions of the multigrammatical framework**

*v* ¼ *a*1, … , *a*<sup>1</sup> |fflfflfflfflffl{zfflfflfflfflffl} *n*<sup>1</sup> *times*

8 < :

*Computational Optimization Techniques and Applications*

Record (1) is usually represented as

Classical theory of sets is based on notion of set as an unordered collection of mutually distinguishable elements. Basic assumption of theory of multisets is that aforementioned collection may contain indistinguishable (identical) elements:

> , … , *ai*, … , *ai* |fflfflfflffl{zfflfflfflffl} *ni times*

where *v* is called *multiset*, *ni* � *ai* – *multiobjects* (*MO*), *ai* – *objects*, *ni*– their *multiplicities*, for all *i* ¼ 1, … , *m*. According to (2), multiset may be considered as a set of multiobjects, and, in fact, multiset 1f g � *a*1, … , 1 � *am* and set f g *a*1, … , *am* represent one and the same collection. Setf g *a*1, … , *am* , denoted as *β*ð Þ*v* , is called *basis* of multiset *v*. Both empty multiset and empty set are denoted as Øf g.

Zero multiplicity of some object is equivalent to the absence of this object in

Fact, that object *a enters MS v* (or *MS v includes* object *a*), is denoted as *a*∈ *v*. Symbol "∈ " is also used to denote, that *MO n* � *a* enters *MS v* (*MSv* includes *MO n* � *a*):*n* � *a*∈ *v*. Structure of the left operand determines what kind of relation is referred in every particular case. Similarly, symbol " ∉ " is used to denote, that object *a* (multiobject *n* � *a*) does not enter multiset *v*. Due to (3), *a* ∉ *v* and 0 � *a*∈*v*

> j j *<sup>v</sup>* <sup>¼</sup> <sup>X</sup>*<sup>m</sup> i*¼1

Two basic relations on multisets – *inclusion* ("⊆") and *strict inclusion* ("⊂") –

ð Þ ∀*n* � *a*∈ *v* ∃*n*<sup>0</sup> � *a*∈ *v*<sup>0</sup> ð Þ *n*≤*n*<sup>0</sup>

i.e. for every *MO n* � *a* entering *MS v* there exists *MOn*<sup>0</sup> � *a*, which multiplicity *n*<sup>0</sup> is not less than *n*. There may be also *n*<sup>0</sup> � *a*<sup>0</sup> ∈*v*<sup>0</sup> such that *a*<sup>0</sup> ∉ *v* (as seen, this does not

).

, then *MS v* is *strictly included* to *MS v*<sup>0</sup>

Number j j *v* ¼ *m* is called *dimensionality* of *MS v*, and number

, if

f g *n*<sup>1</sup> � *a*1, … , *nm* � *am*, 0 � *am*þ<sup>1</sup> ¼ f g *n*<sup>1</sup> � *a*1, … , *nm* � *am :* (3)

, … , *am*, … , *am* |fflfflfflfflfflffl{zfflfflfflfflfflffl} *nm times*

*v* ¼ f g *n*<sup>1</sup> � *a*1, … , *nm* � *am* , (2)

9 =

*ni*, (4)

, (5)

, that is denoted *v*⊂*v*<sup>0</sup>

.

;*:* (1)

discussed in the conclusion.

multiset, i.e.

are equivalent.

is called *power* of *MS v*.

*MS v* is *included* to *MS v*<sup>0</sup>

contradict (5), because0 � *a*<sup>0</sup> ∈ *v* and 0<*n*<sup>0</sup>

are defined as follows.

If *v*⊆*v*<sup>0</sup> and *v* 6¼ *v*<sup>0</sup>

**216**

$$v = \{\mathbf{1} \cdot (eur), \mathbf{5} \cdot (usd), \mathbf{12} \cdot (rur)\},$$

$$v' = \{\mathbf{6} \cdot (eur), \mathbf{5} \cdot (usd), \mathbf{12} \cdot (rur)\}.$$

As seen, according to (5), *v*⊆*v*<sup>0</sup> and *v*⊂*v*<sup>0</sup> .∎

Three basic operations on multisets are *multiplication by a constant*, *addition*, and *subtraction*, which are denoted by bold symbols ∗, + and � respectively. Semantics of these operations is defined by use of the well known set-theoretical operations (join and intersection), as well as arithmetic operations on integer numbers:

$$n\*\{n\_1\cdot a\_1, \ldots, n\_m\cdot a\_m\} = \{ (n\times n\_1)\cdot a\_1, \ldots, (n\times n\_m)\cdot a\_m \},\tag{6}$$

where "�" denotes multiplication of integer numbers;

$$v + v' = \bigcup\_{a \in \beta(v) \cup \beta(v')} \{ (n + n') \cdot a \}, \tag{7}$$

$$\_{n \cdot acv}$$

$$\_{n' \cdot a \in v'}$$

$$\_{n' \cdot a \in v'} = \bigcup\_{a' \in \beta(v) \cup \beta(v')} \{ (n - n') \cdot a \}. \tag{8}$$

$$\_{n' \cdot acv}$$

$$\_{n' \cdot a \in v'}$$

$$\_{n > n'}$$

Along with these operations, we shall use set-theoretical operations on multisets – *join* and *intersection*, – denoted respectively by bold symbols ∪ and ∩, different from ∪ and ∩:

$$v \cup v' = \bigcup\_{a \in \beta(v) \cup \beta(v')} \{ \max \{ n, n' \} \cdot a \}, \tag{9}$$

$$\_{n \cdot uv}$$

$$\_{n' \cdot a \in v'}$$

$$\_{a \in \beta(v) \cup \beta(v')} \bigcup\_{a \in \beta(v) \cup \beta(v')} \{ \min \{ n, n' \} \cdot a \}, \tag{10}$$

$$\_{n \cdot uv}$$

$$\_{n' \cdot a \in v'}$$

We have used equivalence between *a* ∉ *v* and 0 � *a*∈*v* in (9). **Example 2.** Let *v* and *v*<sup>0</sup> be as in **Example 1**. Then

$$\mathfrak{Z} \* v = \{ \mathfrak{Z} \cdot (eur), \mathfrak{1} 5 \cdot (usd), \mathfrak{3} \not\!6 \cdot (eur) \},$$

$$v + v' = \{ \mathfrak{I} \cdot (eur), \mathfrak{1} 0 \cdot (usd), \mathfrak{2} 4 \cdot (urr) \},$$

$$v - v' = \{ \mathfrak{O} \},$$

$$v' - v = \{ \mathfrak{5} \cdot (eur) \},$$

$$v \cup v' = \{\mathsf{6} \cdot (eur), \mathsf{5} \cdot (usd), \mathsf{12} \cdot (rur)\},$$

$$v \cap v' = \{\mathsf{1} \cdot (eur), \mathsf{5} \cdot (usd), \mathsf{12} \cdot (rur)\}.\mathsf{II}$$

Common feature of all described operations, which are known from theory of multisets [13, 14], is that their operands are multisets and integer numbers. Unlike them, following operation called "*filtration*" applies set of multisets (*SMS*) as the first operand and so called "*filter*", being set of *conditions*, as the second operand. Filtration is denoted as *V*↓*F*, where *V* is filtrated *SMS*, *F* is filter, and "↓" – symbol of operation.

Conditions entering filter *F* may be boundary and optimizing.

*Boundary conditions* (*BC*) are recorded as *aθn*, where *θ* ∈ f g >, <, ≥, ≤, ¼ . Multiset *v* satisfies *BC aθn*, if *m* � *a*∈*v* and *mθn* is true (as everywhere, *a* ∉ *v* is equivalent to 0 � *a*∈*v*).

Let *F* <sup>≤</sup> ¼ f g *bc*1, … , *bck* be a filter, containing only boundary conditions. Then

$$V \downarrow F\_{\leq} = \bigcap\_{i=1}^{k} (V \downarrow \{bc\_{i}\}).\tag{11}$$

i.e. result of filtering set of multisets *V* by filter *F* is obtained by application of boundary subfilter *F* <sup>≤</sup> to *V*, after what resulting *SMS* is filtered by optimizing

Application of filters, containing boundary and optimizing conditions, is illus-

Background of this family is notion of *multiset grammar* as a couple *S* ¼ h i *v*0, *R* , where *v*<sup>0</sup> called *kernel* is multiset, and *R* called *scheme* is finite set of so called rules.

Considered operations on multisets and their sets make it possible to define

*v* ! *v*<sup>0</sup>

*v*<sup>0</sup> ¼ *v* � *v* þ *v*<sup>0</sup> . *:* (16)

Speaking informally, (16) defines, that if left part of the rule, i.e. multiset *v*, is

*r*, and "!" is divider. The only restriction on left and right parts of the rule

included to *MS v*, then *v* is replaced by right part of this rule, i.e. multiset *v*<sup>0</sup>

part *v* is not included to *MS v*, result of application *r* to *v* is empty *MS* f g Ø .

same, *defined by this multigrammar*, is recursively created as follows:

*v* ) *r v*0

and it is said, that *MS v*<sup>0</sup> is generated from *MS v* by application of rule *r*. If left

*Set of multisets, generated by application of multigrammar S* ¼ h i *v*0, *R* , or, just the

If *v*⊆*v*, then result of *application* of rule *r* to multiset *v* is multiset

where multisets *v* and *v*<sup>0</sup> are called respectively *left part* and *right part* of the rule

, (15)

, (17)

*V*ð Þ <sup>0</sup> ¼ f g *v*<sup>0</sup> , (18)

. Result

Set of all objects used in kernel and scheme of *MG S* is denoted as *AS*.

syntax and semantics of family of multiset grammars.

*Multi-Agent Implementation of Filtering Multiset Grammars*

*DOI: http://dx.doi.org/10.5772/intechopen.93303*

of application of rule *r* to multiset *v* is denoted as

subfilter *Fopt*.

is*v* 6¼ f g Ø .

**Figure 1.** *Filters application.*

**219**

trated by **Figure 1**.

*Rule r*∈*R* is a construction

**Example 3.** Let *V* ¼ f g *v*1, *v*2, *v*<sup>3</sup> , where

$$\begin{aligned} v\_1 &= \{ 4 \cdot (eur), 3 \cdot (rur) \}, \\ v\_2 &= \{ 8 \cdot (usd), 10 \cdot (rur) \}, \\ v\_3 &= \{ 3 \cdot (eur), 19 \cdot (usd), 17 \cdot (rur) \}, \end{aligned}$$

and *F* <sup>≤</sup> ¼ f g ð Þ *usd* >3,ð Þ *rur* ≤12 . Then

$$\begin{split} V \downarrow F\_{\leq} &= (V \downarrow \{ (usd) > \mathfrak{Z} \}) \cap (V \downarrow \{ (rur) \leq \mathfrak{1} \mathfrak{Z} \}) = \\ &= \{ v\_2, v\_3 \} \cap \{ v\_1, v\_2 \} = \{ v\_2 \}. \end{split}$$

*Optimizing conditions* (*OC*) are recorded as*a* ¼ *opt*, where *opt*∈f g *max* , *min* . Multiset *v*∈*V* satisfies *OC a* ¼ *max* , if *n* � *a*∈*v* and all multisets *v*<sup>0</sup> ∈*V* � f g*v* satisfy boundary condition *a*≤ *n*. Similarly, multiset *v*∈*V* satisfies *OC a* ¼ *min* , if *n* � *a*∈*v* and all multisets *v*<sup>0</sup> ∈*V* � f g*v* satisfy boundary condition *a*≥*n*.

Let *Fopt* ¼ f g *oc*1, … , *ocl* be filter, containing only optimizing conditions. Then, similarly to (6),

$$V \downarrow F\_{opt} = \bigcap\_{i=1}^{l} (V \downarrow \{oc\_i\}).\tag{12}$$

**Example 4.** Let *V* be the same as in Example 3, and *Fopt* ¼ f g ð Þ¼ *usd max* ,ð Þ¼ *rur min* . Then

$$V\Downarrow F\_{opt} = (\upsilon\Downarrow\{(usd) = max\}) \rangle \cap (\upsilon\Downarrow\{(rur) = min\}) = \{\upsilon\_3\} \cap \{\upsilon\_1\} = \{\mathcal{O}\} . \blacksquare$$

If filter *F* contains both boundary and optimizing conditions, i.e.

$$F = F\_{\leq} \cup F\_{opt},\tag{13}$$

then

$$V \downarrow F = (V \downarrow F\_{\leq}) \downarrow F\_{opt},\tag{14}$$

*Multi-Agent Implementation of Filtering Multiset Grammars DOI: http://dx.doi.org/10.5772/intechopen.93303*

i.e. result of filtering set of multisets *V* by filter *F* is obtained by application of boundary subfilter *F* <sup>≤</sup> to *V*, after what resulting *SMS* is filtered by optimizing subfilter *Fopt*.

Application of filters, containing boundary and optimizing conditions, is illustrated by **Figure 1**.

Considered operations on multisets and their sets make it possible to define syntax and semantics of family of multiset grammars.

Background of this family is notion of *multiset grammar* as a couple *S* ¼ h i *v*0, *R* , where *v*<sup>0</sup> called *kernel* is multiset, and *R* called *scheme* is finite set of so called rules. Set of all objects used in kernel and scheme of *MG S* is denoted as *AS*.

*Rule r*∈*R* is a construction

*v* ∪ *v*<sup>0</sup> ¼ f g 6 � ð Þ *eur* , 5 � ð Þ *usd* , 12 � ð Þ *rur* , *v* ∩ *v*<sup>0</sup> ¼ f g 1 � ð Þ *eur* , 5 � ð Þ *usd* , 12 � ð Þ *rur :*∎

Common feature of all described operations, which are known from theory of multisets [13, 14], is that their operands are multisets and integer numbers. Unlike them, following operation called "*filtration*" applies set of multisets (*SMS*) as the first operand and so called "*filter*", being set of *conditions*, as the second operand. Filtration is denoted as *V*↓*F*, where *V* is filtrated *SMS*, *F* is filter, and "↓" – symbol

*Boundary conditions* (*BC*) are recorded as *aθn*, where *θ* ∈ f g >, <, ≥, ≤, ¼ . Multiset *v* satisfies *BC aθn*, if *m* � *a*∈*v* and *mθn* is true (as everywhere, *a* ∉ *v* is

> *k i*¼1

*v*<sup>1</sup> ¼ f g 4 � ð Þ *eur* , 3 � ð Þ *rur* , *v*<sup>2</sup> ¼ f g 8 � ð Þ *usd* , 10 � ð Þ *rur* , *v*<sup>3</sup> ¼ f g 3 � ð Þ *eur* , 19 � ð Þ *usd* , 17 � ð Þ *rur* ,

*V*↓*F* <sup>≤</sup> ¼ ð Þ *V*↓f g ð Þ *usd* >3 ∩ ð*V*↓f g ð Þ *rur* ≤12 Þ ¼

*Optimizing conditions* (*OC*) are recorded as*a* ¼ *opt*, where *opt*∈f g *max* , *min* . Multiset *v*∈*V* satisfies *OC a* ¼ *max* , if *n* � *a*∈*v* and all multisets *v*<sup>0</sup> ∈*V* � f g*v* satisfy boundary condition *a*≤ *n*. Similarly, multiset *v*∈*V* satisfies *OC a* ¼ *min* , if *n* � *a*∈*v*

Let *Fopt* ¼ f g *oc*1, … , *ocl* be filter, containing only optimizing conditions. Then,

*l i*¼1

*V*↓*Fopt* ¼ ð*v*↓fð Þ¼ *usd max* ÞgÞ ∩ ð*v*↓f g ð Þ¼ *rur min* Þ ¼ f g *v*<sup>3</sup> ∩ f g *v*<sup>1</sup> ¼ f g Ø *:*∎

and all multisets *v*<sup>0</sup> ∈*V* � f g*v* satisfy boundary condition *a*≥*n*.

**Example 4.** Let *V* be the same as in Example 3, and

*Fopt* ¼ f g ð Þ¼ *usd max* ,ð Þ¼ *rur min* . Then

*V*↓*Fopt* ¼ ⋂

If filter *F* contains both boundary and optimizing conditions, i.e.

<sup>¼</sup> f g *<sup>v</sup>*2, *<sup>v</sup>*<sup>3</sup> <sup>∩</sup> f g *<sup>v</sup>*1, *<sup>v</sup>*<sup>2</sup> <sup>¼</sup> f g *<sup>v</sup>*<sup>2</sup> *:* <sup>∎</sup>

ð Þ *V*↓f g *bci :* (11)

ð Þ *V*↓f g *oci :* (12)

*F* ¼ *F* <sup>≤</sup> ∪ *Fopt*, (13)

*V*↓*F* ¼ ð Þ *V*↓*F* <sup>≤</sup> ↓*Fopt*, (14)

Let *F* <sup>≤</sup> ¼ f g *bc*1, … , *bck* be a filter, containing only boundary conditions.

*V*↓*F* <sup>≤</sup> ¼ ⋂

**Example 3.** Let *V* ¼ f g *v*1, *v*2, *v*<sup>3</sup> , where

*Computational Optimization Techniques and Applications*

and *F* <sup>≤</sup> ¼ f g ð Þ *usd* >3,ð Þ *rur* ≤12 . Then

Conditions entering filter *F* may be boundary and optimizing.

of operation.

Then

similarly to (6),

then

**218**

equivalent to 0 � *a*∈*v*).

$$
v \to v', \tag{15}$$

where multisets *v* and *v*<sup>0</sup> are called respectively *left part* and *right part* of the rule *r*, and "!" is divider. The only restriction on left and right parts of the rule is*v* 6¼ f g Ø .

If *v*⊆*v*, then result of *application* of rule *r* to multiset *v* is multiset

$$
\mathfrak{v}' = \mathfrak{v} - \mathfrak{v} + \mathfrak{v}'.\tag{16}
$$

Speaking informally, (16) defines, that if left part of the rule, i.e. multiset *v*, is included to *MS v*, then *v* is replaced by right part of this rule, i.e. multiset *v*<sup>0</sup> . Result of application of rule *r* to multiset *v* is denoted as

$$
\boldsymbol{\nu} \stackrel{\boldsymbol{r}}{\Rightarrow} \boldsymbol{\nu}',\tag{17}
$$

and it is said, that *MS v*<sup>0</sup> is generated from *MS v* by application of rule *r*. If left part *v* is not included to *MS v*, result of application *r* to *v* is empty *MS* f g Ø .

*Set of multisets, generated by application of multigrammar S* ¼ h i *v*0, *R* , or, just the same, *defined by this multigrammar*, is recursively created as follows:

$$V\_{(0)} = \{\nu\_0\},\tag{18}$$

**Figure 1.** *Filters application.*

*Computational Optimization Techniques and Applications*

$$V\_{(i+1)} = V\_{(i)} \bigcup \left( \bigcup\_{\mathbf{v} \in V\_{(i)}r \in R} \bigcup \left\{ \mathbf{v}' \middle| \mathbf{v} \xrightarrow{r} \mathbf{v}' \right\} \right), \tag{19}$$

$$V\_S = V\_{(\ast \ast)}.\tag{20}$$

sequential currency exchanges, which parameters are fixed by rules *r*<sup>1</sup> and *r*<sup>2</sup> (2 Euros may be exchanged to 4 US dollars, 2 US dollars and 3 Russian rubles may

*Multi-Agent Implementation of Filtering Multiset Grammars*

*DOI: http://dx.doi.org/10.5772/intechopen.93303*

nents (multiplicities and object names), generation of multisets provides

Generalized scheme of application of multiset grammars is presented at **Figure 2**. Due to the fact, that multiobjects contain both numerical and symbolic compo-

knowledge-driven numerical computation, that creates a lot of new opportunities for simple formalizing and effective solution of various sophisticated practical problems with hard combinatorial background. To implement such opportunities, so called filtering multiset grammars were proposed in [1, 2]. *FMG* are such generalization of *MG*, that integrate two basic concepts—generation of set of multisets and selection from it such *MS*, that satisfy some logical conditions, joined to filter. *Filtering multiset grammar* is a triple *S* ¼ h i *v*0, *R*, *F* , where *v*<sup>0</sup> and *R* are, as above, kernel and scheme, while *F* is a filter, including boundary and optimizing conditions, defining multisets, which would be selected from the set of *TMS*, generated

be exchanged to 2 Euros).∎

by *MG v*h i \_0, *R* , i.e.

**Figure 2.**

**Figure 3.**

**221**

*Application of filtering multiset grammars.*

*Application of multiset grammars.*

As seen, *VS* includes all multisets, which may be generated from *MS v*<sup>0</sup> by sequential application of rules *r*∈*R*, and *VS* is fixed point of the sequence *V*ð Þ <sup>0</sup> ,*V*ð Þ<sup>1</sup> , … ,*V*ð Þ*<sup>i</sup>* , … , so

$$V\_S = \bigcup\_{i=0}^{\infty} V\_{(i)}.\tag{21}$$

In general case *VS* may be infinite.

If *MS v*<sup>0</sup> may be generated from *MS v* by application of some sequence (chain) of rules entering scheme *R*, it is denoted as

$$
\sigma \stackrel{R}{\Rightarrow} \sigma',
\tag{22}
$$

and, if so,

$$V\_S = \left\{ \mathfrak{v} \, \middle| \, v\_0 \stackrel{R}{\Rightarrow} \mathfrak{v} \right\}. \tag{23}$$

Multiset *v*∈*VS* is called *terminal multiset* (*TMS*), if

$$(\forall r \in R) \; \mathfrak{v} \stackrel{r}{\Rightarrow} \{\mathfrak{O}\},\tag{24}$$

i.e. no any rule *r*∈*R* may be applied to this multiset. Set of terminal multisets (*STMS*) defined by multiset grammar *S* is denoted *VS*. Evidently,

$$
\overline{V\_S} \subseteq V\_S. \tag{25}
$$

**Example 5.** Let *S* ¼ h i *v*0, *R* , where kernel

$$v\_0 = \{ \mathbf{3} \cdot (eur), \mathbf{6} \cdot (usd), \mathbf{5} \cdot (rur) \},$$

and scheme *R* ¼ f g *r*1,*r*<sup>2</sup> , where *r*<sup>1</sup> is

$$\{2 \cdot (eur)\} \to \{4 \cdot (usd)\},$$

and *r*<sup>2</sup> is

$$\{2 \cdot (usd), \mathfrak{Z} \cdot (urr)\} \to \{2 \cdot (eur)\}.$$

According to (18)–(19),

$$\begin{aligned} V\_{(0)} &= \{ \{ \mathbf{3} \cdot (eur), \mathbf{6} \cdot (usd), \mathbf{5} \cdot (rur) \} \}, \\ V\_{(1)} &= V\_{(0)} \cdot \cup \{ \{ \mathbf{1} \cdot (eur), \mathbf{10} \cdot (usd), \mathbf{5} \cdot (rur) \} \}, \{ \mathbf{5} \cdot (eur), \mathbf{4} \cdot (usd), \mathbf{2} \cdot (rur) \}, \\ V\_{(2)} &= V\_{(1)} \cup \{ \{ \mathbf{3} \cdot (eur), \mathbf{8} \cdot (usd), \mathbf{2} \cdot (rur) \} \}, \\ &\dots \end{aligned}$$

As seen, this *MG* provides generation of all possible collections of Euros, US dollars, and Russian rubles, which may be obtained from the initial collection *v*<sup>0</sup> by *Multi-Agent Implementation of Filtering Multiset Grammars DOI: http://dx.doi.org/10.5772/intechopen.93303*

*<sup>V</sup>*ð Þ *<sup>i</sup>*þ<sup>1</sup> <sup>¼</sup> *<sup>V</sup>*ð Þ*<sup>i</sup>* ⋃ ⋃*<sup>v</sup>* <sup>∈</sup>*V*ð Þ*<sup>i</sup>*

*Computational Optimization Techniques and Applications*

*V*ð Þ <sup>0</sup> ,*V*ð Þ<sup>1</sup> , … ,*V*ð Þ*<sup>i</sup>* , … , so

and, if so,

and *r*<sup>2</sup> is

⋯

**220**

According to (18)–(19),

In general case *VS* may be infinite.

rules entering scheme *R*, it is denoted as

⋃ *r* ∈*R*

As seen, *VS* includes all multisets, which may be generated from *MS v*<sup>0</sup> by sequential application of rules *r*∈*R*, and *VS* is fixed point of the sequence

> *VS* ¼ ⋃ ∞ *i*¼0

> > *v* ) *R v*0

*VS* ¼ *v v*<sup>0</sup> )

ð Þ ∀*r*∈*R v* )

Multiset *v*∈*VS* is called *terminal multiset* (*TMS*), if

**Example 5.** Let *S* ¼ h i *v*0, *R* , where kernel

and scheme *R* ¼ f g *r*1,*r*<sup>2</sup> , where *r*<sup>1</sup> is

*V*ð Þ <sup>0</sup> ¼ f g f g 3 � ð Þ *eur* , 6 � ð Þ *usd* , 5 � ð Þ *rur* ,

*V*ð Þ<sup>2</sup> ¼ *V*ð Þ<sup>1</sup> ∪ f g f g 3 � ð Þ *eur* , 8 � ð Þ *usd* , 2 � ð Þ *rur* ,

(*STMS*) defined by multiset grammar *S* is denoted *VS*. Evidently,

*R* � � � �

*r*

i.e. no any rule *r*∈*R* may be applied to this multiset. Set of terminal multisets

*v*<sup>0</sup> ¼ f g 3 � ð Þ *eur* , 6 � ð Þ *usd* , 5 � ð Þ *rur* ,

f g 2 � ð Þ *eur* ! f g 4 � ð Þ *usd* ,

f g 2 � ð Þ *usd* , 3 � ð Þ *rur* ! f g 2 � ð Þ *eur :*

*V*ð Þ<sup>1</sup> ¼ *V*ð Þ <sup>0</sup> � ∪ f g f g 1 � ð Þ *eur* , 10 � ð Þ *usd* , 5 � ð Þ *rur* , 5f g � ð Þ *eur* , 4 � ð Þ *usd* , 2 � ð Þ *rur* ,

As seen, this *MG* provides generation of all possible collections of Euros, US dollars, and Russian rubles, which may be obtained from the initial collection *v*<sup>0</sup> by

*v* � �

If *MS v*<sup>0</sup> may be generated from *MS v* by application of some sequence (chain) of

*v*<sup>0</sup> *v* ) *r* � � � *<sup>v</sup>*<sup>0</sup> n o !

*VS* ¼ *V*ð Þ <sup>∞</sup> *:* (20)

*V*ð Þ*<sup>i</sup> :* (21)

, (22)

*:* (23)

f g Ø , (24)

*VS* ⊆*VS:* (25)

, (19)

sequential currency exchanges, which parameters are fixed by rules *r*<sup>1</sup> and *r*<sup>2</sup> (2 Euros may be exchanged to 4 US dollars, 2 US dollars and 3 Russian rubles may be exchanged to 2 Euros).∎

Generalized scheme of application of multiset grammars is presented at **Figure 2**. Due to the fact, that multiobjects contain both numerical and symbolic components (multiplicities and object names), generation of multisets provides knowledge-driven numerical computation, that creates a lot of new opportunities for simple formalizing and effective solution of various sophisticated practical problems with hard combinatorial background. To implement such opportunities, so called filtering multiset grammars were proposed in [1, 2]. *FMG* are such generalization of *MG*, that integrate two basic concepts—generation of set of multisets and selection from it such *MS*, that satisfy some logical conditions, joined to filter.

*Filtering multiset grammar* is a triple *S* ¼ h i *v*0, *R*, *F* , where *v*<sup>0</sup> and *R* are, as above, kernel and scheme, while *F* is a filter, including boundary and optimizing conditions, defining multisets, which would be selected from the set of *TMS*, generated by *MG v*h i \_0, *R* , i.e.

**Figure 2.** *Application of multiset grammars.*

**Figure 3.** *Application of filtering multiset grammars.*

$$\mathcal{V}\_t = \overline{\mathcal{V}}\_{\langle v\_0, \mathcal{R} \rangle} \downarrow F. \tag{26}$$

All messages are couples, the first components of which are numbers of multisets, processed by the agents, and every *MS* has its unique number. Assigning numbers to multisets is performed by agent *G*<sup>∗</sup> . Current maximal number is denoted *<sup>J</sup>*. Also agent *<sup>G</sup>*<sup>∗</sup> uses variable *<sup>Z</sup>*, which value is set of couples h i *<sup>j</sup>*, *<sup>n</sup>* , where *n* is number of agents *ri* which until current moment have not sent to *G*<sup>∗</sup> messages

**N Sender Receiver Message Comment**

*Multi-Agent Implementation of Filtering Multiset Grammars*

*DOI: http://dx.doi.org/10.5772/intechopen.93303*

<sup>4</sup> *<sup>G</sup>*<sup>∗</sup> h i *<sup>j</sup>*, *<sup>v</sup>* , h i *<sup>j</sup>*, *<sup>v</sup>* As 1

<sup>1</sup> *<sup>G</sup>*<sup>∗</sup> *ri* h i *<sup>j</sup>*, *<sup>v</sup> <sup>j</sup>* – number of *MS,v* 6¼ f g <sup>Ø</sup> <sup>2</sup> *ri <sup>G</sup>*<sup>∗</sup> *<sup>j</sup>*, *<sup>v</sup>*<sup>0</sup> h i *<sup>v</sup>*<sup>0</sup> – result of application of rule

<sup>3</sup> *ri <sup>G</sup>*<sup>∗</sup> h i *<sup>j</sup>*, Øf g Rule *ri* is not applicable to *<sup>v</sup>*

<sup>5</sup> *<sup>F</sup>* <sup>∗</sup> *<sup>G</sup>*<sup>∗</sup> h i *<sup>j</sup>*, 1 *<sup>j</sup>*th *MS* satisfies filter *<sup>F</sup>* <sup>6</sup> *<sup>F</sup>* <sup>∗</sup> *<sup>G</sup>*<sup>∗</sup> h i *<sup>j</sup>*, 0 *<sup>j</sup>*th *MS* does not satisfy filter *<sup>F</sup>*

*ri* to *MS v*

Agent *<sup>G</sup>*<sup>∗</sup> sends couple h i *<sup>j</sup>*, *<sup>v</sup>* to all agents *ri*. After this, *<sup>G</sup>*<sup>∗</sup> joins to the current value of variable *Z* couple h i *j*, *l* . Every agent *ri*, receiving message h i *j*, *v* from agent *G*<sup>∗</sup> , tries to apply *v* to rule *ri*. If application is possible, *ri* sends to *G*<sup>∗</sup> message *j*, *v*<sup>0</sup>

where *v*<sup>0</sup> is result of application of rule *ri* to *MS v*. Otherwise *ri* sends to *G*<sup>∗</sup> message h i *<sup>j</sup>*, Øf g . Agent *<sup>G</sup>*<sup>∗</sup> , receiving message h i *<sup>j</sup>*, *<sup>v</sup>* , where *<sup>v</sup>* 6¼ f g <sup>Ø</sup> , assigns *<sup>J</sup>* new value *J* þ 1, and sends message h i *J*, *v* to all agents. Also couple h i *J*, *l* is joined to *Z*, and couple h i *j*, *q* ∈ *Z* is eliminated from set *Z*, that means at least one rule was applied to *<sup>j</sup>*th *MS*, so this multiset is non-terminal. If agent *<sup>G</sup>*<sup>∗</sup> receives message h i *<sup>j</sup>*, Øf g from *ri*, that means rule *ri* was not applied to *j*th multiset, and h i *j*, *q* ∈ *Z* is replaced by h i *j*, *q* � 1 . If now h i *j*, 0 ∈*Z*, that means no one rule was applied to *j*th *MS*, that's why it is terminal, and, according to *FMG* semantics, it must be filtered. So agent *G*<sup>∗</sup> sends couple h i *<sup>j</sup>*, *<sup>v</sup>* to agent *<sup>F</sup>* <sup>∗</sup> , which provides testing, whether *<sup>v</sup>* satisfies boundary subfilter *<sup>F</sup>* <sup>≤</sup> <sup>⊆</sup>*F*. If testing is successful, agent *<sup>F</sup>* <sup>∗</sup> sends to agent *<sup>G</sup>*<sup>∗</sup> message h i *<sup>j</sup>*, 1 , otherwise—message h i *j*, 0 . In the case h i *j*, 1 couple h i *j*, *v* is joined to the current value of variable *Vs*. After no active agents *ri* remain, agent *G*<sup>∗</sup> applies optimizing subfilter *Fopt* ⊆*F* to the aforementioned current value *Vs*, eliminating from it all multisets, which do not satisfy *Fopt*. Final value of variable *Vs* is exactly set of

As may be seen, proposed multi-agent system provides generation and filtration

However, there are some evident bottlenecks, limiting speed of multisets gener-

To implement proposed logics, we shall introduce auxiliary database *L*, which elements would be couples h i *a*, f g h i *i*1, *n*<sup>1</sup> , … ,h i *ik*, *nk* , where *a* is name of object, and in couples h i *i*, *n* , entering the set, which is second component of the couple, integer *i*

ation. Most essential of such bottlenecks are massive transmissions of multiply repeated sets of multiobjects via *MAS* communication network. To reduce such transmission it is possible not to send *MO* to agents *ri* such, that corresponding them rules are applicable to multisets, having place in the storage *V,* and this applicability may be recognized directly by agent *G*<sup>∗</sup> . If such opportunity may be implemented, only those agents *ri*, which, possibly, may apply corresponding rules to current *MS*, would receive it. By this measure, traffic on *MAS* communication

,

with results of application of corresponding rule to *j*th *MS*.

**Table 1.**

*Set of MAS messages.*

terminal multisets, defined by *FMG S* ¼ h i *v*0, *R*, *F* .

network may be reduced sharply.

**223**

of multisets by parallel operation of all agents, entering this *MAS*.

is number of the rule, which left part contains multiobject *n* � *a*.

Verbally, *Vs* is subset of *V*h i *<sup>v</sup>*0,*<sup>R</sup>* , which includes only such elements of this set, that satisfy filter *F*. Generalized scheme of application of filtering multiset grammars is presented at **Figure 3**.

After description of syntax and semantics of filtering multiset grammars we may move to their implementation issues, which background are multi-agent technologies.

#### **3. Basic techniques of the multi-agent implementation of multisets generation**

Due to granularity and natural internal parallelism of multigrammatical representation it is perspective to try to use multi-agent paradigm as a background for implementation of the *FMG* application engine (*AE*), providing generation of multisets.

We shall use scheme, depicted at **Figure 4**, as a basis for primary multi-agent implementation of *FMG AE*. Proposed multi-agent system implementing *FMG S* ¼ h i *v*0, *R*, *F* , contains *l* ¼ j j *R* agents *r*1, … ,*rl*, each corresponding to one rule from set *R* (everywhere below we shall denote rules and implementing them agents by the same symbols); one agent *F* <sup>∗</sup> , implementing filter *F*; one agent *G*<sup>∗</sup> , providing supervision on other agents interaction (in fact, implementing ubiquitous generation by application of rules to multisets, generated at previous steps). Agent *G*<sup>∗</sup> uses storage *VS* for accumulation of all generated terminal multisets, satisfying filter *F*. Also *G*<sup>∗</sup> operates storage *V*, containing current set of generated multisets, which are not yet transferred to other agents. Initial state of *V* is f g *v*<sup>0</sup> . Agents communicate via network *N*.

Described multi-agent system is operating according to the definition of mathematical semantics of *FMG* (15)–(26). Set of messages, which are circulating between the agents, is represented in **Table 1**.

**Figure 4.** *Multi-agent system implementing* FMG.


*Multi-Agent Implementation of Filtering Multiset Grammars DOI: http://dx.doi.org/10.5772/intechopen.93303*

#### **Table 1.**

*Vs* ¼ *V*h i *<sup>v</sup>*0,*<sup>R</sup>* ↓*F:* (26)

Verbally, *Vs* is subset of *V*h i *<sup>v</sup>*0,*<sup>R</sup>* , which includes only such elements of this set, that satisfy filter *F*. Generalized scheme of application of filtering multiset gram-

After description of syntax and semantics of filtering multiset grammars we may move to their implementation issues, which background are multi-agent

Due to granularity and natural internal parallelism of multigrammatical representation it is perspective to try to use multi-agent paradigm as a background for implementation of the *FMG* application engine (*AE*), providing generation of

We shall use scheme, depicted at **Figure 4**, as a basis for primary multi-agent implementation of *FMG AE*. Proposed multi-agent system implementing *FMG S* ¼ h i *v*0, *R*, *F* , contains *l* ¼ j j *R* agents *r*1, … ,*rl*, each corresponding to one rule from set *R* (everywhere below we shall denote rules and implementing them agents by the same symbols); one agent *F* <sup>∗</sup> , implementing filter *F*; one agent *G*<sup>∗</sup> , providing supervision on other agents interaction (in fact, implementing ubiquitous generation by application of rules to multisets, generated at previous steps). Agent *G*<sup>∗</sup> uses storage *VS* for accumulation of all generated terminal multisets, satisfying filter *F*. Also *G*<sup>∗</sup> operates storage *V*, containing current set of generated multisets, which are not yet transferred to other agents. Initial state of *V* is f g *v*<sup>0</sup> . Agents communi-

Described multi-agent system is operating according to the definition of mathe-

matical semantics of *FMG* (15)–(26). Set of messages, which are circulating

**3. Basic techniques of the multi-agent implementation**

*Computational Optimization Techniques and Applications*

mars is presented at **Figure 3**.

**of multisets generation**

technologies.

multisets.

cate via network *N*.

**Figure 4.**

**222**

*Multi-agent system implementing* FMG.

between the agents, is represented in **Table 1**.

*Set of MAS messages.*

All messages are couples, the first components of which are numbers of multisets, processed by the agents, and every *MS* has its unique number. Assigning numbers to multisets is performed by agent *G*<sup>∗</sup> . Current maximal number is denoted *<sup>J</sup>*. Also agent *<sup>G</sup>*<sup>∗</sup> uses variable *<sup>Z</sup>*, which value is set of couples h i *<sup>j</sup>*, *<sup>n</sup>* , where *n* is number of agents *ri* which until current moment have not sent to *G*<sup>∗</sup> messages with results of application of corresponding rule to *j*th *MS*.

Agent *<sup>G</sup>*<sup>∗</sup> sends couple h i *<sup>j</sup>*, *<sup>v</sup>* to all agents *ri*. After this, *<sup>G</sup>*<sup>∗</sup> joins to the current value of variable *Z* couple h i *j*, *l* . Every agent *ri*, receiving message h i *j*, *v* from agent *G*<sup>∗</sup> , tries to apply *v* to rule *ri*. If application is possible, *ri* sends to *G*<sup>∗</sup> message *j*, *v*<sup>0</sup> , where *v*<sup>0</sup> is result of application of rule *ri* to *MS v*. Otherwise *ri* sends to *G*<sup>∗</sup> message h i *<sup>j</sup>*, Øf g . Agent *<sup>G</sup>*<sup>∗</sup> , receiving message h i *<sup>j</sup>*, *<sup>v</sup>* , where *<sup>v</sup>* 6¼ f g <sup>Ø</sup> , assigns *<sup>J</sup>* new value *J* þ 1, and sends message h i *J*, *v* to all agents. Also couple h i *J*, *l* is joined to *Z*, and couple h i *j*, *q* ∈ *Z* is eliminated from set *Z*, that means at least one rule was applied to *<sup>j</sup>*th *MS*, so this multiset is non-terminal. If agent *<sup>G</sup>*<sup>∗</sup> receives message h i *<sup>j</sup>*, Øf g from *ri*, that means rule *ri* was not applied to *j*th multiset, and h i *j*, *q* ∈ *Z* is replaced by h i *j*, *q* � 1 . If now h i *j*, 0 ∈*Z*, that means no one rule was applied to *j*th *MS*, that's why it is terminal, and, according to *FMG* semantics, it must be filtered. So agent *G*<sup>∗</sup> sends couple h i *<sup>j</sup>*, *<sup>v</sup>* to agent *<sup>F</sup>* <sup>∗</sup> , which provides testing, whether *<sup>v</sup>* satisfies boundary subfilter *<sup>F</sup>* <sup>≤</sup> <sup>⊆</sup>*F*. If testing is successful, agent *<sup>F</sup>* <sup>∗</sup> sends to agent *<sup>G</sup>*<sup>∗</sup> message h i *<sup>j</sup>*, 1 , otherwise—message h i *j*, 0 . In the case h i *j*, 1 couple h i *j*, *v* is joined to the current value of variable *Vs*. After no active agents *ri* remain, agent *G*<sup>∗</sup> applies optimizing subfilter *Fopt* ⊆*F* to the aforementioned current value *Vs*, eliminating from it all multisets, which do not satisfy *Fopt*. Final value of variable *Vs* is exactly set of terminal multisets, defined by *FMG S* ¼ h i *v*0, *R*, *F* .

As may be seen, proposed multi-agent system provides generation and filtration of multisets by parallel operation of all agents, entering this *MAS*.

However, there are some evident bottlenecks, limiting speed of multisets generation. Most essential of such bottlenecks are massive transmissions of multiply repeated sets of multiobjects via *MAS* communication network. To reduce such transmission it is possible not to send *MO* to agents *ri* such, that corresponding them rules are applicable to multisets, having place in the storage *V,* and this applicability may be recognized directly by agent *G*<sup>∗</sup> . If such opportunity may be implemented, only those agents *ri*, which, possibly, may apply corresponding rules to current *MS*, would receive it. By this measure, traffic on *MAS* communication network may be reduced sharply.

To implement proposed logics, we shall introduce auxiliary database *L*, which elements would be couples h i *a*, f g h i *i*1, *n*<sup>1</sup> , … ,h i *ik*, *nk* , where *a* is name of object, and in couples h i *i*, *n* , entering the set, which is second component of the couple, integer *i* is number of the rule, which left part contains multiobject *n* � *a*.

**Example 6.** Let scheme *R* ¼ f g *r*1,*r*<sup>2</sup> , where *r*<sup>1</sup> is

$$\{\mathcal{9} \cdot (eur)\} \to \{\mathbf{10} \cdot (usd)\},$$

18 � ð Þg *pound* . As seen, multiplicity of object ð Þ *pound* is not transferred to agent *r*,

tion network and, thus, total time of generation of *STMS*, defined by *FMG*.

Proposed techniques provides further reduction of traffic on *MAS* communica-

Application of the described *MAS*-based generation of *STMS* is flexible as it is only possible: due to granularity of multigrammatical knowledge representation local corrections of *FMG* by replacement of one rules by another are easily reflected by corresponding replacement of only concerned agents without touching the other. The same may be done with *FMG* filters. Such flexibility provides the simplest implementation of the most practically useful "what-if" regimes of application of *MG*-centered knowledge-based decision support systems.

Proposed techniques of application of multi-agent technology to the highparallel generation of sets of multisets, defined by filtering multiset grammars, provides essential growth of speed of creation of *STMS*. However, there are some evident ways of further enhancement of *FMG* implementation upon this

• development of methods of matching constructed *MAS* to real homogeneous or heterogeneous hardware in such a way that delays, caused by information

• development of more efficient *MAT* application techniques concerning some more particular cases of *MG* – first of all, filtering context-free multiset grammars as well as filtering unitary *MG* and unitary multiset metagrammars;

• development of *MAT*-based techniques of implementation of algorithmics of unitary multiset metagrammars as most practically useful tool of the *MG*

Author is grateful to Prof. Fred Roberts and Prof. Alexey Gvishiani for useful

• design of special-purpose computing environments suitable for direct

implementation of *FMG* and other dialects of *MG* family;

exchange between agents, would be minimal;

because this object does not enter rule *r*.∎

*DOI: http://dx.doi.org/10.5772/intechopen.93303*

*Multi-Agent Implementation of Filtering Multiset Grammars*

**4. Conclusion**

background:

family.

discussions.

**225**

**Acknowledgements**

and *r*<sup>2</sup> is

$$\{\mathbf{5} \cdot (eur), \mathbf{3} \cdot (rur)\} \to \{\mathbf{7} \cdot (usd)\}.$$

Then *L* ¼ f g <ð Þ *eur* , f g <1, 9>, <2, 5> > , < ð Þ *rur* , f g <2, 3> > *:*∎

Database *L* has such internal organization, that there exists associative index, providing direct selection of couple h i *a*, *w* for object name *a*. To reduce search in the selected list of couples h i *i*, *n* , it may be created as ordered by increase of multiplicities *<sup>n</sup>*. Let *<sup>v</sup>* <sup>¼</sup> f g *<sup>n</sup>*<sup>1</sup> � *<sup>a</sup>*1, … , *nm* � *am* be a current multiset processed by agent *<sup>G</sup>*<sup>∗</sup> , and *Q* ¼ f g h i *a*1, ≤ *n*<sup>1</sup> , … ,h i *am*, ≤ *nm* is set of queries to database *L*, each providing selection of couples *ai*, *j i* <sup>1</sup>, … , *j i ki* D E n o , such that *ni <sup>p</sup>* ≤*ni*. It is clear, that only in this case rules *r <sup>j</sup> i* 1 , … ,*r <sup>j</sup> i ki* may have opportunity to be applied to *MS v*, and, totally, only those rules, in which all multiobjects from their left parts have multiplicities hot greater than those of the same objects having place in *v*. So there is an evident criterion for selection of rules, which may be applicable to the current multiset *v*.

**Statement 1.** Let *ai*<sup>1</sup> h i , *N*<sup>1</sup> , … , *aip* , *Np* n o D E be a set, selected from database *<sup>L</sup>* by query *Q* ¼ f g h i *a*1, ≤*n*<sup>1</sup> , … ,h i *am*, ≤*nm* , corresponding to multiset *v* ¼ f g *n*<sup>1</sup> � *a*1, … , *nm* � *am* , and *n <sup>j</sup>* <sup>1</sup> � *a <sup>j</sup>* 1 , … , *n <sup>j</sup> <sup>s</sup>* � *a <sup>j</sup> s* � � be the left part of rule *r*. Then *r* may be applicable to *v*, if

$$\{a\_{\;j\_1}, \ldots, a\_{\;j\_r}\} \subseteq \{a\_{\;j\_1}, \ldots, a\_{\;j\_p}\}.\tag{27}$$

As seen, proposed associative organization of set of left parts of rules entering scheme *R* provides fast selection of sets of rules, which may be applied to the current multiset.

Let us consider further enhancement of *FMG* application engine, based on the multi-agent technology.

First of all, it is evident, that it is not necessary to send all multiobjects of multiset *v*, to which rule*ri* is applicable, to agent *ri*, because replacement of left part of this rule by its right part is local operation, regarding in general case relatively small number of multiobjects in the processed multiset *v*, while all the rest *MO* remain unchanged. So it is sufficient to send to agent *ri* only tuple *f* <sup>1</sup>*ni*<sup>1</sup> , … , *ft nit* � � of multiplicities of objects *ai*<sup>1</sup> , … , *ait* , in *MS v*, such that tuple *A* ¼ *ai*<sup>1</sup> , … , *ait* h i is ordered lexicographically set of objects, having place in both left and right parts of rule *r*, and signs *fi* before multiplicities *ni <sup>j</sup>* of objects *ai <sup>j</sup>* , having place in left side of rule *r*, are "–", while all other are "+". Receiving this tuple, agent *r* provides computation of tuple *ni*<sup>1</sup> , … , *nit* h i, where *nj* ¼ *n <sup>j</sup>* þ *f <sup>j</sup> ni j* � �, *<sup>j</sup>* <sup>¼</sup> 1, … , *<sup>t</sup>*. (There may be particular case, when some objects do enter both left and right parts but this singularity is simply handled by positioning to the *j*th place of tuple *A* number �*n* þ *n*<sup>0</sup> , where *n* is multiplicity of object *ai <sup>j</sup>* in the left part, and *n*<sup>0</sup> –its multiplicity in the right part of rule *r*).

**Example 7.** Let *v* ¼ f g 5 � ð Þ *eur* , 10 � ð Þ *usd* , 7 � ð Þ *rur* , 18 � ð Þ *pound* , and *r* is f g 3 � ð Þ *eur* , 2 � ð Þ *rur* ! f g 5 � ð Þ *usd* . Because set of lexemes, entering this rule, is ordered lexicographically as h i *eur*,*rur*, *usd*, so tuple, sent by agent *<sup>G</sup>*<sup>∗</sup> to agent *<sup>r</sup>*, would be 5, 7, 10, h i and agent *<sup>r</sup>* would sent to agent *<sup>G</sup>*<sup>∗</sup> tuple 5h i � 3, 7 � 2, 10 <sup>þ</sup> <sup>5</sup> <sup>¼</sup> h i 2, 5, 15 , and, thus, result of *v* ) *r v*<sup>0</sup> would be *v*<sup>0</sup> ¼ f2 � ð Þ *eur ;* 15 � ð Þ *usd ;* 5 � ð Þ *rur ;*

18 � ð Þg *pound* . As seen, multiplicity of object ð Þ *pound* is not transferred to agent *r*, because this object does not enter rule *r*.∎

Proposed techniques provides further reduction of traffic on *MAS* communication network and, thus, total time of generation of *STMS*, defined by *FMG*.

Application of the described *MAS*-based generation of *STMS* is flexible as it is only possible: due to granularity of multigrammatical knowledge representation local corrections of *FMG* by replacement of one rules by another are easily reflected by corresponding replacement of only concerned agents without touching the other. The same may be done with *FMG* filters. Such flexibility provides the simplest implementation of the most practically useful "what-if" regimes of application of *MG*-centered knowledge-based decision support systems.
