Modeling and Simulation of Task Allocation with Colored Petri Nets

The task allocation problem is a key element in the solution of several applications from different engineering fields. With the explosion of the amount of information produced by the today Internet-connected solutions, scheduling techniques for the allocation of tasks relying on grids, clusters of computers, or in the cloud computing, is at the core of efficient solutions. The task allocation is an important problem within some branch of the computer sciences and operations research, where it is usually modeled as an optimization of a combinatorial problem with the inconvenience of a state explosion problem. This chapter proposes the modeling of the task allocation problem by the use of Colored Petri nets. The proposed methodology allows the construction of compact models for task scheduling problems. Moreover, a simulation process is possible within the constructed model, which allows the study of some performance aspects of the task allocation problem before any implementation stage.


Introduction
The services provided by Internet-based modern applications require the execution of massively parallel processes in order to produce time-effective information for different requirements.The processing of these "Big Data" is very computing, demanding in almost all of the cases.Thus, vast server farms installed over the world are ready to process the requests from different users.The digital data available in the web are huge and diverse, therefore complex, and in a continuous growth rate.
Nowadays, most of the queries on Internet are produced from smartphones and personal computers.However, the data traffic on web is expected to grow in an exponential rate, as the technology related to the Internet of Things (IoT) allows the connection of other devices from the houses, smart warehouses, automated driving cars, machinery from the agriculture, UAV's for goods delivering, or smart cities, to mention a few.In order to cope with the challenges related to a massive number of connected devices, new ways of computing emerged.Most of them are based on parallel and distributed computing, such as clusters, grids, and cloud computing paradigms.
At the core of these paradigms are the tasks scheduling and resources allocation problems.Adaptations of theory, methods, algorithms, tools, and others are arising in order to cope with the increasing number of cores per processor, as well as with the interconnected and heterogeneous computers, considering that, in many cases, those computing architectures are connected through the Internet.The tasks scheduling and resources allocation were well studied in the context of architectures with a relatively small number of processors.One of the fundamental concerns deals with designing algorithms for an efficiently allocation of the tasks among all the available processes and resources.
The answer to this question may lead to a hard work, since, in the worst case, it involves an exponential number of possible solutions [1].Thus, a simulation process, for scenarios with a big number of computing elements, or cores, as in cloud and grid computing, is a valuable tool.In this context, the modeling and simulation are disciplines widely used to obtain feedback and statistics information, to improve associated applications and algorithms.Through experimentation in simulators, a fast prototyping process allows performance evaluation and parameter tuning for different workload conditions.To perform an efficient simulation process, a suitable modeling method is required.The Petri nets (PN's) and its extension, such as colored PN (CPN), have been considered as an efficient modeling technique for concurrent and distributed systems.
This work proposes the modeling of the task allocation problem by the use of a methodology based on CPN's.It also shows how to simulate these models in order to obtain relevant information for the design process.To illustrate the techniques, this work considers a tree structure and supposes that the set of tasks and the set of processes are fixed and defined before the task allocation is performed as in Ref. [27].The proposed CPN modeling method represents the behavior of a set of processors, or working threads, that traverse a tree structure from the root to a single leaf in order to acquire a task.The processes decide what route to take at each node of the tree structure, by using a decision function.Then, it routes the tree backwards updating some global variables that serves as inter-process communication mechanism.
The proposed method allows obtaining a CPN, which is a compact representation of the problem, and at the same time, it allows simulating its behavior and obtaining performance graphics.The colored tokens represent the processes, tasks, and other variables of interest in the problem.A decision function is attached to some transitions of the CPN model.This function influences the behavior of the process or thread.Due to the graphical nature of the CPN, in addition to the mathematical fundamentals, this methodology provides a great framework to simulate and analyze the task allocation problem, avoiding the state space explosion, and thus, having a compact representation of a complex behavior.The flexibility of the modeling framework allows simulating different scenarios, using different decision functions, as well as varying the number of initial processes or threads.Additionally, the Petri Net model can be easily extended to simulate a wider number of tasks.
The rest of this chapter includes a background of the task allocation and several techniques that have been used for addressing this problem.The modeling framework based on colored Petri nets is next presented and the modeling methodology is detailed.This methodology highlights the main aspects of the task allocation problem, such as the concepts of task and process, as well as the balancing policies and how to capture them by CPN blocks.The simulation of the obtained CPN models is then presented and discussed.Some performance charts are provided.The charts allow the study of key aspects of task allocation problem such as the effective work done by a processor, the task contention, the effects of different balancing policies, to mention a few.With this information, the scientists and engineers are able to study different aspects of the problem prior any implementation stage in a particular field of interest.

Task allocation problem
Task allocation problem has been addressed for several purposes and using different techniques.Analytic solutions are in some cases prohibitive since they require the analysis of an exponential number of possible solutions.Thus, some designs use probabilistic approaches to produce good solutions in a reasonable time.Jevtić et al. [28] present a distributed bee's algorithm for static task allocation inspired on the behavior of a colony of bees and based on the optimization of a cost function.They also show results using the Arena simulator.Delle Fave et al. [29] introduced a decentralized optimization for static task assignment based on a constrained utility function, firstly evaluated by simulations.Johnson et al. [30] state a distributed multi-agent algorithm for static multi-task allocation as an optimization problem based on mixed-integer programming.They also provide some results of Monte Carlo simulation.Zhao-Pin et al. [31] introduced a distributed and static task allocation algorithm for multiagents that learn how to determine by themselves what tasks should realize and how to form coalitions for cooperation, via their proposed profit-sharing learning mechanism.Macarthur et al. [32] introduced a dynamic and distributed algorithm for multi-agent task allocation problems, based on fast-max-sum algorithm combined with a branch-and-bound technique, in order to reduce the execution time in the allocation of task to its respective agent.Alistarh et al. [27,33] present a decentralized task allocation, static and dynamic, based on to-do trees, where decisions on every inner node are based on a probability function.
One of these most used techniques, due to its simplicity of implementation, is based on a rooted tree structure that the process traverses in order to acquire a task [7,8].The tree structure allows to the working processes for executing a non-deterministic behavior, which is quite suitable for real environments.Typically, in these tree structures, every reference to a task is allocated on the leaves.Thus, every internal vertex allows to a working process taking a decision based on a function over the number of tasks in every leaf of the subtrees from each child of the current vertex.Hence, the decision function, which could be a simple deterministic algorithm, or a sophisticated statistical or stochastic procedure, is a key element for which a process traverses through the tree structure, in this kind of task allocation techniques.
Figure 1 shows a binary tree that represents a scheduling problem where eight tasks have to be attended.The height of the tree is H ¼ log 2 ð8Þ¼3, where the level of v 2, 2 is 2, the vertex v 1, 0 is said to be parent, or ancestor, of v 2, 0 and v 2, 1 , and the latter two are said to be children, or descendant, of v 1, 0 .The vertex v 0, 0 is the root, and every vertex is internal except for all of the level 3, i.e., v 3, x with x ∈ ½0, 7, which are known as leafs of the tree.The tree formed by the vertexes v 2, 1 ,v 3, 2 ,v 3, 3 and the corresponding edges that connects them, is a subtree with v 2, 1 as a root.
From the graph theory point of view, a DT is an acyclic graph in which a unique path connects every node to others, represented in a top-to-bottom fashion, where the root, i.e., initial node, is plotted at the top of the tree.The DT is a binary decision tree (BDT) if at every node is considered at most two possible decisions, as shown in Figure 1.For more information on trees see Ref. [34].

Task scheduling with DT
By using a tree structure like the one depicted in Figure 1, the task allocation algorithm is relatively simple.Each working process shares the tree structure and iterates in an infinite loop, trying to acquire a new task to execute, which is located at the leafs of the tree.Each working process starts at the root node of the tree and decides whether to go to the left or the right child node.The process knows an approximation of the total pending tasks at the left and right subtrees at every step.For example, in Figure 1, each working thread knows that at the beginning of the scheduling process, at the root node, that there exist four pending tasks at the Computer Simulation left subtree and four pending tasks at the right one.Then, at every stage, the processes decide to traverse to the left or right in an asynchronous fashion.The total number of pending tasks is backward updated from the lower nodes to the uppers as the tasks are successfully executed by the threads.Notice that, the number of pending tasks at the left or right subtree is an approximation since this number may be not updated yet.
Since the processes are asynchronous among them, it is possible that they arrive to the leaf nodes that may occur at different rates.Every time that a process reaches a leaf, it asks for the execution of the task.If such a task is free, then the process blocks this task, executes the activity, and marks the task as executed.Then, it goes back to the root node to seek for a new task to execute, while the information of the remaining tasks is backward updated from the leaf to the root node.It is possible that when a process reaches a leaf node, the corresponding task was already executed by another process.In this case, the process goes back to the root node, and this miss is counted to measure the effectiveness of the algorithms.
In Eq. ( 1), it represented a decision rule that a working process may execute at every level of the BDT.Let x be the total number of pending tasks in the left subtree and y be the total number of pending tasks in the right subtree, while r is a random number.Thus, the probability to go to the left subtree in a flip coin is given by r.As greater the ratio, it is greater the probability to go to the left child of the current node.One of the main objectives of this work is to measure the effectiveness of a decision rule as Eq. ( 1) by means of a simulation process.
The main characteristic that differentiates CPN from other type of nets resides in the token definition.In a CPN, the tokens can stand for complex data besides of a single value, such as an integer, a real, Boolean or strings.This characteristic allows for the representation of elaborated data types, similar to those used by high-level programming languages.This ability exploits the multi-set cardinality to construct compact models that otherwise are in the power set of the colored tokens.The formal definition of a CPN is as follows [35].
Ct〉 where its elements are described as: • P is a finite set of places of N , with m ¼jPj, • T is a finite set of transitions of N , such that T∩ P ¼ ∅, with n ¼jTj, • B is finite set of color classes, • F is a set of conditions, • C p : P !B is the color domain mapping, • C t : T !F is a conditional color mapping, and • Pre, Post ∈ S jPj • jTj are matrices representing the input and output incidence matrices of N , such that Pre½p, t : C t ðtÞ!BagðC p ðpÞÞ and Post½p, t : C t ðtÞ!BagðC p ðpÞÞ are mappings for every pair ðp, tÞ ∈ P • T; where BagðSÞ¼∪ bðs i Þ for all s i ∈ S, such that bðs i Þ¼ X s i ∈ S.
The incidence matrix is C ¼ Post À Pre.The mapping given by Pre½p, t : C t ðtÞ!BagðC p ðpÞÞ, defines for each conditional color mapping f of t ði:e: ∀f i ∈ C t ðtÞÞ, the token bag to be removed from p, in the occurrence of t, under color condition f.In the same way, Post½p, tðf Þ specifies the token bag to be added to p, in the occurrence of t, under color condition f.Definition 2. A marking M of a CPN N is a vector of size m ¼jPj, such that MðpÞ ∈ BagðC p ðpÞÞ for every p ∈ P. The vector M 0 denotes the initial marking of the net N and the pair ðN ,M 0 Þ is known as a CPN System.
. Definition 4. The marking evolution w.r.t a color condition f is given by M M 0 .For a general color condition, it is denoted as M! t M 0 where f is implicit in a context.
The net in Figure 2 represents a very simple CPN System ðN ,M 0 Þ where: • B ¼ o∪ r, where o ¼fo 1 ,o 2 g and r ¼fr 1 ,r 2 g are variables, Computer Simulation • Pre and Post are as depicted, and Notice that, at the initial condition, ∅, {r 1 , r 2 } :{ðo 1 , r 1 Þðo 2 , r 2 Þ}, thus, t 1 can be fired for any color binding fðo 1 ,r 2 Þðo 2 ,r 1 Þg due to the condition in f 1 .Suppose that, t 1 fires for color condition Roughly speaking, the CPN binds the even number in p 1 to the character "a" in p 3 and the odd number to character "b."This is defined by the guard function f 1 attached to t 1 .The function s 1 discards the r element of the token bound to the firing of t 1 , while the firing of t 2 adds two to the o element of the token and recovers the r element that is put back to the place p 3 .Thus, the tones in p 1 changes to o 1 ¼ 1, 3, 5, … and o 2 ¼ 2, 4, 6, …, while the characters "a" and "b" in p 3 remain the same all the time.The "R" in the place p 3 stands for "resources," which is the function intended for the characters in this CPN model.
Notice that, the bindings ðo 1 ,r 1 Þ and ðo 2 ,r 2 Þ are discarded by the function f 1 .This is one of the advantages of the CPN modeling tool, since otherwise, the combinatorial explosion of possible bindings turns untreatable under some circumstances that typically arises in real applications.
For more information about the CPN modeling formalism and related analysis and tools, see Ref. [36].

Modeling and simulation of task scheduling
The construction of a generalized model for a BDT based on CPN considers d different features and nT classes.The procedure includes the identification of the transitions and places of the model, the arcs and its labeling, as well as the multi-set of colored tokens.The remaining of this section is devoted to detail the methodology and illustrate it by short examples.

Structure of the task allocation as a CPN
Consider the following steps for the construction of a CPN model that captures the structure of a BDT.It is supposed that the BDT is a full binary tree with a complete set of tasks represented by a structure called Task Array.Thus, the size of the Task Array is 2 H , where the height of the tree is H.
Step 1. Labeling nodes in the BDT Firstly, suppose that the DT is a full binary tree.Then, assign "0" to every left edge and "1" to every right edge.This labeling represents the result of the flip coin in the task allocation procedure of a BDT discussed in the previous section.
After that, some information is used to label every node with a pair ðdepth, positionÞ,wheredepth is the level of the node, and position is the corresponding position from left to right.For example, considertherootnodeð0, 0Þ in the section of the BDT depicted in Figure 3.It is a fraction of the tree of height H ¼ 3ofFigure 1.Then, to label the children of the root node proceed as follows: Therefore, the label of the left child is Step 2. Building the CPN System Let ðN ,M 0 Þ be a CPN System for a dynamic binary decision tree for nT classes and d features with N ¼ 〈P, T, Pre, Post, B, F, C p ,C t 〉 constructed as follows: • T is the set of transitions with jTj¼jP O j. Computer Simulation , and a ¼ ∪ a l where o i ¼ 〈depth i , pos i , val i , success i 〉, r j ¼ 〈depth j , pos j , data j 〉, a l ¼ 〈pos l , ready l 〉 for i ∈ ½1,d, j ∈ ½1, 2 Hþ1 À 2, and l ∈ ½1,nT, with depth i , pos i , val i , success i , data j , exist l variables and depth j , pos j , pos l constants.
• C p ðp i Þ¼o for all i ∈ ½1, jP O j, C p ðp i Þ¼r for all i ∈ ½jP O jþ1, jPj and C p ðp i Þ¼a for i ¼ 2ðHþ 1ÞþH þ 1.
• so 3 : o !o, such that so 3 ð〈depth i , pos i , val i , success i 〉Þ¼〈depth i , pos i , val i , success i ¼ 1if Exist ðpos i ,a l Þ¼1 otherwise 0〉, where Existðpos i ,a l Þ returns 1 if for a color class a l ¼ pos l , exist l with pos l ¼ pos i , exist l ¼ 1, otherwise 0.
Modeling and Simulation of Task Allocation with Colored Petri Nets http://dx.doi.org/10.5772/67950 • The initial marking, assuming that the Task Array is initially full, is M 0 defined as follows: HÀi 〉 assuming that the Task Array is initially full, as mentioned.
Figure 4 shows the relation of the tree structure with the proposed CPN as stated by the previous definition.Observe that places of type O represent every level from the root to the leaves, forward, and backwards, i.e., a token in one of those place contains the information of pos, depth,andval.Places of type R represent the state of every subtree from every node at that level, i.e., the value of the data function for every node of the same level given by pos and depth.Place of type A represents the Task Array state, i.e., the information of the availability of the task.

Dynamics of the task allocation as a CPN
Typically, in these tree structures, every reference to a task is allocated on the leaves.Thus, every internal vertex allows to a working process taking a decision based on a function over the number of tasks in every leaf of the subtrees from each child of the current vertex.Hence, the decision function, which could be a simple deterministic algorithm, or a sophisticated statistical or stochastic procedure, is a key element for which a process traverses through the tree structure, in this kind of allocation techniques.The following definitions allow capturing these dynamics aspects of the task allocation based on a BDT.
Definition 5.The pos is a position function defined from a set of vertexes V of a tree T to the set of natural numbers N as pos : V !N, such that posðvÞ¼j, where j is the numeric position of vertex v with respect to all the vertexes in the same level and counting from left to right.Definition 6.The depth is a function defined from a set of vertexes V of a tree T to the set of natural numbers N as depth : V !N, such that depthðvÞ¼#edges from the root node to v: Notice that, in Figure 2, the identification of a vertex v is given by v i, j where i ¼ depthðvÞ and j ¼ posðvÞ.
Definition 7. The w is a weight function defined from the set of edges E of a tree T to the set containing 0 and 1 as w : E !f0, 1g, such that wðeÞ¼0i fe connects a parent vertex to its left child, and 1 if it connects to its right child.Let consider a vertex v of a tree T denoted as v i, j such that i ¼ depthðvÞ and j ¼ posðvÞ.Then, for v i, x parent of left child v j, y and right child v j, z , with their respective edges e i, j, y and e i, j, z , with y < z, by definition of depth, then wðe i, j, y Þ¼0 and wðe i, j, z Þ¼1.
Notice that, the weight function w provides a zero for an edge connecting a father with its left child and a one for the edge connecting it with the right child.In the modeling methodology Computer Simulation here introduced, it is assumed that there exists a data structure called Task Array, which may have a reference to a task, if it is initially inserted, and the task has not been taken yet.This Task Array is mapped to the location of the leaves of a tree of height H from left to right, i.e., the array has a capacity for referencing a maximum of The quaternion semi À widel tasks.Figure 1 shows a tree of height 3, with 8 leaves that are associated with the location in the Task Array, where references to task are T0,T1…,T7.Accordingly, the following functions are defined.
Definition 8.The data function is defined from the set of vertexes V of a tree T to the set of natural numbers N as data : V !N, where dataðvÞ¼# of leaves in the subtree of root v with a task ready to be taken.
Definition 9.The parent is a function defined from the set of vertexes of a tree T to itself as parent : V !V, such that parentðvÞ¼y,ifv is child of y.
Definition 10.The val is a recursive function defined from the set of vertexes V of a tree T of height H, to the set of natural numbers N as val : V !N, such that: • (Base): valðv 0, 0 Þ¼0.
HÀi , for every pair ði, jÞ, In Figure 2, for example, valðvÞ is shown in the left of every vertex v as valðvÞ=, e.g., Observe that function val generates the value of a node based on the value of his parent.Notice that, there are 8 leaves in level 3, and then, every node value is exactly one entry in the Task Array.For example, the value 4= at v 3, 5 points to the entry T4.Now, consider the nodes in level 2, which are 4, exactly the half of those at level 3. Every vertex at this level, points to the first entry in a range of 2, i.e., v 2, 0 has a value of 0, v 2, 1 and has a value of 2. Thus, every vertex at level 1, points to the first entry of the two partitions of the Task Array, and therefore, v 0, 0 points to the first entry of the whole of the Task Array.
For illustration purposes, suppose that there is one node with two threads and eight tasks to be executed.Accordingly, d ¼ 2 and nT ¼ 8.The CPN System ðN , M 0 Þ for modeling this problem is shown in Figure 4.
Notice that accordingly to the proposed method, a full binary tree is obtained when nT ¼ 2 n for some n, since, in this case, H ¼ log 2 nT is exactly equal to log 2 nT.In the particular example,

Computer Simulation
• o i ¼ 〈depth i , pos i , val i , success i 〉 ¼ 〈0, 0, 0, 0〉, for i ∈ {1, 2}.This marking represents the current state of every process, i.e., at the beginning, processes are at root node v 0, 0 with a value 0. Success being 0 means that no task has been assigned to the current process.
• r j ¼ 〈depth j , pos j , data j 〉, such that j ∈ ½1, jrj, where: . These markings provide the information about the data available for every subtree constructed from the node identified as v depth, pos .
• a l ¼ 〈pos l ,ty l 〉, such that l ∈ ½1,nT, where: . These markings provide the information about the availability of the task located at pos, i.e., ty ¼ 1 if the task is available, 0 otherwise.Thus, Figure 4 represents a CPN that captures the structure of a BDT and the behavior of the working threads over the tree of height H ¼ log 2 nT ¼ log 2 8 ¼ 3.They represents the places and transitions for the traveling from the root down to a leaf, and the reverse way from the leaf up to the root, on the left and right side of the CPN, respectively.Additionally, the central places, marked as "R," represent the "resources" in the system, i.e., the shared memory registers and the tasks.
Consider an initial token in place p 1 ¼ 〈0, 0, 0, 0〉 as described by the initial marking M 0 .Now, the binding for t 1 requires two tokens from p 9 , besides one initial token in p 1 ,s u b j e c tt o conditions given by f 1 : ,w h e r edata 1 ¼ data 2 ¼ 4, assuming that the Task Array is full of tasks to be attended.Thus, the output of t 1 due to so The sketches of CPN in Figure 6 show the three main marking evolutions in the CPN subject to the binding functions f 1 ,f 2 ,f 3 .The marking evolution subject to f 1 from the current state is shown in (a).In (b), the tokens o i ,r j ,r k are taken by the depicted transition, since , the transition has fired, then o 1 ¼< 2, 3, 6, 0 >, since so 1 ð〈depth i , pos i , val i , success i 〉Þ¼〈depth i þ 1, pos i Ã 2 þ h i , val i þðh i ÞÃ2 HÀdepth i þ1 , success i 〉 assuming that h i ¼ 1.The tokens r j ,r k remain the same, since success ¼ 0. In (d), the marking evolution subject to f 3 from the current marking < 3, 6, 6, 0 > is updated to the marking < 3, 6, 6, 1 > Computer Simulation as shown in (f), since the task reference represented by the marking < 6, 1 > is available as shown in (e).Notice that, this marking is updated to < 6, 0 > as shown in (f), as expected.In (g), the input state of the transitions subject to f 2 is represented with the marking < 3, 6, 6, 1 >.Then, it is binding by f 2 with the token < 3, 6, 1 >, as illustrated in (h).Thus, the input token < 3, 6, 6, 1 > is updated to < 2, 3, 6, 1 > by so 2 , as well as, < 3, 6, 1 > is updated to < 3, 6, 0 > by ro 2 , as shown in the section (i) of the figure.
One of the main advantages of modeling the task allocation problem by CPN's is the possibility of varying the parameters during the simulation process, as well as the flexibility of the net structure in order to cope with a greater number of task to be attended.One of the key parameters for the simulation of the problem is the number of tokens of type O, which represents the number of processes or threads in a specific problem.The other important parameter is the decision function α, which is related to the spreading of processes or threads through the tree, by updating of depth and pos functions.It is clear, for example, that the distribution of the processes or threads at every level in the tree structure directly influences the contention at the acquisition of the tasks.
The next section explains the simulation process that is possible to execute with the proposed modeling methodology and how these simulations can help explore different parameters in order to optimize the task allocation problem.

Simulation of the CPN model
This section shows how to simulate a CPN model as that obtained by the methodology detailed in the previous subsection.The simulation process allows to investigate the performance of the model under parametric variations.First, the general characteristics of the simulation framework are introduced.Then, the simulation and results of a CPN model, representing a problem with 1024 tasks, are given.
The model parameters that have to be considered are a number of initially available tasks ðnTasksÞ, the height of the tree with respect to the number of tasks ðHÞ, and the decision function ðαÞ.For this example, those values are nTasks ¼ 1024, H ¼ log 2 1024 ¼ 10, and and where r is a randomly generated number.These parameters are fixed during every simulation process.However, the number of threads is varying between simulations, with d ¼ 2 n , 1 ≤ n ≤ nTasks, for a total of 10 simulations runs.
In the simulation framework, there are different measurements of parameters that can be obtained.For illustrative purposes, in this example, the attention is focused on study the impact on the performance of the task allocation procedure when the number of processes, or working threads, is increasing.
Table 1 summarizes some results obtained from the simulations performed on the CPN tools framework for a model with model described previously.The number of tasks was constant, while the number of processes was increased by a power of two, represented in the first column.The second column represents the average of events required per process to complete all the tasks.It provides a measure of the speed by increasing the number of processes.The third column represents the total number of readings to the task array.The forth column represents the total number of read collisions, i.e., when a process reads a task that was previously attended by other process.The fifth column represents the average of the reads to the task array executed by each process.The sixth column shows the average of the failed reads or collisions executed by each process.The seventh column shows the proficiency of the execution by the total amount of processes.Finally, the eighth column represents the average of total reads, including the failed ones, to the task array required per task.
The plot in Figure 7 shows the average of event, in the simulation framework, that each process required for completing all the tasks in the array.Notice that, as the number of processes increases exponentially, the number of events per processes decreases almost logarithmically.
The plot in Figure 8 shows the average of reads that each process has performed to the task array for the completion of all the tasks.As in the previous figure, notice that the number of reads decreases almost logarithmically as the number of processes increases exponentially.
The plot in Figure 9 shows the average of collisions, i.e., a process's read of a task that was previously attended by other process, as the number of processes increases.The figure shows that the maximum number of average collisions occurs when the number of processes is 32 in these experiments.The collisions, or failed reads, are highly influenced by the decision rule α.
The plot in Figure 10 shows the proficiency of attending all the tasks in the array as the number of processes increases.

Computer Simulation
processes increases to 256.The ideal behavior is to double the proficiency as the number of processes also double.However, the collisions at reading the tasks undermine this proficiency, as expected.Notice that, the plot is logarithmic.The plot in Figure 11 shows the average of work that each process has to do for completing a task, measured as the number of reads.This number slightly increases as the number of processes increases due to the growth in the number of collisions.Computer Simulation

Conclusions
This work presented a framework, based on Colored Petri nets, for the modeling and simulation of task allocation problems, which arises in environments such as grid or cluster of computers.The framework allows the construction of complex problems in a compact way.Additionally, a simulation process of the constructed models permits the study of different key aspects of the allocation strategies.Some analysis that could be performed includes the impact of different decision rules of the processes for allocating the tasks, the effect of a greater number of processes in the contention of the task's acquisition or the ration of the increased speed to the attention of tasks by a greater number of processes, among others.Additionally, the methodology allows with ease the construction of structures for an incremental model construction and its respective simulation process.
The proposed methodology allows with ease the extension to n À ary tree structures as well as tree structures with a greater number of tasks and their respective simulation process.

Figure 1 .
Figure 1.A direct rooted full binary tree.
where P O is the set of places with assigned tokens of type O, P R is the set of places with assigned tokens of type R, P A is the place with assigned tokens of type A. jP O j¼2ðH þ 1Þ, jP R j¼H and jP A j¼1, where H ¼ log 2 nT.Places of type O represent every level from the root to the leaves, forward, and backwards, i.e., a token in one of those place contains the information of pos, depth, val.Places of type R represent the state of every subtree from every node at that level, i.e., the value of the data function for every node of the same level given by pos and depth.Place of type A represent the Task Array state, i.e., the information of the availability of the task.

Figure 6 .
Figure 6.Binding and firing of a CPN transition.

Figure 7 .
Figure 7. Average of events per process.

Figure 8 .
Figure 8.Average of reads per process.

Figure 9 .
Figure 9. Average of collisions per process.
The color mapping is C p ðp k Þ¼o for k ∈ ½1, 8, C p ðp k Þ¼r for k ∈ ½9, 11 and C p ðp 12 Þ¼a.That is, the places p 1 , …,p 8 accept tokens of type O, the places p 9 ,p 10 ,p 11 accept tokens of type R, and p 12 accept tokens of type A. The conditional color mapping is C t ðt k Þ¼f 1 for k ∈ ½1, 3, C t ðt k Þ¼f 2 for k ∈ ½5, 7, and C t ðt k Þ¼f 3 for k ¼ 4 and k ¼ 9.The Pre-and Post matrices for the net of this example are shown in Figure 5.

Table 1 .
The proficiency increases almost exponentially as the number of Simulation results for nTasks ¼ 1024.