Algorithm 2: –Greedy Solution |
-
Input:
V (tasks), W (users), (probability of random selection), M (maximum number of episodes with no improvement)
-
Output:
R (greward of all episodes), {} (profit of platform, travel distance of workers and workers’ response time), {} (travelling trajectory of workers)
-
1:
// global maximum greward
-
2:
// profit, distance and response time
-
3:
; // number of episodes with no improvement
-
4:
while do
-
5:
; // local greward in current episode
-
6:
for do
-
7:
if there exist feasible users for task then
-
8:
Random selection with probability ; otherwise, greedy selection (reward)
-
9:
Get reward of this assignment as
-
10:
; // update local greward
-
11:
if the task cannot be completed then
-
12:
Tasks are not assigned to workers, update status of tasks and workers’ set
-
13:
else
-
14:
Assign the task to worker, update status of tasks and workers’ set
-
15:
end if
-
16:
end if
-
17:
end for
-
18:
if then
-
19:
R = ; // update global maximum greward
-
20:
Record
-
21:
Record paths
-
22:
k = 0; // reset k with improvement
-
23:
else
-
24:
k = k + 1; // increase k without improvement
-
25:
end if
-
26:
end while
-
27:
return R, {} and
|