*2.2. Reconfigurable S3PR Net*

This section presents definitions and theorems in the reconfigurable S3PR nets, which are originally proposed by [34,35,39].

**Definition 20.** *Let N* <sup>=</sup> *({p0}* ∪ *PA* ∪ *PR, T, F, W, Mo, K) be a finite-capacity S3PR, where p0, PA, PR, T, F, W, and Mo are defined in Definitions 1–6. K: PC* <sup>→</sup> *IN is the function of capacity that assigns to each place p the maximal number of tokens K(p).*

**Definition 21.** *Let (Ni, Mi) be two S3PR nets with Ni* = *(PCi, Ti, Fi, Wi, Mi, Ki), i*= *1, 2. N1 and N2 are called morphism nets if there exists a bijection* Ψ*: N1* → *N2,* Ψ = *(*Ψ*PC: PC1* → *PC2,* Ψ*T: T1* → *T2) such that for all a, b* ∈ *PC1* ∪ *T1, F1(a, b)* ∈ *N1* = *F2(*Ψ*(a),* Ψ*(b))* ∈ *N2, and for all p* ∈ *PC1, M1(p)* ≤ *M2(*Ψ*PC(p)).*

**Definition 22.** *Let (Ni, Mi) be two S3PR nets with Ni* = *(PCi, Ti, Fi, Wi, Mi, Ki), i* = *1, 2. N1 is called the full subnet of N2 if there exists an injection function that maps places to places and transitions to transitions, denoted by* ξ*: N1* → *N2,* ξ *(PC1)* ⊆ *PC2, and* ξ *(T1)* ⊆ *T2 such that for all a, b* ∈ *PC1* ∪ *T1, F1(a, b)* = *F2(*ξ *(a),* ξ *(b)).*

*In the algebraic, a rewriting rule is a transformation approach that can change and combine the Petri nets dynamically. The main idea is to define and change the system configurations as a graph rewriting rule.*

**Definition 23.** *Let NR be a reconfigurable S3PR with NR* = *((N, Mo),* R*), where(N, Mo) is an S3PR net with N* = *(PC, T, F, W, Mo, K) and* R = *{rr1, rr2, rr3,* ... *, rrm} is called a set of rewriting rules or dynamic configurations if*


**Definition 24.** *Let NR be a reconfigurable S3PR with NR* <sup>=</sup> *((N, Mo),* R*). A new rewriting reconfigurable net NR is an S3PR net (NR, MR) with NR* = *(PC, T, F, W, MR, K), and a net (N, Mo) is called the initial state of the rewriting net model.*

**Definition 25.** *Let NR be a reconfigurable S3PR with NR* = *((N, Mo),* R*). A state graph in NR is a labeled directed graph whose nodes are the marking of NR, expressed as:*

	- *2.1. a* ∈ •ξ*(b)* ⇒ *b* ∈ •ϕ *and a* ∈ ξ*(b)* ⇒ *b* ∈ ϕ•*.*
	- *2.2. N1* = *(PC1, T1, F1, W1, M1, K1) and N2* = *(PC2, T2, F2, W2, M2, K2) holds the following: PC2* = *PC1* − ξ*(PC1L)* + *PC1R and T2* = *T1* − ξ*(T1L)* + *T1R. Note that* −*(*+*) means deleting(inserting) places or transitions from (to) N1 and the places name of PC1R and T1R inserted into N1 must be di*ff*erent to prevent clashes.*

**Definition 26.** *Let NR be a reconfigurable S3PR with NR* = *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2). A net N1 is the restriction of a net N2 if PC1* ⊆ *PC2, T1* ⊆ *T2, and F1* = *F2* ∩ *((PC1* × *T1)* ∪ *(T1* × *PC1)) and expressed by N1* ⊆ *N2.*

**Definition 27.** *Let NR be a reconfigurable S3PR with NR* = *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2). The set of weighted arcs (flow relation) F2 is expressed as:*

$$F\_2(a,b) = \begin{bmatrix} F\_1(a,b) & \text{if } a \notin \mathbb{R} \land b \notin \mathbb{R} \\ F\_R(a,b) & \text{if } a \in \mathbb{R} \land b \in \mathbb{R} \\ \sum\_{b\_i \in \bullet qb} F\_1(a,\xi(y\_i)) & \text{if } a \notin \mathbb{R} \land b \in \mathbb{R} \\ \sum\_{a\_i \in \bullet q \bullet a} F\_1(\xi(a\_i),b) & \text{if } a \in \mathbb{R} \land b \notin \mathbb{R} \end{bmatrix} \tag{2}$$

**Definition 28.** *Let NR be a reconfigurable S3PR with NR* = *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2). The marking of M (p), p* ∈ *PC2, is expressed as:*

$$M'(p) = \begin{cases} M(p) & \text{if } p \notin \mathcal{R} \\ \sum\_{p' \in \text{opp}} M(\pounds(p')) & \text{if } p \in \mathcal{R} \end{cases} \tag{3}$$

**Theorem 1.** *Let NR be a reconfigurable S3PR with NR* <sup>=</sup> *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2), PC1, T1* - ∅ *and* R = *{rr}, rr* = *{L, R,* ϕ*,* •ϕ*,* ϕ•*}. If L and R are a single place or single transition, then the obtained N2 by rr is equal to N1.*

**Proof.** Straightforward. -

**Theorem 2.** *Let NR be a reconfigurable S3PR with NR* <sup>=</sup> *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2), PC1, T1* - ∅ *and* R = *{rr}, rr* = *{L, R,* ϕ*,* •ϕ*,* ϕ•*}. If (N1, M1) is bounded, L is a single place or single transition and R is an S3PR net, then the resulting (N2, M2o) net by rr is bounded.*

**Proof.** The rewriting of *N2* using *rr* is similar to replacing a place/transition by the S3PR net. Therefore, the boundedness can be established by checking if the S3PR net is well constructed and behaved. The resulting net (*N2*, *M2o*) maintains the boundedness because the S3PR net is well constructed and behaved. -

**Corollary 1.** *Let NR be a reconfigurable S3PR with NR* = *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2), PC1, T1* - ∅ *and* R = *{rr}, rr* = *{L, R,* ϕ*,* •ϕ*,* ϕ•*}. If (N1, M1o) is bounded, L is an S3PR Petri net and R is a single place or single transition, then the resulting net (N2, M2o) by rr is bounded.*

**Corollary 2.** *An S3PR net (N2, M2o) can be a bounded net and a full subnet of (N1, M1o).*

**Theorem 3.** *Let NR be a reconfigurable S3PR with NR* <sup>=</sup> *((N, Mo),* R*). Let N1 and N2 be two states in NR with N1* = *(PC1, T1, F1, W1, M1o, K1) and N2* = *(PC2, T2, F2, W2, M2o, K2), PC1, T1* - ∅ *and* R = *{rr}, rr* = *{L, R,* ϕ*,* •ϕ*,* ϕ•*}. If (N1, M1o) is bounded, L is an S3PR net and R is an S3PR net, then the resulting net (N2, M2o) by rr is bounded.*

**Proof.** The rewriting of *N2* using *rr* is similar to replacing an S3PR net by another S3PR net. Therefore, the boundedness can be established by checking if the S3PR net is well constructed and behaved. The resulting net (*N2*, *M2o*) maintains the boundedness because the S3PR net is well constructed and behaved. -

Based on Definitions 20–28 and Theorems 1–3, the developed reconfiguration procedures for S3PR net algorithm are constructed as follows:

**Algorithm 1:** *Reconfiguration procedures for S3PR net*

*Input: An S3PR net (No, Mo) Output: A reconfigurable S3PR net (NR, MRo) Initialization: Generate dynamic configurations* <sup>R</sup> <sup>=</sup> *{rr1, rr2, rr3,* ... *, rrm} k*=0. *Step 1: while* <sup>R</sup> - <sup>∅</sup> *do k* = *k*+*1* 1.1. *Build rrk* = *{Lk, Rk,* ϕ*k,* •ϕ*k,* ϕ*<sup>k</sup>* •*}.* 1.2. *Build Lk* = *(PCLk, TLk, FLk, WLk, MLko, KLk).* 1.3. *Build Rk* = *(PCRk, TRk, FRk, WRk, MRko, KRk).* 1.4. *Build* •ϕ*<sup>k</sup> and* ϕ*<sup>k</sup>* •*.* 1.5. *Build* ξ*k: Nk-1* → *Nk.* 1.6. *Apply rewriting rule rrk: Nk rrk* <sup>→</sup> *Nk*−*1.* 1.7. *Update the flow relation Fk as follows: Fk*(*a*, *b*) = ⎡ ⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣ *Fk*−1(*a*, *b*) if *a Rk* ∧ *b Rk <sup>F</sup>*(*k*−1)*R*(*a*, *<sup>b</sup>*) if *<sup>a</sup>* <sup>∈</sup> *Rk* <sup>∧</sup> *<sup>b</sup>* <sup>∈</sup> *Rk bi*∈•ϕ*b Fk*−1(*a*, ξ(*yi*)) if *a Rk* ∧ *b* ∈ *Rk ai*∈ϕ•*a Fk*−1(ξ(*ai*), *b*) if *a* ∈ *Rk* ∧ *b Rk*

1.8. *Calculate the initial marking of Nk*

$$M\_{k\boldsymbol{\alpha}}(p) = \begin{bmatrix} M\_{(k-1)\boldsymbol{\alpha}}(p) & \text{if } p \in P\_{\boldsymbol{R}\boldsymbol{\omega}}, P\_{\boldsymbol{R}} \in R\_k\\ 0 & \text{if } p \in P\_{\boldsymbol{A}\boldsymbol{\omega}}, P\_{\boldsymbol{A}} \in R\_k \end{bmatrix}$$

⎤

⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦

1.9. R = R\*CR.* /*\* CR is covered rrk\**/ *end while Step 2: Output a reconfigurable S3PR net (NR, MRo) Step 3: End*

To illustrate the proposed Algorithm 1, reconsider the initial S3PR net (*No*, *Mo*) illustrated in Figure 2. Suppose that the first system configuration includes adding new machine. In this scenario, a new machine M2 is assigned to the system (*No*, *Mo*) to process a part after M, a robot is needed to load/unload a part to/from M2. To model the addition of new machine by using the synthesis procedure of Algorithm 1, we construct a configuration as a rewriting rule R = {*rr1*} with *rr1* = {*L1*, *R1,* ϕ*1*, •ϕ*1*, ϕ*<sup>1</sup>* •}, where *L1* and *R1* are illustrated in Figures 3a and 3b, respectively. We have ξ*1: N1* → *No*, ϕ*<sup>1</sup>* = ({*p1*, *p6*, *p7*, *p8*, *p9*},{*t4*, *t5*, *t6*}), •ϕ*<sup>1</sup>* = ({*L1.t4*},{*R1.t4*}), and ϕ*<sup>1</sup>* • = ({*L1.p1*, *L1.p6*},{*R1.p1*}). Then the obtained reconfigurable S3PR net (*N1*, *M1o*) is illustrated in Figure 3c.

**Figure 3.** A reconfigured S3PR net by addition of new machine. (**a**) Left hand side net *L*. (**b**) Right hand side net *R*. (**c**) A reconfigurable S3PR net (*N1*, *M1o*).

The second configuration includes adding a new product. In this scenario, a new product (part B) is assigned to a system, which indicates that a new operation sequence is assigned and the system requires an adjustment to its Petri net model structure. To model the addition of new product by using the synthesis procedure of Algorithm 1, we constructed a configuration as a rewriting rule R = {*rr2*} with *rr2* = {*L2*, *R1,* ϕ*2*, •ϕ*2*, ϕ*<sup>2</sup>* •}, where *L2* and *R2* are illustrated in Figures 4a and 4b, respectively. We have ξ*2: N2* → *N1*, ϕ*<sup>2</sup>* = ({*p5*, *p6*, *p10*, *p11*, *p12*, *p13*},{*t7*, *t8*, *t9*, *t10*}), •ϕ*<sup>2</sup>* = ({*L2.p5*, *L2.p6*},{*R2.t7*}), and ϕ*<sup>2</sup>* • = ({*L2.p5*, *L2.p6*},{*R2.t10*}). Then the obtained reconfigurable S3PR net (*N2*, *M2o*) is illustrated in Figure 4c.

The third system configuration involves rework. In this scenario, a part can be inspected after all operations have been completed. The system can proceed on the basis of the original sequence of operation if the configuration is carried out properly. Otherwise, rework is needed. By using Algorithm 1, the production operations of the reworked part can be exactly and easily modeled by considering rework operations as alternative sequences. Reconsider the reconfigurable S3PR net (*N2*, *M2*) illustrated in Figure 4c. Suppose that an inspection machine M3 is added to a system and that part B is processed in M1. Then, part B is moved to M3 by Robot 1 to check if there are defects in part B. If part B performed properly, then it will leave the system by Robot 1. Otherwise, if part B has defects, rework is needed, and part B is moved to M1 by Robot 1. To model the rework operation by using the synthesis procedure of Algorithm 1, we construct a configuration as a rewriting rule R = {*rr3*} with *rr3* = {*L3*, *R3,* ϕ*3*, •ϕ*3*, ϕ*<sup>3</sup>* •}, where *L3* and *R3* are illustrated in Figure 5a,b, respectively. We have

ξ*3: N3* → *N2*, ϕ*<sup>3</sup>* = ({*p5*, *p6*, *p10*, *p11*, *p12*, *p13*, *p14*, *p15*, *p16*, *p17*},{*t7*, *t8*, *t9*, *t10*, *t11*, *t12*, *t13*, *t14*, *t15*}), •ϕ*<sup>3</sup>* = ({*L3.t7*},{*R3.t7*}), and ϕ*<sup>3</sup>* • = ({*L3.t10*},{*R3.t14*}). Then the obtained reconfigurable S3PR net (*N3*, *M3o*) is illustrated in Figure 5c.

**Figure 4.** A reconfigured S3PR net by addition of new product. (**a**) Left hand side net *L*. (**b**) Right hand side net *R*. (**c**) A reconfigurable S3PR net (*N2*, *M2o*).

**Figure 5.** A reconfigured S3PR net by rework. (**a**) Left hand side net L. (**b**) Right hand side net R. (**c**) A reconfigurable S3PR net (N3, M3o).

Finally, a configuration includes adding a new robot. In this scenario, a new robot R2 is assigned to the system (*N3*, *M3o*) to load/unload a part A to/from M1 and M2. To model the addition of the new robot by using the synthesis procedure of Algorithm 1, we construct a configuration as a rewriting rule R = {*rr4}* with *rr4* = {*L4*, *R4,* ϕ*4*, •ϕ*4*, ϕ*<sup>4</sup>* •}, where *L4* and *R4* are illustrated in Figure 6a,b, respectively. We have ξ*4: N4* → *N3*, ϕ*<sup>4</sup>* = ({*p1*, *p2*, *p3*, *p4*, *p6\_1*, *p6\_2*, *p7*, *p8*, *p10*, *p11*, *p12*, *p14*, *p15*, *p16*},{*t1*, *t2*, *t3*, *t4*, *t5*, *t6*, *t7*, *t8*, *t9*, *t10*, *t11*, *t12*, *t13*, *t14*, *t15*}), •ϕ*<sup>4</sup>* = ({*L4.t1*, *L4.t7*},{*R4. t1*, *R4. t7*}), and ϕ*<sup>4</sup>* • = ({*L4. t6*, *L4. t14*}, {*R4.t6*, *R4.t14*}). Then the obtained reconfigurable S3PR net (*N4*, *M4o*) is illustrated in Figure 6c.

**Figure 6.** A reconfigured S3PR net by addition of a new robot. (**a**) Left hand side net *L*. (**b**) Right hand side net *R*. (**c**) A reconfigurable S3PR net (*N4*, *M4o*).
