# Task Assignment of the Improved Contract Net Protocol under a Multi-Agent System
## 3 Task Allocation under the Improved Contract Net Protocol
### The Task Assignment Process  
The task assignment process includes the whole bidding process of the improved contract net protocol, releasing a task pheromone to the public environment by the manager agent, obtaining a bidding pheromone by the contractor agent according to the accepted task pheromone and the manager agent selecting a winning contractor agent to complete the task according to the right bidding pheromone [23]. The whole process of assigned tasks is shown in the following steps 1 through 7.  
Figure 2: The flow of pheromones.  
Step 1: The manager agent sets the \(ID\) for each decoupled task and each decoupled task is written as a task pheromone A<\(ID\), \(Nam\), Pri, Sti, Rew>. In addition, it is released into the public environment.  
Step 2: The contractor agent can perceive the task pheromone from the public environment, then the contractor agent will judge its own value of \(Val\) and the value of \(Sti\) in this task pheromone and the contractor agent will calculate the value of \(\alpha\), \(\beta\) and \(CosT\) according to Formulas (3) and (4) if \(Val>Sti\).  
\[\left\{\begin{array}{l}\alpha=\frac{Pri}{100}+\frac{Rew}{10}\\ \beta=\frac{\sin(2\pi pri\times Rew)}{100}+\frac{\exp(-(3 Rew)^{2})}{10}\quad \alpha,\beta\in[0.001,0.1)\\ \\ CosT=\sum_{i=1}^{r}T_{0i}\end{array}\right. \tag{3}\]  
\[CosT=\sum_{i=1}^{r}T_{0i} \tag{4}\]  
where, \(T_{0i}\) is the estimated time for the current agent to complete the task \(i\), \(r\) is the number of tasks to be completed by the contractor agent and the lower limit of \(\beta\) is 0.001.  
Step 3: The calculated value of \(CosT\) is compared with the agent's own ability value of \(Cap\) and it proceeds to the next step only when the value of \(Cap\) is greater than \(CosT\). The bidding pheromone B<\(ID\), \(Nam\), H, \(Cap\), \(CosT\), \(L\),\(Val\)> will be calculated and released into the public environment again. Otherwise, the contractor agent will abandon this task.  
Step 4: The manager agent perceives the same \(ID\) and \(Nam\) of the bidding pheromones and ranks all bidding pheromones by a calculation. In the case of the same task set, the priority of the task is sorted from the value of the largest to the smallest. For two tasks with the same priority, they are sorted by a value from large to small. Furthermore, the comprehensive evaluation sequence table of the tasks is obtained accordingly. The value calculation is shown by Formula (5).  
\[Z=\lambda_{3}\times Y-\lambda_{4}\times\frac{T_{\max}-CosT}{T_{\max}-T_{\min}}- (1-\lambda_{4})\times\frac{L_{\max}-L}{L_{\max}-L_{\min}} \tag{5}\]  
where, \(0<\lambda_{3},\lambda_{4}<1\) and \(T_{\max}\) is the task completion time of the agent with the maximum value of \(Val\), \(T_{\min}\) is the task completion time of the agent whose value of \(Val\) is greater than \(Sti\) and less than the other \(Val\), \(L\) is the number of tasks waiting to be completed in the task list of the current agent, \(L_{\max}\) is the maximum number of waiting tasks among all contractor agents, \(L_{\min}\) is the minimum value.  
Step 5: Assign the task to the first agent in the list and inform it of winning the bid. Update the \(L\) value as shown in Formula (6) and check whether the task is completed with the contractor agent after the time of \(CosT\).  
\[L=L+1 \tag{6}\]  
Step 6: If the contractor agent that obtains the task successfully completes the task, it will update the value of \(Val\); if the task is abandoned in the process of completing the task, it will update the current agent's value of \(Val\), then notify the manager agent to check the second contractor agent in the comprehensive evaluation sequence of tasks. If the agent does not get the task after that, it will assign the task to that agent, otherwise it will repeat Steps 1-4.  
Step 7: Complete the task.  
The specific protocol flow of the improved contract net is shown in Figure 3. In order to make the whole process easy to explain, only one manager agent and one contractor agent are depicted in Figure 3.