|
Algorithm 1: The pseudocode of the proposed algorithm for finding the expected throughput , the optimal transmission energy and the action for channel n. |
|
Notations: |
|
K denotes the number of slots for calculating the channel sensing order. |
|
denotes the set of sensed channels, which are arranged in sensed order. |
|
denotes the set of not yet sensed channels. |
|
denotes the packets of energy in the battery at the beginning of each time slot. |
|
and denote the energy packets consuming for sensing per channel and channel switching per step, respectively. |
|
Input: ; Output: Action (Active or Silent), and . |
| 1: ; ; use Equation (4) to calculate for each channel. |
| 2: if
// Remaining energy is not enough for sensing channel n
|
| 3: Action = Silent, ,
|
| 4: else
|
| // Calculate the expected throughput when Action = Silent |
| 5: if
// the current time slot is the last time slot |
| 6:
|
| 7: else
|
| 8: Use Equation (9) to update ; use Equation (16) to update ; and use Equation (18) to calculate = , recursively. |
| 9: end if
|
| // Calculate the expected throughput when the CU stays in the state Active |
| 10: if
// the current time slot is the last. |
| 11: , . |
| 12: if
. |
| 13: set , use Equation (13) to calculate , and use Equation (15) to calculate . |
| 14: else
|
| 15: calculate recursively, use Equation (13) to calculate and use Equation (15) to calculate . |
| 16: end if
|
| 17: else
|
| 18: calculate and , recursively (use Equation (16) to update ); then combine with Equation (17) to calculate
|
| 19: if
set
|
| 20: else calculate recursively |
| 21: end if
|
| 22: use Equation (19) to decide the Action (Active or Silent), and calculate and
|
| 23: end if
|