Colored Resource-Oriented Petri Net Based Ladder Diagrams for PLC Implementation in Reconfigurable Manufacturing Systems

A typical example of discrete event systems (DESs) is a reconfigurable manufacturing system (RMS) whose can be changed and become more complicated during its operation. Thus, an effective tool needs to be developed to create both high- and low-level DES implementation. The ladder diagram (LD) is a common programming method for controlling DESs. Petri nets (PNs) represent the most important graphical and mathematical tool that can be used to provide an integrated solution for the design, modeling, analysis, control, and implementation of DESs. Various types of PN-based LDs are developed for DESs, which have high structural complexity of the LDs. Therefore, an approach that can facilitate the elimination of the LDs’ structural complexity needs to be developed. The main objective of this paper is to develop a two-step approach for LDs implementation for RMSs with dynamic changes. First, a colored resource-oriented Petri net (CROPN)-based algorithm is proposed for a rapid and valid configurations of an RMS. Second, a ladder diagram colored resource-oriented Petri net (LDCROPN) is developed to convert the CROPN into an LD. The developed approach is evaluated using examples in the literature. Moreover, the results demonstrate the effectiveness of the developed approach for LD implementation under RMS specification changes.


I. INTRODUCTION
A reconfigurable manufacturing system (RMS) is described as a sequence of events with discrete states and a state evolution, which occur according to the events that define the system state. RMS requires a control program that exhibit several characteristics, such as rapidity, validity, and flexibility, to achieve configurations, including the addition of new products, addition of new handling device, processing rework, and addition of new machines. Appropriate modeling and the formulation of a rapid control logic using mathematical and graphical tools are among the most peculiar methods to achieve more feasible control logic for rapid and valid configurations in RMS.
The associate editor coordinating the review of this manuscript and approving it for publication was Chaitanya U. Kshirsagar.
Programmable logic controllers (PLCs) are the main tools used in industrial automation. They are utilized in systems requiring the implementation of logical sequencing, operations, and numerical and timing computation. The everincreasing complexity of the PLC software and user-imposed operational and security specifications require new techniques to meet the control requirements. Petri nets (PNs) are a very interesting and useful graphical and mathematical tool for the modeling and control of manufacturing systems [1]- [17]. Indeed, PNs have advantages over other languages, including simple graphical representation (circles, rectangles, and arcs), structured algorithms, and simple algebraic representation [18], [19]. Moreover, they enable the implementation of parallelism, causality, and synchronization [20]. When the controlled system is achieved by PNs, it has to be converted into a PLC to enable its implementation. VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ PLCs have become the cornerstone in executing the automation tasks. According to IEC 61131-3, the International Electrotechnical Commission has defined five PLC languages: the structured text (ST) [21], the ladder diagram (LD) [22], the functional block chart (FBD) [23], the instruction list (IL) [24], and the Grafcet or sequential function chart (SFC) [25]. Among them, the ladder diagram is the most popular PLC language, primarily because it can be heuristically performed. PLC programs can be easily written for simple systems using ladder diagram. However, the consideration of multiple systems complicates the problem. Indeed, if the system is individual in type and multiproduct in heuristic approaches, writing down the ladder logic programs is impossible [26], [27]. The most successful solutions for this problem are the use of PNs and the heuristic transformation of PN into LD. Various methods developed using PNs in LD have been employed in the modeling, simulation, analysis, and control of transformation algorithms [28]- [42]. Using the token pass ladder logic (TPLL), Jones et al. [28], [29] design a concept for the conversion of PN into LD. In this method, the mechanism for primary control in PNs is considered as the token. The control of the program is performed using flags or auxiliary relay. The technique is extended by using delay timers in various contexts to include timed-transition PNs. The basic structure and related ladder logic equivalents of the timedtransition PNs are established. However, the number of the basic elements of PNs, which has significantly increased, has rendered the implementation of the PN difficult.
Uzam et al. [30]- [33] present the TPLL method for the conversion of the colored PN controllers into an LD in both the methodology and application. This method can also provide a simple mapping between the basic information on sequencing and programming steps. The basic structures and related LD equivalents of the timed-transition PNs are described. In addition, a heuristic PN controller is developed for DESS and a structured LD methodology. The method is also extended to include the formal structures of actuators and sensors. Uzam et al. have listed a set of additional features for ordinary PNs, thus enabling the sensor readings to be inserted during transitions and the control of the impulse and level of actuators, which results in an automation PN (APN). The work in [34] proposes the technique of bottomup synthesis including the structure of a system controlled APN reachability graph. A controller of the system that is obtained by using the token pass marking (TPM) rules and the uncontrolled APN model is associated with the prohibited state requirements. The TPM rules are directly derived from the prohibited state requirements. In addition, the TPM rules are implemented using a mixture of enabling and inhibitor arcs that connect the appropriate places to the transitions of the corresponding controllers.
In Feldmann [36], logical control structures are designed and implemented to enable a combination of the features of traditional methods for designing the PLC code and to avoid drawbacks such as the lack of relevant validation.
In combination with some extensions, they first present the ordered colored PNs (OCPNs) as a logic controller modeling tool. The OCPN's logical control system model consists of two main structures: a coordination system model, and a submodel for some elements of the first model, obtained following a transitional refinement. Then, a structural analysis of the net will conduct the validation of both the model and the logic structure control requirements. They then propose an automated technique for creating a PLC code from a validated OCPN textual description. Park et al. [37] develop a method based on Petri nets for the development of control logic for machining systems. Two Petri nets are used to represent the control logic: one for mode decision and the other for the sequence. The Petri net control logic for each process can be created by replacing the I / O for the corresponding sensors, actuators, and operator commands from the operation module templates. The proposed Petri net control logic is still under study and it is anticipated to automatically generate the verified IEC1131-3 control logic code. Frey [38] defines a special type of Petri nets, which includes more information, named the signal interpreted Petri net (SIPN) and develops a transformation technique from SIPN to LD in which programmable logic controller input and output signals are defined for each transition and event. In addition, for each place there is a Boolean function value assigned. In the study of Borges and Lima the SIPN is used to design two educational techniques in laboratory classes: to transform the SIPN into ladder diagram for PLC and to transform the SIPN into C language for Arduino microcontroller. In [40], the JAVA application is developed for flexible manufacturing systems (FMS) to model a Petri net supervisor based on the signal interpreted Petri net and theory of regions, and is then converted into the corresponding LIST code approved by the PLC. Then, the obtained code is verified using the SIEMENS STEP7 compiler.
In [41], a technique is developed for creating the related LD for the PLC using Petri net models, which has been demonstrated to be efficient by the application to a sequence controller of a small-scale robotic system. The experimentation is carried out with Allen Bradley PLC for programming in an educational system. The developed method considers the LD rows to be two parts the ''conditional part'' and the ''action part'' as shown in the PLC's memory, and then assigns a bit for a place in the conditional part of the Petri net, and another bit for a transition in the action part of the Petri net. Luo et al. [42] introduce an ordinary Petri net-based method for modeling and race-detection issues of programs for PLCs. In the first step, a PLC program is generated by a graph to reflect contacts and coils. The second step is to convert this graph into an ordinary Petri net using a conversion algorithm. Third, a technique is developed to determine whether a race occurs in a system using a reachability graph approach, to locate a race by adding the race path, and to fix a race by evaluating its subnet.
Feio et al. [43] propose a set of rules for the conversion of input-output place-transition (IOPT) Petri net models [44], [45] into an LD. These rules are integrated in a programming tool that reads the IOPT model represented in the PNML format, and creates the LD. Kaid et al. [35] suggest a Petri net-based methodology for the prevention of deadlocks and create PLC codes for an automated manufacturing system (AMS). First, the controlled Petri net model is constructed using a deadlock-prevention method based on strict minimal siphons. Second, the controlled Petri net model is transformed into an automation-controlled Petri net model that is further transformed into a controlled token-passing logic (CTPL) model. The obtained CTPL model is then utilized to create the LDs for the automated manufacturing system (AMS). The suggested methodology is verified and evaluated using a real-world system. Wu and Zhou have been active in the field of deadlock avoidance by using the formalism of resource-oriented Petri nets (ROPN) [46], [47]. The ROPN model is developed to describe the dynamic resources competition by parts in an AMS [46], [48]- [64]. In an ROPN, a type of resources is modeled by only one place. It is a type of colored Petri nets with a finite capacity for each place and there is a oneto-one mapping between the places in the AMS model and the resources in the plant, leading to a very compact Petri net model. Colors are used to differentiate between various jobs and the progress of their processing in the AMS [46], [61], [63]. Tokens and directed edges are marked with ROPN colors and the token color can change as it transfers from one place to another. In addition, a deadlock can appear in ROPN only in a circuit and the circuits' number is limited.
Wu [47] develops colored resource-oriented Petri nets (CROPNs), and necessary and sufficient conditions under which a maximally permissive control law is obtained to ensure the deadlock-free operations. In the CROPN, the deadlock freedom of its interactive subnets is verified by the control law. If the control law is applied on each interactive subnet, then the overall CROPN of the system can be shown to be live. Deadlock starvation and blocking have a significant influence on the utilization of AMSs. To resolve this problem, Wu and Zhou [50] develop a novel deadlock-control policy based on CROPN to avoid deadlock completely, which decreases starvation and blocking problems through releasing a number of appropriate jobs into the system and controlling the order of the utilization of a resource based on state information embedded in the system model.
Wu and Zhou [55] present a CROPN modeling approach to handle deadlock avoidance and conflict resolution in automated guided vehicles (AGV) systems with unidirectional and bidirectional routes. Wu and Zhou [54] use the CROPN modeling paradigm to model the AGV system and part processing processes. Then, the two models are integrated through macro transitions. Based on the integrated model, a deadlock-avoidance policy is developed. In addition, Wu and Zhou [61] propose a CROPN based on an approach to minimize the bidirectional AGV traveling time, while both deadlock and blocking are avoided. The proposed approach can provide better solutions compared with other techniques.
In addition, its performance evaluations are performed by experimental studies.
Wu and Zhou [63] propose a novel way for modeling robots in an automated manufacturing system using the CROPN modeling approach. A modeling paradigm leads to the appealing and interesting result, i.e., robots have no contribution to deadlocks. A new deadlock control policy is proposed, which is more permissive than the existing ones when robots are treated as both material handling devices and buffers. Wu et al. [49] propose ROPN to solve the problem of deadlock avoidance in flexible assembly systems (FAS). Based on ROPN, a deadlock control policy is proposed. The proposed control policy is shown to be better than the one in the literature and to be computationally efficient.
The work in [65] is extended by Wu et al. [64]. Wu and Zhou consider sequential problem allocation of resources in AMS, where each processing step requires a single type of resource. The necessary and sufficient conditions are proposed under which a one-step look-ahead maximally permissive deadlock-avoidance policy exists. In addition, a method is established to propose such a policy if it exists. Note that the system in [64] is modeled by the ROPN, and the system in [65] is modeled by traditional process-oriented Petri nets (POPN). The ROPN is considered to be more effective and compact for deadlock avoidance than the POPN [57].
The works in Chen et al. [59] and [48] use the ROPN and the theory of regions to design a deadlock prevention controller for automated manufacturing systems. The relationship between structural properties and bad markings in an ROPN is demonstrated. Then, an efficient deadlock prevention approach is developed. Next, a controller is obtained by simple calculation and only one monitor is required for each strongly connected subnet in an ROPN and there is no redundant monitor at all. Thus, it is structurally very simple.
Chen et al. [56] use an ROPN modeling approach to model a class of AMS to overcome the deadlock control problem. Several types of illegal markings are explored, which can be prevented by structural analysis of ROPN models. For these markings, a deadlock prevention policy is developed for illegal markings in an algebraic method without solving a notorious integer linear programming (ILP) problem. Approaches based on linear programming (LP) are designed to prevent other markings optimally, instead of ILP. Chen et al. [62] use an ROPN modeling approach to model the disjunctive and strict single-type automated manufacturing systems (DS-AMS) in which multiple units of one resource type are needed to support a processing stage. They propose effective techniques to achieve the liveness of an ROPN of a DS-AMS by only enforcing some specific transitions to be controlled using its structural properties.
It is well-known that various kinds of PN-based LDs are developed for DESs. However, these approaches have disadvantages, including their growing complexity when a system is large and the complication that arise when checking and changing the model completely. Therefore, an approach that can reduce the structural complexity of LDs needs to be developed. Thus, this paper is an extension of the work in [2] and aims to propose a novel two-step approach for the implementation of LDs for RMSs with dynamic changes. First, a colored resource-oriented Petri net (CROPN) modeling approach is proposed for a rapid and valid reconfiguration of RMS, and necessary and sufficient conditions under which a maximally permissive control law is obtained to ensure the deadlock-free of RMS operations. Second, a ladder diagram colored resource-oriented Petri net (LDCROPN) is developed to convert the CROPN model into an LD.
The main contributions are summarized as the following aspects.
1. A new method for RMS is developed in this paper for the first time to convert a CROPN into LDs, which has the ability to handle any complex RMS change. 2. A sufficient and necessary condition for liveness of CROPN is presented, which is more succinct than that in [2]. 3. The GPenSIM code is developed for simulation, performance comparison, and validation; the results show that the proposed method has accurate results and low-overhead computation compared with the studies in [1], [66]- [68]. 4. A single common transportation resource place in a CROPN is developed to transport all part types, which has polynomial complexity and has a simpler structure compared with the existing studies. The rest of the paper is organized as follows. In Section II, the synthesis of CROPN is presented. In Section III, how to model the configurations of RMSs by the CROPN is described. The quantitative and qualitative properties of the CROPN are presented in Section IV. The LDCROPN is defined in Section V, and a conversion algorithm for CROPN into LD is presented. Section VI provides the conclusions, advantages, limitations, and future work of this paper.

II. COLORED RESOURCE-ORIENTED PETRI NET
A resource-oriented Petri net (ROPN) considers a part production operation as a part visiting the resources one by one based on its specified processing paths. In ROPN, machines and their buffers are represented as the same type resource, called H-resources [46], [49], [51], [57]. Each resource is designed by a single place. The production operations of the part are designed by the routes on which the parts visit the resources. When each part production operation is designed in an effectively way, the model is very compact, and some useful structural features can be demonstrated. In addition, the ROPN treats the material handling devices as another type of resources, called G-resources [46], [49], [51], [57]. Due to the limited resources in manufacturing systems, a finite capacity Petri net is used with its corresponding transition enabling and firing rules. In an ROPN, a transition models that a part is moved from a resource to another resource. Two steps can be used to model the RMS by the ROPN: (1) model the part production operations irrespective of the material transportation, and (2) model the material handling processes based on step 1 model.
place, indicating a load/unload station, p r is a common transportation resource, indicating the system's transportation resources, and P R = {p 1 , p 2 , p 2 , . . . , p m }, m > 0, is a finite set of resource places in the system. 2. T = {t 1 , t 2 , . . . , t n }, n > 0, is a finite set of transitions with P ∩ T = ∅ and P ∪ T = ∅, 3. C(p) and C(t) are the sets of colors associated with place p i ∈ P and transition t i ∈ T, respectively, where Definition 8 [46]: In Definition 8, t j is process-enabled if condition (1) is satisfied and it is resource-enabled if condition (2) is satisfied. Therefore, t j is said to be enabled if it is both process and resource-enabled. Definition 9 [46]: The marking M resulting from the firing of an enabled transition t at marking M with respect to color b jk is expressed by M [ t M and can be updated from M to M as follows: is a set of reachable markings from M in N , which is denoted by vertices and arcs; vertices reflect markings that are labeled with M k and arcs reflect firing of transitions that are labeled with t. If t fires, then there is an arc from marking M k to marking M l and M l is reached. Let X = [X 1 , X 2 , · · · , X m ] T be a weighted matrix that represents a set of places, where X i , i = 1, 2, · · · , m, is a matrix of integers of dimension h× u i . X is said to be a Place invariant of a CROPN if R o is called an infinite capacity load/unload station of N , and R i (i = 0) is called a machine or a buffer that is called an resource. The route of the operation begins at R o and finishes at R o . For each part, in the presence of more than one route of operation such that R i → R j(i =j) , a path from R i to R j is said to exist. If the part moves from R i to R j , a material handling device, such as a robot or AGV, is used to move the part and is called a transportation resource.
Based on the operation routes and transportation requirements of the system and colored Petri net [1], the design of the CROPN is represented as follows: Consider an example of an automated manufacturing system presented in Figure 1(a) to demonstrate the formulation of a CROPN. The system includes a machine (M1) and a robot (Ro1). M1 (Ro1) produces (holds) one part at a time. For loading/unloading parts, buffers are allocated into the system. Furthermore, the system is used to process part type A and the process sequence of part A is displayed in Figure 1(b). The transportation and operation resources model is displayed in Figure 2. For operation resource, p 1 models M1, and the part A operation sequence is p o → t 010A → p 1 → t 100A → p 0 . For transportation resource, place p r models Ro1. To model the transportation processes of part types, Ro 1 is required for loading part A to p 1 by transition t 010A . Ro 1 is required for unloading part A from p 1 by transition t 100A . These processes can be conducted by place p r . Therefore, place p r and arcs (p r , t 010A ), (t 010A , p r ), (p r , t 100A ), and (t 100A , p r ) are added into the model. Then, to define the initial marking of the developed model, add colored token into place where c t1 denotes transportation resource Ro 1 in the system. The model presented in Figure 2 demonstrates the behavior of the CROPN model. When the requirements in Definition 8 are met, we may say that t is enabled by c pi and c ti . The CROPN marking can be modified in the following way by Definition 9. If transition t 010A fires, it chooses only one colored token c p1 and one colored token c t1 from input places p o and p r , respectively. If t 010A fires, it disposes only one colored token c p1 and one colored token c t1 to output places p 1 and p r , respectively. Finally, if transition t 100A fires, it chooses only one colored token c p1 and one colored token c t1 from input places p 1 and p r , respectively. If t 100A fires, it disposes only one token with color c p1 and one colored token c t1 to output places p o and p r , respectively.

III. DYNAMIC CHANGES DESIGNING BY CROPN A. ADDING A NEW MACHINE
Suppose a new machine M2 is added to the system presented in Figure 1(a) to process part A after M1, and a robot is required to load/unload a part from/to M2. The part A operation sequence is stated as load/unload station → M1→ M2→ load/unload station. To model the new machine with the use of the synthesis procedure of Algorithm 1, new transitions and places can be inserted based on the original CROPN. Reconsider the CROPN model presented in Figure 2(b). Ro 1 is required to transport part A between the load/unload station and M1; to move part A between M1 and M2; and to transport part A between M2 and load/unload station. Therefore, consider the following procedures in order to model the reconfigured system: 1) Add operation route of part A as: Add the transportation operation of part A. Ro 1 is required for the transportation of part A to p 2 by transition t 120A ; these operations can be conducted by place p r ; 3) Add the transitions t 120A and t 200A to the model. The reconfigured model by using the CROPN is presented in Figure 3.

B. ADDING A NEW PRODUCT
Assume a new product part B is added to the system presented in Figure 3, which means adding a new operation path and modifying CROPN structure. The part B operation route is designed by load/unload station → M1→ load/unload  1. for (1, β, i++), select OR i ∈ OR, do 2.
for (1, r Denote a place p a , which relates to R i(j−1) ; 4.
Draw a place p b , which relates to R ij ; 5.
if t abhi requires p r to move part i from p a to p b , then 12.
Denote a place p a , which relates to R iOi ; 17.
Draw arcs (p a , t a0hi ) and (t a0hi , p o ); 19. T: if t a0hi requires p r to move part i from p a to p o , then 22.

End
station. To transport part B between the load/unload station and M1, and to transport part B between M1 and the load/unload station, Ro 1 is required. To model the newly added product by using the procedure of the CROPN synthesis, consider the following procedures: 1) Add a new route: 2) Add the transportation operation of part B. Ro 1 is required for loading part B to p 1 by transition t 010B , and Ro 1 is required for unloading part B from p 1 by transition t 100B ; 3) Add the transitions t 010B and t 100B to the model; 4) Set the initial colored token c p2 into place p o that denotes part B. The reconfigured model by using the CROPN is presented in Figure 4.

C. REWORK
Suppose an inspection machine M3 is added to the system presented in Figure 4. Part B can be inspected after some of its operations have been completed. If it is produced accurately without defects, the system continues based on its original operation sequence. Otherwise, if defects exist in part B, rework is required. Note that the reworked part production operations can be modeled precisely and easily with alternative rework sequences. As a result, there are two possible sequences for part B: (1) Load/unload station → M1→ M3 → load/unload station or (2) Load/unload station → M1→ M3 → M1→ M3 → load/unload station.
To model the rework operation for part B by using the procedure of the CROPN synthesis, consider the following procedures: 1) Add two operations sequences as route 1: The reconfigured model by using the CROPN is illustrated in Figure 5.

D. ADDITION OF NEW TRANSPORTATION RESOURCE
Assume a new transportation resource (robot Ro2) is added to the system presented in Figure 5 to load/unload part A to/from M1 and M2. To model robot Ro2 operation for part A by using the procedure of the CROPN synthesis, consider the following procedures: 1) Update the transitions t 010A , t 120A , and t 200A ; 2) Set the initial colored token c t2 into place p r , which represents a transportation resource Ro2 in the system. The reconfigured models by the CROPN is illustrated in Figure 6.

IV. BEHAVIORAL AND QUANTITATIVE ANALYSIS OF CROPN A. LIVENESS
A colored resource-oriented Petri net contains a number of circuits due to its strong connectedness. A special class of circuits in a CROPN is the production process circuit (PPC), which plays a crucial role for the liveness of the CROPN. Due to RMS routing complexity, the CROPN may have several PPCs, but only a few PPCs need to be identified in a CROPN.
Definition 20 [46]: Proof: see [46]. VOLUME 8, 2020 Definition 24 [46]: Let N = (P, T, I, O, C, K, M o , OR) be a CROPN. A circuit in a CROPN is called an interactive PPC, formed by a number of PPCs, if each PPC in the circuit shares places and transitions with at least another PPC in the circuit and the circuit is strongly connected.
Definition 25 [46]: It is easy to verify that some PPCs are full when a deadlock appears. Even when one PPC is full, the system can be deadlocked. Therefore, the following results are generated: Lemma 1 [46]: If a CROPN is not live, then the net includes a PPC.
Lemma 2 [46]: The following two statements are similar: 1. A CROPN is not deadlock-free. 2. A CROPN is not live. Lemmas 1 and 2 demonstrate that if deadlocks appear in a CROPN, then they appear in certain PPCs. Therefore, the following result is generated: Theorem 1: The necessary condition for the existence of deadlocks in a CROPN is that at least one PPC e exists such that Proof: see [46]. Definition 28 [46] Definition 32 [46]: Let N = (P, T , I , O, C, K , M o , OR) be a CROPN. A transition t is called an input transition of interactive subnet e n if t / ∈ T (e n ) and t • ∈ P(e n ). A transition t is called an output transition of interactive subnet e n if t / ∈ T (e n ) and • t ∈ P(e n ). Let T I (e n ) be an input transition set of interactive subnet e n and T O (e n ) be an input transition set of interactive subnet e n .
Definition 33 [46]:  Proof: see [46]. Definition 34 [46]: Let N = (P, T , I , O, C, K , M o , OR) be a CROPN. A PPC e in a CROPN is called an enabled if it is both process-enabled and resource-enabled.
Corollary 1 [46]: A PPC e is an enabled PPC if the condition in Theorem 2 is satisfied.
and η(e n , M ) ≥ 1 (15) where, η(e n , M ) represents the number of enabled PPCs in e n at M. Proof: see [46]. Proof: see [46]. We call a transition t the input transition of multiple PPCs. Let V en (t) represent the set of these PPCs. Let T d be the set of transitions in CROPN such that if t ∈ T d , then V en (t) = ∅. Proof: see [46]. To demonstrate the liveness of the CROPN, let us consider the CROPN of the reconfigured manufacturing system shown in Figure 6. It contains one PPC: e 1 = {p 1 , t 130B , p 3 , t 310B }. Figure 7 displays the reachability graph of the CROPN illustrated in Figure 6. We suppose that all places other than p o and p r have a capacity of one with a machine and a buffer space. Based on the control law given in Theorem 2, the available spaces in PPC e 1 are computed as follows: From the example, we can see that a subnet PPC e 1 in the CROPN is live and the condition in Theorem 2 is satisfied for any marking M ∈ R c (N, M o ). Thus, if the control law given in Theorem 2 is applied in real time, then the deadlock in a CROPN of the reconfigured manufacturing system presented in Figure 6 can be totally avoided.
each subroute R needs place p a that relates to R i(j−1) , place p b , which relates to R ij , transition t, an arc (p a , t), an arc (t, p b ), an arc (p r , t), and an arc (t, p r ). Thus, let σ be the cardinality of OR, i.e., | OR | = σ . Let ζ be the cardinality of r i , i.e., |r i | = ζ . Let be the number of corresponding places, transitions, and arcs to each subroute, and θ be the cardinality of , i.e., | | = θ. The ''FOR loop'' is executed (σ ζ θ ) times to build the CROPN. Thus, the Algorithm 1 computational complexity is represented as  O(σ ζ θ). Therefore, the Algorithm 1 computational complexity is polynomial.

C. GPENSIM CODE AND VALIDATION OF CROPN
To verify and validate Algorithm 1, the GPenSIM tool [1], [69] is employed to develop a code for the ICPN model. The developed code is implemented on MATLAB R2015a under the following conditions: Windows 10, 64-bit and Intel(R) Core (TM) i7-4702MQ CPU @ 2.20 GHz, 16 GB RAM. First, three GPenSIM files are generated, which are main simulation file (MSF), the PN definition file (PDF), and common processor file (COMMON_PRE file). The PDF is proposed to represent the sets of places, transitions, and arcs of the PN model. The COMMON_PRE file is developed to represent the conditions to enable fire transitions. The MSF is proposed to represent the simulation results. Then, the time performance is conducted, including the machines and robots, total throughput, and total throughput time. The results of the simulation are compared with those of the works by [1], [66]- [68]. Reconsider the model presented in Figure 3. The simulation was conducted for 480 minutes and Table 1 summarizes the simulation results of MATLAB, which presents the results in terms of the aforementioned criteria for time performance. It can also be observed that the proposed Algorithm 1 can obtain better utilization, greater throughput, and less throughput time than the other approaches, as presented in Figure 8. Thus, Algorithm 1 is effective and can accommodate other cases. Moreover, the results are accurate.

V. LADDER DIAGRAM COLORED RESOURCE-ORIENTED PETRI NET
In an LD program, the input variable demonstrates the status of a switch or sensor that is sampled on regular intervals and inputs it to a PLC system; conversely, the output variable describes the status of an actuator such as a relay or motor, that is regularly delivered to an actuator by a PLC; and no external equipment, including the actuator or the sensors, is presented by an internal variable, but is used for an LD computation. The LD has nine element types, which include the left power bar, the right power bar, the contact, the coil, timer, counter, the horizontal line and the vertical line. The left and right power rails are represented as |. The main LD symbols for the Siemens Step 7-1200 PLC are presented in Table 2. The LD is a set of rungs from the left power rails to the right power rail. Each rung is considered as a collection of contacts and coils linked by vertical and horizontal lines. In the same rung, contact and coil, which are represented by the same Boolean variable, may occur. In this article, it is assumed that coils are directly connected to the right power rail. The PLC is implemented on a periodic scanning. In each scan, the LD program is executed in the same way as the relay electrical connector chart. The execution flows from left to right and then from top to bottom; therefore, each output is calculated and updated. denotes the firing condition that maps each transition t ∈ T to a guard expression (t) that has a Boolean firing function, 5. δ denotes the output function that maps each place p ∈ P to a guard expression δ(p), which has a Boolean place function, 6.
denotes the output function combining all the outputs δ of all marked places p ∈ P; : {0, 1} P → {0, 1, -, c}, and c denotes the contradiction in the case where the same signal is set to 0 in a given place and one in another place; to compute (m a ), m a : (m a ) i δ(p i ) can be used. = L ∪ R ∪ v is called a vertex set; 2. L = { l1 , l2 , . . . , lg } where li , 1 ≤ i ≤ g is called the junction of the i th rung and the left power rail in the LD; 3. R = { r1 , r2 , . . . , rg } where ri , 1 ≤ i ≤ g is called the junction of the i th rung and the right power rail in the LD; 4. v is called a set of components representing the LD symbols and v y1,y2,y3 is its element if a) y1 is a character string variable of the component representing the name of the LD symbols such as contact, counter, timer, or coil; b) y2 is expressed as y2 = {0, 1, 2, 3, 4, 5} where 0 denotes a normally open contact, 1 denotes a normally closed contact, 2 denotes a coil, 3 represents a negated coil, 4 denotes a set coil, and 5 denotes a reset coil; c) y3 is expressed as y3 = {0, i}, where 0 denotes a contact named by y1 and i, and 1 ≤ i ≤ g denotes the i th coil from top to bottom, named by y1.
γ is a collection of edges.
Let v x and v y be two components. For all v x, v y ∈ , v x, v y ∈ γ if there exists a connect line between two symbols in the LD, which are corresponding to v x and v y , respectively.  vertex v y1,y2,y3 that is directly linked to ri , ri ∈ R , 1 ≤ i ≤ g, g ∈ Z is said to be an assigned-component of the i th rung and represents the output variables in an LD graph LD . Definition 39: Let N = (P, T , I , O, C, K , M o , OR, I s , Q, M, , δ, , LD ) be an LDCROPN. Let v y1,y2,y3 ∈ v , (k = y3 , 1 ≤ k ≤ g, g ∈ IZ) be an assigned-component if a path between li and ri that includes v y1,y2,y3 exists; this path is expressed as (v y1,y2,y3 ). Let  *  (v y1,y2,y3 ) be an instruction path of v y1,y2,y3 if li and ri are removed from (v y1,y2,y3 ) and represented by k,i , 1 ≤ i ≤ | * (v y1,y2,y3 )|; k = y3 relates to the k th coil in the LD and represents the kth path of * (v y1,y2,y3 ). Otherwise.
Otherwise.  Proof: It must be proven that all rungs g, g ∈ IZ in LD are live and work from left to right, and from top to bottom. Let v y1,y2,y3 ∈ v , (k = y3 , 1 ≤ k ≤ g, g ∈ IZ) be an assignedcomponent. Moreover, let * (v y1,y2,y3 ) be an instruction path of v y1,y2,y3 represented by k,i , 1 ≤ i ≤ | * (v y1,y2,y3 )|; k = y3 relates to the kth coil in the LD and represents the kth path of * (v y1,y2,y3 ). For all k,i ∈ * , if k,i is working without error in any case, then it can be inferred that the LDCROPN (N, M o ) is live. A rung with its LD components needs to be added to each transition t ∈ T . Therefore, let j be the cardinality of T , i.e., |T | = j. Each transition t has input place p ∈ • t, and each input place is represented by an LD component. Thus, let E be the set of input places of transition t and ε be the cardinality of E, i.e., |E| = ε. Moreover, each transition t has output place p ∈ t • , and each output place is represented by an LD component. Thus, let be the set of output places of transition t and π be the cardinality of , i.e., | | = π. Also, physical output signal/s may exist that correspond to the output place/s of transition t, which can be represented by an LD component. Therefore, let be the set of physical output places of transition t and ψ be the cardinality of , i.e., | | = ψ. To construct an LD , the ''FOR loop'' is executed (j(ε + π + ψ)) times. Thus, the Algorithm 2 computational complexity is represented as O(j(ε + π + ψ)), which is polynomial.
Based on Definitions 35-41 and Theorems 7 and 8, the developed algorithm for converting a CROPN into an LD is presented as follows:  if an arc (p, • t) is normal, then 9.
Start a new rung j; 20. if there is a physical input signal I Si ∈ I S , then 21.
Add  LD

End
To demonstrate the LDCROPN synthesis, consider a CROPN presented in Figure 6. The obtained CROPN lacks recognition and identification of the two part types at the input buffer and machine 1. To enable recognition of parts A and B in the input buffer area, sensor 1 (an infrared reflective sensor) and sensor 2 (a proximity sensor) are added, respectively. Sensor 3 (an infrared reflective sensor) and sensor 4 (a proximity sensor) are added to enable recognition of parts A and B in machine 1, respectively. Moreover, sensor 5 (an infrared reflective sensor) and sensor 6 (a proximity sensor) are added to enable recognition of part A in machine 2 and part B in machine 3, respectively. Based on Definition 35,   the developed LDCROPN is presented in Figure 9. The physical input and output signals of the PLC are presented in Table 3, and the Boolean firing and place functions are listed in Table 5. The start and stop pushbuttons for the whole system are realized by input registers I0.0 and I0.1, respectively. Moreover, sensor readings are realized by input registers I0.2, I0.3, I0.4, I0.5, I0.6, and I0.7. The output bits, Q0.0, Q0. 1, Q0.2, Q0.3, and Q0.4, are added to the action places. Conversely, the memory bits (Mx.x) are assigned to places and transitions. It is noteworthy that we can assign two memory bits to the place whose capacity has two tokens. For the representation of the time delays, an on-delay timer is associated with timed transitions and places.
The LDCROPN model has the following specifications.

VI. CONCLUSION
In this paper, a novel two-step approach is proposed for the implementation of ladder diagrams (LDs) for reconfigurable manufacturing systems (RMSs) with dynamic changes. First, a CROPN-based algorithm is developed to enable a rapid and valid reconfiguration of an RMS. Second, an LDCROPN is established to convert the CROPN into an LD. The developed approach is validated using examples in the literature. The effectiveness of the proposed approach for the implementation of LDs under RMS configuration changes is validated by the simulation results.
The main advantages of this paper are summarized as follows. (1) The proposed approach has the ability to easily handle any complex RMS change compared with the studies in [70]- [72]. (2) The obtained LD has a simpler structure and has low overhead computation compared with the approaches proposed in [30]- [33], [35].
The main limitations of the proposed approach are that the obtained result is restricted to discrete data types, including bit strings, integer values, and Boolean, as the CROPN is based on discrete data types. Thus, our future research will extend the proposed approach to use the continuous CROPN in order to tackle the continuous data types generally used by the programmable logic controller systems. Moreover, automatic transformation programs based on the proposed algorithms need to be developed, and systematic analysis techniques for user programs that are proposed based on the commercially available Siemens Step 7-1200 PLC need to be presented. Another interesting future research topic is to conduct a study on an LD control algorithm with more input and output signals, and define new transforming structures for additional control logic. Finally, the proposed method needs to be extended to such complex flexible assembly/ disassembly systems. The proposed method will be applied to multiagent systems and social systems [  He is currently with the Macau University of Science and Technology. His current research interests include Petri net theory and application, supervisory control of discrete event systems, workflow modeling and analysis, system reconfiguration, game theory, and data and process mining. He serves as a reviewer for more than 90 international journals. He is listed in Marquis Who's Who in the world, 27th Edition, 2010. He was a recipient of an Alexander von Humboldt Research Grant, Alexander von Humboldt Foundation, Germany, and Research in Paris, France. He is the Founding Chair of the Xi'an Chapter of IEEE Systems, Man, and Cybernetics Society. VOLUME 8, 2020