Extended Hierarchical Fuzzy Interpreted Petri Net

Petri nets (PNs) have many advantages such as graphical representation, formal description, and the possibility of sequential and concurrent control. An important aspect of using PNs is hierarchical modeling, which may be provided in different ways. In this paper, a new concept and definition of the hierarchical structure for Fuzzy Interpreted Petri Net (FIPN) are proposed. The concept of macroplace with several input, output, and input-output places is introduced to the net. The functionality of the macroplace instances and the hierarchy graph are also proposed. They are implemented in a computer simulator called HFIPN-SML. In this study, FIPN is employed since it allows the use of analogue sensors directly for process control. Better visualization and more precise control are among advantages of the introduced approach.


Introduction
Petri nets (PNs) are increasingly used in the development of information systems whose high complexity requires a new approach to design and implementation. Therefore, new concepts of PN description, analysis, and presentation have appeared, among which an important place takes introducing the hierarchy (modularization) to the net structure. It allows for the presentation of the developed systems in different levels of abstraction and facilitates the determination of the properties of nets modeling these systems. There is, however, no unified approach to using the hierarchy in PNs, and the main research directions are described in the following subsections.

Refinement of Places and Transitions
One of the first works related to the hierarchy in PNs was presented by Valette [1], who proposed a concept of macrotransition with a single input and output. The author defined a concept of a well-formed block and examined the properties of the hierarchical net, such as boundedness, safeness, and liveness. Suzuki and Murata [2] continued Valette's research by extending the concept of the well-formed block to a k-well-behaved block. Vogler [3] proposed an extension of the concepts described in [1,2] by replacing a transition having several inputs and outputs with a subnet taking into account certain constraints of the structure. Brauer et al. [4] described the refinement of transitions for a subnet with one initial and one final transition as well as a method for creating macroplaces.
Bernardinello and De Cindio [5] presented and compared different approaches to the refinements of place and transition. The majority of these concepts use the composition of synchronized subnets with a state machine structure. Van Der Aalst [6] described a method to validate the workflow using a hierarchical net, which preserves properties such as safeness, liveness, boundedness, free-choice, and well-structuredness. The net was used to model the flow control of different aspects of business processes. Huang et al. [7] described a method for refinement providing nineteen system properties. In the literature,

Hierarchical Nets in Industrial Standards
The formalism of PNs along with their hierarchy structure has found its application in programming standards of industrial controllers. The use of PNs to write programs for PLC controllers is described in the international standard IEC 60848:2013 [36], that proposes a Grafcet language. Based on Grafcet, the Sequential Function Chart (SFC) is defined [37] as one of the five programming languages for PLC controllers. The theoretical basis of Grafcet are described by David and Alla [38].
In the Grafcet standard, it is possible to use several functionalities based on the hierarchy. The first of them is the concept of the macroplace called macrostep. It assumes that a token, which is moved to a macroplace node, is automatically moved to the input step of a subnet assigned to this macrostep. Another concept is the so-called enclosure, in which a subnet is assigned to one enclosure step. If a token moves to the enclosure step, the initial steps of the subnet are activated, and when the token leaves the enclosure step, all subnet steps are deactivated. A different functionality is forcing subnet states: pausing and resuming a subnet work as well as activating/deactivating of the chosen steps.
In the IEC 61131-3 standard, the hierarchical structure is not directly defined for the SFC language. However, the way in which the actions assigned to steps are defined indirectly introduces the hierarchical nesting. They can be implemented using SFC and other languages of this standard.

Methodology of Dealing with Complex Systems
Modular PNs can be used for the creation of methodologies that describe dealing with complex systems, e.g., manufacturing systems. This approach is usually given in the form of a general verbal description supplemented with examples and formal descriptions.
Silva and Valette [39] proposed the modeling of Flexible Manufacturing Systems (FMS) using hierarchical PNs. Stepwise place/transition refinements and modular composition were applied. Valavanis [40] described a methodology of FMS modeling using an extended PN. In the approach, a decomposition (top-down) and composition (bottom-up) are used. Zhou et al. [41] proposed a hybrid methodology that ensures the appropriate properties of modules, such as boundedness, liveness, and reversibility. In the described concept, the decomposition and composition are employed for the determination of unshared and shared resources between modules.
Der Jeng and DiCesare [42] described the use of PNs in the modeling of sharedresource automated manufacturing systems. The merging of the modules is performed through transitions shared by different subnets. The methodology allows the preservation of liveness and boundedness. Zhou [43] showed a practical example of modular modeling of a semiconductor manufacturing system using time PN. A reduction technique is used to facilitate the analysis of properties of the entire system.

Recent Studies
Recent studies indicate that the hierarchy/modularization in PNs can be very useful. One of the subjects of research is decomposition. Ye et al. [44] showed the method for the creation of the decentralized control system using PNs. In the proposed solution, the subnets have a state-machine structure. Wisniewski et al. proposed a new algorithm of decomposition for edge systems modeled using Petri nets [45]. Formal proof of the correctness of the algorithm and comparison to a similar method were also given. For the modeling of practical problems, hierarchical Colored Petri Nets (HCPN) are widely used. The application of HCPN for the implementation of a traffic signal control model was proposed by An et al. [46]. Sicchar et al. [47] presented the application of HCPN in the control system for load-balance procedure in low voltage grid. Gozhyj et al. [48] presented the use of HCPN to model the interaction between web services using CPN tools.
Fuzzy hierarchical PNs and formal definitions of hierarchy are also considered. Li et al. [49] presented a layered fuzzy Petri net with a hierarchical structure for risk assessment. The fault diagnosis approach using time hierarchical fuzzy Petri net was proposed by Yuan et al. [50]. The combination of fuzzy and colored PNs for runtime veryficaton of pacemaker was presented by Majma et al. [51]. Padberg [52] proposed a formal definition of hierarchical reconfigurable PN and its conversion to a flat net. Different models and problems related to hierarchical PNs can also be found in [53][54][55][56].

Paper Scope and Organization
As can be seen from the previous subsections, the hierarchy in PNs can be realized in different ways. The boundary between the discussed research areas is ambiguous because they often overlap and can complement each other. For example, an important methodology for dealing with large systems, such as FMS, can be the reduction technique [43,57,58].
In this paper, a new concept and a formal description of hierarchical FIPN (HFIPN) is presented. The theoretical basis of FIPN are described in [59], where the structure, behavior, and algebraic representation of this net are shown. In [60], a coverabality graph for FIPN was proposed, which can be used in the study of net properties and as a diagnostic system. The properties of FIPN can also be determined using a reachability graph. Research related to the FIPN implementation is also conducted. The works [61,62] describe the FIPN software model and its implementation for PLC controllers, while a method of code generation for FPGA circuits is presented in [63]. As part of the research, a software tool called HFIPN-SML was developed based on (H)FIPN model. This paper proposes a new hierarchical structure for FIPN and is a continuation of [64]. The contributions of this study are as follows: Formal way to sum any two subnets.
The paper is organized as follows. First, a comparison of our approach to similar solutions is presented (Section 1.8). Then, the theoretical basis of FIPN is described (Section 2). Next, the new HFIPN concept is presented (Section 3). Then, an exemplary application is shown (Section 4). Finally, a summary of the research and potential future studies are given (Section 5).

Comparison to Similar Solutions
Due to previous research, HFIPN is compared to PNs used in PLC controllers. In Table 1 general characteristics of Signal Interpreted Petri Net (SIPN) [65][66][67][68], Grafcet [36], SFC [37], and other fuzzy PNs [69][70][71] are presented. The first three were chosen since they seem to be the most comprehensive because of the hierarchy structure, software tool support, and automatic executable code generation. The others, like HFIPN, allow the use of analogue signals, but they do not have the advantages shown in Table 1 that facilitate  the practical application. SIPN is a binary net with a formal description. It allows the use of a hierarchy based on a macroplace concept with one input and output place. Software based on SIPN enables the automatic conversion of the graphical net representation to executable code in Instruction List (IL) language and the automatic investigation of the net properties. All functionalities are implemented in one computer tool. Grafcet and SFC are binary nets allowing the use of a hierarchical structure (described in Section 1.4) and automatic executable code generation based on a net graph. Although they are proposed as international standards, there are some issues related to their informal description. There is no unified approach to the formal analysis of their properties and their operation depends on implementation. They can be converted to the finite machine [72][73][74], timed automata [72,[75][76][77][78], or formal PNs [79][80][81][82][83].
In comparison to the mentioned solutions, the main advantage of HFIPN is the possibility of using analogue signals for direct control of a process. Conditions assigned to a transition may not be binary (it is explained in the next section). Contrary to Grafcet, SFC, and SIPN, HFIPN also allows resource modeling in the structure of a net since the weight of arcs and the capacity of places can be greater than one. In comparison to SIPN, HFIPN offers more possibilities in the use of a hierarchical structure. However, HFIPN has some gaps that need to be filled as shown in Table 1. As with SIPN, SFC, and Grafcet, HFIPN permits automatic generation of executable code [64], but unlike the others, only for a non-hierarchical net structure. Another issue is the investigation of properties. For HFIPN, like for Grafcet and SFC, there are created methods to investigate properties [60], but they are not integrated with HFIPN-SML. Clearing both gaps is planned for future studies.
To conclude this section, it can be observed that there is no other solution combining PNs and PLC programming to create control systems and offering the possibility of using analogue sensors, software tool support, resource modeling by the structure of a net, and automatic generation of executable code. However, some new functionalities need to be implemented to see HFIPN and its simulator as a complete solution.

The Formal Basis and the Concept of FIPN
Three definitions describe the formal basis of FIPN. The first presents the net construction. .., p a } is a set of places for processes modeling, P = {p 1 , p 2 , ..., p a } is a set of places for resources modeling; T = {t 1 , t 2 , ..., t b } is a nonempty finite set of transitions; Ω = {ω 1 , ω 2 , ..., ω a +a } is a nonempty finite set of statements; Ψ = {ψ 1 , ψ 2 , ..., ψ b } is a nonempty finite set of conditions; P, T, Ω, Ψ are disjoint sets; R ⊆ (P × T) ∪ (T × P) is the incidence relation that assigns a place to each transition t i (1 i b) where there is the place p ∈ P , such that (p , t i ) ∈ R or (t i , p ) ∈ R; ∆: P → Ω is the function assigning a statement to each place; K : P → {1} and P → ℵ\{1} are the functions assigning a capacity to each place, where ℵ = {1, 2, ...}; Γ : T → Ψ is the function assigning a condition to each transition; Θ : T → [0, 1] is the function defining the degree to which the condition corresponding to the each transition is satisfied; W : R → ℵ is the weight function which ∀p ∈ P and ∀t ∈ T meets two conditions: W(p, t) ≤ K(p), W(t, p) ≤ K(p); M 0 : P → {0, 1} and P → W + are the initial marking functions, where: W + is a set of non-negative rational numbers; e is an event that synchronizes the work of all transitions.
FIPN can be represented as a bipartite graph. An exemplary net and a system controlled by it (in different states) are presented in Figure 1. There exist two types of places in the net: p -type-p 1 and p 2 (for process modeling) and p -type-p 3 (for resource model-ing). They are shown as circles. For both types, the marking is a real number in the range [0, 1] located inside the circle. However, the marking of p -type places is presented as a fraction and can hold more than one token. The denominator holds the capacity of a place, while the numerator holds the number of tokens.
Moreover, statements can be assigned to p -type places to set the value of process variables. In Figure 1 actions start and stop are assigned to places p 1 and p 2 for the control of a dispensing process. Transitions are represented by rectangles and can be related to binary or analogue signals. Transition t 1 is synchronized by an analogue signal A 1 representing the weight of the material transferred to the truck ( Figure 1). In FIPN, analogue signals are normalized into the range [0, 1]. As can be seen in the figure, the transfer of a token across the fired transition is a process with a duration longer than one clock cycle which synchronizes the net operation. This duration depends on the increment of the sensor value. Such operation of transitions allows for better visualization as well as for more precise control in comparison to discrete PNs. Additionally, some logic conditions (an example is shown in Figure 3) can be assigned to transitions. The basic conditions for transition activation and deactivation are described in Definition 2.

Definition 2.
The transition t ∈ T with marking M : P → [0, 1] is enabled when the degree to fulfill the condition Θ(t) = θ, assigned to the transition, is greater than zero and the following conditions are satisfied [59]: and until: where: The transfer of tokens from input to output places across the transition can begin when conditions (1) and (2) of Definition 2 are satisfied, while it ends when condition (3) or (4) is fulfilled.
The change of the marking for places connected to the enabled transition depends on the increment of the degree to which the condition corresponding to the transition is satisfied. The method for calculating the new marking is described by Definition 3. The transition remains active until the tokens are transferred from the input places to the output places.

Definition 3.
Let M be the marking for which the transition t ∈ T is enabled, the degree Θ(t) = θ (where θ ∈ [0, 1]), to which the condition corresponding to the enabled transition is satisfied, will be changed by ∆θ ≥ 0 and there will be an event e synchronizing the work of all transitions. The new marking of the net M can be computed by the following rule [59]: The increment ∆θ < 0 does not introduce any changes in the net marking.
It has been mentioned that FIPN gives better visualization effect in comparison to discrete PNs. This advantage can be seen in Figure 2 which presents the discrete PN graph and the FIPN graph (in different states) used for the control of heating, measuring time and filling the tank. Discrete PN displays only the actions that are currently performed, while FIPN additionally presents the progress of these actions. Another advantage of FIPN in comparison to discrete PNs is the possibility of the dynamic control in response to changing values of analogue signals or fuzzy marking of places. An example of such control is shown in Figure 3. If the temperature is too low after 70% of the measured time (logic condition assigned to transition t 4 ), the additional heater G 2 is turned on (place p 8 ). If the temperature increases with enough speed (t 5 ), no action is needed (p 9 ). Such dynamic control is also presented in Section 4 (macroplace mp 4 ).

New HFIPN Concept and Its Definitions
In this section, a new concept and definitions of HFIPN are presented. The proposed net enables the creation of subnets with multiple input, output, and input-output places as well as the use of macroplace instances. Moreover, based on a HFIPN graph, a hierarchy graph is created. All of these functionalities allow for good adaptation of HFIPN to practical needs. The way of summing subnets and the conversion of HFIPN to its flat version are also described. Finally, a new algebraic representation and a brief introduction of HFIPN-SML features are given.

The Concept of HFIPN
In this subsection, the conception of HFIPN is presented. Figure 4 shows an example of the hierarchical net consisting of two subnets N 0 and N 1 . The subnet N 0 contains the macroplace mp 1 which includes the subnet N 1 . The macroplace mp 1 is an internal macroplace of the subnet N 0 and is overriding for the subnet N 1 . In the hierarchical net, a macroplace can have several input, output, and input-output places that are visible in its overriding and internal subnets. Input places can only have input arcs in the overriding subnet of a macroplace, while output places can only have output arcs. Input-output places can have both types of arcs in the overriding subnet. The macroplace mp 1 (Figure 4) contains two input places (p 4 and p 5 ), two output places (p 9 and p 10 ), and one input-output place (p 6 ). The place p 6 has an input and output arc in the subnet N 0 and two output arcs in the subnet N 1 . In the subnet N 1 , the place p 6 can also have an input arc.
HFIPN enables the application of macroplace instances, which facilitates the use of modularization in a net. This functionality is analogous to that used in CPN [31]. It allows creating several macroplaces (subnets) that have the same structure: they have the same number of places with the same capacity, the same number of transitions and arcs of the same weights connecting the corresponding nodes. In the proposed concept, macroplaces that are instances of the same type do not share nodes and arcs. Therefore, the places, transitions, and arcs of one macroplace are always separate from the elements of other macroplaces, and in the algebraic representation, they are represented by different numbers in all vectors and an incidence matrix. However, the concept of macroplace instances allows for simultaneous modification of macroplaces of the same type.
The concept of macroplace instances entails the introduction of place, transition and arc instances, but only for those elements that are inside macroplaces. Places that are instances of the same type may be associated with the same statements, while transitions may be associated with the same conditions. Therefore, instances of places and transitions belonging to macroplace instances can be created in two ways in HFIPN. In the first approach, the statements assigned to the places and conditions associated with the transitions are shared between nodes of the same type, while in the second approach they are separate. In Figure 5 the first type of place and transition instances is presented, in which statements and conditions are shared. There are two macroplaces mp 1 and mp 2 in the net, that are of the same type mtype 1 . The places p 1 and p 2 from the subnet N 1 are functionally the same places as p 3 and p 4 from the subnet N 2 . They set the variable O 1 . The same applies to the transitions t 1 and t 2 , whose degrees of the conditions fulfillment are synchronized with the variable A 1 . In Figure 6, the second type of macroplace instances with separate statements and conditions is presented. The macroplaces mp 1 and mp 2 do not share the output variables assigned to places. The places p 1 and p 2 set the variable O 1 , and the places p 3 and p 4 set O 2 . The variables synchronizing the degrees to which the conditions corresponding to the transitions are satisfied for transitions t 1 (variable A 1 ) and t 2 (A 2 ) are also not shared between macroplaces. The concept of macroplace instances with shared variables can be used when a certain part of a system is controlled by several modules in the same way- Figure 7a. The second approach with unshared variables is used when similar parts of a system are controlled in the same way by different macroplaces- Figure 7b.

Formal Description of HFIPN
Three definitions specify the structure and operation of HFIPN. The first of them, the main definition of a whole net, is as follows.
is a subnet, for which the macroplace mp i is overriding (the subnet N i is internal for the macroplace mp i ); P mp(i) = P in mp(i) ∪ P out mp(i) ∪ P io mp(i) is a nonempty finite set of input, output and input-output places of a macroplace; IO : P → {in, out, inout, normal} is a function determining the place type; I NS is the function that returns the instance type for any node or arc: By Definition 4, each subnet except N 0 has exactly one overriding macroplace. Moreover, HFIPN is divided into d + 1 subnets. If d = 0, the net is flat, and if d > 0, the net is hierarchical. The subnet N 0 is the main or top level subnet. The remaining subnets are called lower level subnets or macronets. Definition 4 also shows that the elements of a macroplace are sets of input, output, and input-output places. To distinguish the types of places in the net, the global function IO was added to the main definition, which allows specifying the type of each place in the net, whether it is an input, output, input and output of a macroplace or a normal place. Each macroplace in HFIPN is an instance of a given type. The remaining elements (places, transitions, and arcs) are instances if they occur inside macroplaces (e.g., the place p 1 in Figure 5 is an instance of type pt 1 ). However, the elements are not instances if they occur directly in the main subnet N 0 (e.g., the place p 5 in Figure 5).
Definition 5 describes the structure of each subnet in HFIPN.

Definition 5.
Each subnet N i , 0 ≤ i ≤ d is defined as follows: , where: MP i ⊆ MP is a finite set of internal macroplaces of the subnet N i (N i is an overriding for these macroplaces); P i ⊆ P and P i = P i ∪ P i ∪ P in i ∪ P out i ∪ P io i is a nonempty finite set of places (in the subnet N i ), where: P i ⊆ P is a set of places of the type p , P i ⊆ P is a set of places of the type p , is a set of input places (of the type p or p ) of internal macroplaces from the set MP i , P out i = P out i ∪ P out i is a set of output places (of the type p or p ) of internal macroplaces from the set MP i , is a set of inputoutput places (of the type p or p ) of internal macroplaces from the set MP i , P i , P i , P in i , P in i , P out i , P out i , P io i , P io i any two of them have no common elements; T i ⊆ T is a nonempty finite set of transitions; Ω i ⊆ Ω is a nonempty finite set of statements; Ψ i ⊆ Ψ is a nonempty finite set of conditions; ) is a subnet incidence relation; ∆ i : P i → Ω i is the function assigning a statement to each place; are the functions assigning a capacity to each place; Γ i : T i →Ψ i is the function assigning a condition to each transition; 1] is the function defining the degree to which the condition corresponding to the transitions is satisfied; W i : R i → ℵ is the weight function, which for ∀p ∈ P i and ∀t ∈ T i meets two conditions: ; e is the global event which synchronizes the work of all transitions.
By Definition 5 each set of places P i , the transitions T i , the conditions Ψ i , the statements Ω i and the arcs R i , which belongs to the subnet N i , is a subset of the flat net set: P, T, Ψ, Ω and R respectively. From Definitions 4 and 5, it follows that the main subnet may have internal macroplaces, which are overriding macroplaces for some subnet, which, in turn, may contain further macroplaces, etc. The level of maximum depth in HFIPN is not limited in the definition. Subnets/macroplaces only in a special case may have common elements (places) with other subnets/macroplaces, which is described in Definition 6 specifying the relationship between sets of subnets in HFIPN. Definition 6. For any two subnets N i , N j ∈ N for 0 ≤ i ≤ d, 0 ≤ j ≤ d and i = j the relationship between the subsets of places, transitions, statements, macroplaces, conditions assigned to transitions, arcs is defined as follows: for mp i ∈ MP j and i = 0, P mp(j) for mp j ∈ MP i and j = 0, ∅ in other cases, and for additionally fulfilled conditions d > 1 and i, j = 0: Definition 6 shows that for any two subnets, for which the overriding macroplace of one of them is the internal macroplace of the other, the common part is the set of input, output and input-output places of this macroplace (Equation (6)). The example of such a set in Figure 4 is the set P mp(1) = {p 4 , p 5 , p 6 , p 9 , p 10 }. Places from this set belong to the subnets N 0 and N 1 . However, the introduced restrictions do not allow the input and output place of the first macroplace/subnet to be the input and output place of the second macroplace/subnet (Equation (12)). This prevents the possibility of the creation of an infinite number of macroplaces for a finite number of places.

The Hierarchy in HFIPN
This subsection presents a hierarchy graph, allowing to define nesting relations between macroplaces (subnets) in HFIPN and facilitates navigation to various areas of the net. The terms defining the degree of the nesting relation: ancestor, direct ancestor, descendant, and direct descendant are also introduced. The special function * () is used to formulate the concept of ancestor and descendant, and in the next subsection to define an algebraic representation.
First, the function * () is introduced. For each subnet Definition 7 specifies what is the sum of two subnets.
Definition 7. For any two subnets N i , N j ∈ N for 0 ≤ i ≤ d, 0 ≤ j ≤ d and i = j their sum N k is calculated as follows: for mp j ∈ MP i and j = 0, P io i ∪ P io j in the other cases; (20) By Definition 7, the sum of the subnets N i and N j is the subnet N k , which consists of subsets (transitions, statements, conditions, and arcs), which are the sums of the corresponding subsets from the subnets N i and N j . The subsets of macroplaces and places can be summed in a different way. If, for instance, the macroplace mp i is internal for the subnet N j , then mp i is removed from the result subset of internal macroplaces of N k (Mp k ). Similar operations occur for the set of places P k (if mp i is internal for N j ). The input places P in mp(i) , the output places P out mp(i) and the input-output places P io mp(i) of mp i are removed from the sets P in k , P out k and P io k , respectively. These places are still the elements of the normal place sets of the subnet N k , i.e., P k ∪ P k .
In the HFIPN-SML simulator, there is no need to continuously add subnets to create the algebraic representation described in Section 3.4. For each subnet, the vectors and the incidence matrix are updated on-the-fly when places, transitions, and arcs are added to the subnet. The summation operation is used when a user wants to undo adding a new macroplace based on a selected fragment of the subnet. Definition 7 and the function (13) allow for the transformation of a hierarchical net (HFIPN) into its flat equivalent (FIPN). This conversion involves the addition of all subnets of the hierarchical net. Some sets of the obtained net, i.e., the set of internal macroplaces and the sets of input, output, and input-output places of the internal macroplaces are empty: Based on Definition 7, the following functions for subsets of subnets can be created: They are defined as follows: Functions * () (Equations (32)-(37)) were defined for subsets of places, macroplaces, transitions, statements, conditions, and arcs. Their notation used without parentheses, e.g., * P i for * (N i , P i ) can be treated as the set returned by them, which simplifies their definition. After defining the functions * (), the formal definitions of nesting relations between subnets can be formulated.
is a direct ancestor for the subnet N j (N j ∈ N) if the overriding macroplace mp j (mp j = {N j , P mp(j) }) of the subnet N j belongs to internal macroplaces of the subnet N i (mp j ∈ MP i ).

Definition 9.
The subnet N i (N i ∈ N) is a direct descendant for the subnet N j (N j ∈ N) if the overriding macroplace mp i (mp i = {N i , P mp(i) }) of the subnet N i belongs to internal macroplaces of the subnet N j (mp i ∈ MP j ).

Definition 10.
The subnet N i (N i ∈ N) is a ancestor for the subnet N j (N j ∈ N) if the overriding macroplace mp j (mp j = {N j , P mp(j) }) of the subnet N j belongs to the set * MP i created according to Equation (33).
Definition 11. The subnet N i (N i ∈ N) is a descendant for the subnet N j (N j ∈ N) if the overriding macroplace mp i (mp i = {N i , P mp(i) } of the subnet N i belongs to the set * MP j created according to Equation (33).
In , the nesting relations between subnets were defined. Nesting relations for macroplaces can be defined analogously. Therefore, the concepts of descendant, ancestor, direct descendant, and direct ancestor can also be used for macroplaces. The nesting relations and the function * () will be additionally shown on the example of a hierarchical net, which is presented in Figure 8. It contains three macroplaces. The macroplaces mp 1 and mp 2 belong to the subnet N 0 , and the macroplace mp 3 belongs to the internal subnet of the macroplace mp 1 . The macroplaces mp 2 and mp 3 are instances of the same type. For the subnet N 0 the set * N 0 has the form N 0 ∪ N 1 ∪ N 2 ∪ N 3 , i.e., it contains this subnet and all of its descendant subnets. In turn, the direct descendants of the subnet N 0 are the subnets N 1 and N 2 . A direct ancestor of the subnet N 3 is the subnet N 1 , and all the ancestors of N 3 are subnets N 0 and N 1 . The subnet N 3 has no descendants. For the main subnet N 0 , the set * P 0 consists of all places in the net {p 1 , p 2 , ..., p 13 }, i.e., in the subnet N 0 and in its descendant subnets N 1 , N 2 and N 3 , while the set * P 3 has the form {p 9 , p 10 , p 11 , p 12 }. The set * T 0 consists of all the transitions {t 1 , t 2 , ..., t 13 } in the net, while * T 1 consists of the transitions {t 8 , t 9 , ..., t 13 } from the subnet N 1 and all of its descendant subnets (N 3 in this case). After defining the concepts related to the degree of nesting and function * (), the HFIPN hierarchy graph is formalized. A hierarchy graph is a directed graph in which nodes represent subnets (macroplaces) described in Definition 4. A hierarchy graph for the net from Figure 8 is shown in Figure 9. The graph allows for quick reading and understanding of subnets/macroplaces nesting, the number of instances and their nesting in HFIPN. A special node of the graph is the root representing the main subnet N 0 , whose name is main since N 0 does not have an overriding macroplace. If there is an internal macroplace in a given subnet, the node representing it in the hierarchy graph is connected to the node representing the overriding macroplace for this subnet. The direction of the arcs is visible in the graphical representation by arranging the nodes. The node, to which the arc leads (e.g., mp 3 in Figure 9), is located below and to the right of the node (mp 1 ) which is the starting point of the arc. Arcs in the hierarchy graph are unlabeled. The advantage of the graph is the presentation of the hierarchical structure of the net: the level of depth and the indication of the way of macroplace nestings in the net. It also allows determining the number of instances of a given macroplace type, because the labels of nodes (except main) are represented by a pair consisting of the macroplace name and the instance type of this macro. Moreover, the software version of the hierarchy graph in the HFIPN-SML simulator allows a user to click on any node to move inside the macroplace (subnet) represented by that node.

The Algebraic Representation
In this subsection, the algebraic representation of HFIPN is presented. First, the auxiliary functions are defined and discussed: * ∆ i : * P i → * Ω i , (38) Functions (38)-(43) extend the following functions: assigning statements to places ∆ i (), returning the places capacity K i (), assigning conditions to transitions Γ i (), determining the degrees to which the conditions corresponding to the transitions Θ i (), as well as weight functions W i () and initial marking functions M 0(i) (), which are all defined within a subnet (Definition 5). The extended functions * ∆ i (), * K i (), * Γ i (), * Θ i (), * W i (), * M 0(i) () defined for a subnet N i can take as arguments elements that belong to N i directly or to its descendant subnets. These functions are explained using the exemplary net shown in Figure 10 and the function returning the capacity of places. The other extended functions work in the same way. For the subnet N 0 , the function K 0 () arguments can only be places that are directly in the subnet, i.e., p 1 -p 4 . However, for the same subnet, the function * K 0 () can additionally return capacity for the places p 5 and p 6 , i.e., all places of descendant subnets for N 0 (N 1 in this case). If the subnet has no descendant subnets (N 1 in Figure 10), then the functions K i () and * K i () work in the same way. The functions K 1 () and * K 1 () can only return capacity of the places p 3 -p 6 . Each subnet N i in HFIPN may be represented by its own algebraic representation N i = ( * C i , * Ω i , * Ψ i , * ∆ i , * K i , * Γ i , * Θ i , * M 0(i) ). The algebraic representation of the subnet N 0 is used to simulate the work of the entire net. However, for the remaining subnets, it can be used to test the properties or to simulate the work of the subnet, separately. The most important element of the algebraic representation is the incidence matrix * C i defined analogously to classical Petri nets, but taking the hierarchy into account. It has the following form.
, e} one of its subnets (N i ∈ N), for which card( * T i ) = * b i and card( * P i ) = * a i . The incidence matrix * C i = * C + i − * C − i is defined as follows by the matrices: for j = 1, 2, ..., * b i and k = 1, 2, ..., * a i .
The HFIPN algebraic representation enables the computation of a new marking in the net in response to transition activation and token movement between places. It uses vector and matrix operations, such as addition (46), multiplication (47), division (48), and minimum of two numbers (49): where: i = 1, 2, ..., n and j = 1, 2, ..., m.
Therefore, for each subnet N i ∈ N, the algebraic representation takes the following form: where: * M i is the vector of the length 1 × * a i , holding the current marking of places, where * a i = card( * P i ); * M i is the vector of the length 1 × * a i , holding the new marking of places; * U i is the vector of the length 1 × * b i , in which the given coefficient is equal to one if it corresponds to the enabled transition by the marking * M i in the subnet, where * b i = card( * T i ); ∆ * Θ i is the vector of the length 1 × * b i , in which the coefficient ∆θ j (1 ≤ j ≤ * b i ) describes the increment in the degree to which the condition corresponding to the transition t j (t j ∈ * T i ) is satisfied; * K i is the vector of the length 1 × * a i , holding the places capacity.
For the subnet N 0 from Figure 10, the incidence matrix * C 0 and the vectors * M 0 , * K 0 , * U 0 , * Θ 0 take the following form: If the increment of the degree to which the condition corresponding to the transition t 1 is satisfied changes by ∆θ 1 = 0.1, and the event e, synchronizing the work of all transition, occurs, then the vector ∆Θ 0 takes the following form: According to (50), After that, the vector * Θ 0 changes as follows: * Θ 0 = t 1 t 2 t 3 t 4 t 5 0.4 0 0 0 0 , (58) and the vector ∆ * Θ 0 , which contains the increments of the degrees to which the conditions corresponding to the transitions are satisfied, is reset to zero at each calculation cycle. Therefore, the vector * Θ 0 is used for storing the current values of these degrees and to calculate their increments at the beginning of each cycle.

HFIPN-SML Tool
In this subsection HFIPN-SML is briefly described. Most of the figures presented in this and the next section are created using screenshots from this application. Although the tool has not yet been published, it implements some functionalities that can be useful in practical modeling. In the current version, HFIPN-SML enables: All these features can make HFIPN-SML useful for practical modeling from the control system design to its practical implementation, and even then for monitoring purposes. However, some gaps need to be filled, i.e., automatic code generation module based on a hierarchical net and automatic analysis of properties integrated with HFIPN-SML.

Exemplary Application
In this section, an example of using HFIPN is shown, including the concepts of macroplace instances and macroplaces that can have multiple input, output and input/output places. Figure 11 shows a system for mixing three components, while Figures 12-16 illustrate an algorithm in the form of an HFIPN graph for controlling this system. First, three portions of each of the liquids L 1 and L 2 , measured in the tanks T k 1 and T k 2 , are transferred to the mixer. At the same time, two soluble bricks are fed into the mixer. Then all ingredients are mixed for some time represented by the variable T imeV al. The default time value is stored in tx 1 . Moreover, the measured time is converted to a value from the range [0, 1] and stored in T IM E1. Finally, after obtaining the liquid of the desired consistency, the mixer is emptied and the whole process is repeated. In addition, if the liquids L 1 and L 2 are not transferred to the mixer at a similar speed, the mixing time can be extended even up to twelve times by the value of the variable tx 2 or the entire process may stop. Figure 12 shows the main subnet with four macroplaces (modules). The macroplace mp 1 controls the transport of the bricks, while the macroplace mp 2 controls the transfer of the liquids L 1 and L 2 to the mixer. The macroplace mp 4 serves as a diagnostic module that checks the uniformity of filling by both liquids. The macroplace mp 3 controls the mixing of all ingredients and emptying the mixer. The whole process starts with pressing the ST ART button (transition t 1 ), and the red diode is turned on, while the green one is turned off (place p 2 ), what signals the operation of the system. The modules mp 1 and mp 2 are activated. Figure 11. The scheme of the system to mix three components: two liquids and soluble bricks. Based on [64]. The macroplace mp 1 (Figure 13) turns on the belt motor (place p 10 ), which causes that the two bricks are transported to the mixer. After the detection of the second brick by the binary transit detector T D the feed belt is turned off (p 13 ). The input place p 9 of type p represents the number of bricks that need to be transferred to the mixer. Moreover, this place enables to observe the state of the macroplace mp 1 internal subnet (N 1 ) from the main subnet (N 0 ) without going inside the subnet. If the marking of this place equals 2, it means that the two bricks will soon be transported to the mixer. If it equals 1, a single brick has been transported and the other one will be moved soon. If the marking of this place is 0, and the marking of the output place p 13 equals 1, it means that there are two bricks in the mixer. In the other case, the brick transport module is not working. In the macroplace mp 2 (Figure 14), the transfer of the liquids L 1 and L 2 to the tanks T k 1 and T k 2 is controlled using macroplace mp 5 and mp 6 , that are instances of the same type. The dosing of both liquids with the use of the valves V 1 (place p 3 in mp 5 ) and V 2 (p 6 in mp 6 ) is monitored by the analogue sensors An 1 (transition t 3 ) and An 2 (t 4 ). It ends when the value of the signal provided by the sensors equals 1. Then, both measured liquid portions are transferred from T k 1 and T k 2 to the mixer through the valves V 3 (p 17 ) and V 4 (p 18 ). The valve V 3 (V 4 ) is closed by the action assigned to the place p 3 (p 6 ) when the value from the liquid level sensor An 1 (An 2 ) equals 0. Then, successive portions of liquids are measured.
The number of portions of the liquids L 1 and L 2 that need to be transferred to the mixer are represented by the input places p 5 and p 8 . Both liquids have to be delivered at a similar speed due to the technological requirements. The sum of both portions of the liquids transferred into the mixer is represented by the output place p 19 . Thus, at any time during the work of the liquid dosing module, its state can be determined based on the marking of the places p 5 , p 8 and p 19 (analogously to mp 1 ). If, for instance, the marking of the place p 5 equals 1.9, p 8 equals 1.87, and p 19 is 2, it means that the transfer of the first portions of both liquids is complete, while the second are being transferred into the dispensers. During the transport of the liquids to the mixer, twelve tests are performed to determine whether the speed of transferring the liquids L 1 and L 2 is similar, as long as the process has not been interrupted earlier. Through the output place p 20 the token is sent to the test module (the macroplace mp 4 ). The test is performed every half of the portion obtained from both liquids (a total portion number is six).
The module comparing the speeds of the liquids dosing into the mixer (macroplace mp 4 ) is shown in Figure 15. First, the numeric variables x 1 and x 2 are calculated (place p 21 ) based on the marking of places that are inside the macroplace mp 2 to determine how many portions of L 1 and L 2 were transferred into the mixer. If x 2 equals 0 (t 22 ), the whole process is stopped (p 24 ). This most likely means the dispensing failure of L 2 . If x 2 is greater than 0, the quotient of x 1 and x 2 is assigned to the variable x. Then, based on x, specific control actions are taken by activating one of the transitions t 17 -t 19 . Conditions excluding any conflict between these transitions are assigned to them. If L 1 and L 2 are transferred into the mixer evenly (x ∈ [0.9, 1.1]), no additional control action is taken. If one of the liquids is transferred to the mixer too fast compared to the other, but their proportion is still sufficient (x ∈ [0.8, 0.9) ∪ (1.1, 1.2]), the mixing time of all components T imeV al is extended by tx 2 (p 23 ). If L 1 and L 2 are transferred unevenly (t 19 ), the whole system is stopped (p 24 ). In the macroplace mp 3 (Figure 16), the mixing of all ingredients using the rotary engine M R is controlled. First, the operation of M R and the external timer T M are initialized (p 14 ). After mixing for a period of time defined by T imeV al and obtaining the liquid of the desired consistency, the mixer is emptied through the valve V 5 (p 15 ). The binary level sensor BM L detects when the mixer is completely empty (t 13 ). After that, the mixing time T imeV al of the components is restored to the base value (p 16 ). Then, if the ST ART button is on, the next cycle of the whole system starts. The place p 15 is an input-output place and allows for better visualization of the module from the main subnet.
The presented example shows that the use of HFIPN can improve the visualization of the process and facilitate communication between different modules in the net. Moreover, in the macroplace mp 4 an example of dynamic control in response to fuzzy marking of places is presented.

Conclusions
In this work, a new concept of HFIPN has been introduced. The contributions of this study are as follows: The proposed macroplaces with several inputs and outputs can be useful for the implementation of modules that require asynchronous communication and facilitate resource modeling as illustrated in the example presented in Section 4. The concept of macroplace instances allows for the creation of several modules with the same structure and operation, their use in different areas of a net, and their simultaneous modification by introducing changes to one of them.
The nesting relations have also been defined, as well as the hierarchy graph which presents graphically the hierarchical structure of the net: the number of macroplaces and instances, and how they are nested in the net. The implementation of the graph in the HFIPN-SML simulator allows for quick movement between modules. An important part of the described research is an algebraic representation of HFIPN and the conversion method of a hierarchical net to the corresponding flat FIPN.
However, further studies on HFIPN are needed. In the future work, we are going to focus on the conversion of its graph to executable code.