| | Input: //The current state of VMs |
| | Input: //VMs speeds in MIPS |
| | Input: //The cloudlet to be scheduled in MIPS |
| | Input: //The selected virtual machine |
| | Output: //The reward |
| | Function rewardCurrentState(): |
| | //Get the number of VMs |
| | //List of makespans initialized with zeros with a length of |
| | forIterate over VMs |
| | do |
| | //Make a copy of the current VMs state |
| | //Calculate the run time of the given task in |
| | //Add task’s execution time to |
| | //Calculate the makespan of the copied state |
| | end |
| | //Sort VMs executions times in descending order |
| | //Get the unique length of makespans to exclude makespans with the same value |
| | //Create an empty dictionary to store each VM rank. |
| | //The highest rank is given to a VM |
| | for//Iterate over VMs |
| | do |
| | //makespan’s value from sorted makespans |
| | not in //Check the makespan’s value if it is not in the rank dictionary |
| | then |
| | //Assign the rank’s start value to |
| | //Decrement rank’s start value |
| | end |
| | end |
| | //List of scores initialized with zeros with a length of |
| | for//Iterate over makespans |
| | do |
| | //Get |
| | //Score the VM based on makespan’s rank |
| | end |
| | return//Select the score based on the given action |
| | End Function |