Skip to main content
. 2016 Mar 31;16(4):461. doi: 10.3390/s16040461
Algorithm 1: The pseudocode of the proposed algorithm for finding the expected throughput EKn(n0,S,μ,eKtotal), the optimal transmission energy eopttr(n) and the action for channel n.
Notations:
K denotes the number of slots for calculating the channel sensing order.
S1,2,,N denotes the set of sensed channels, which are arranged in sensed order.
S^ denotes the set of not yet sensed channels.
eKtotal denotes the packets of energy in the battery at the beginning of each time slot.
eSS and eCS denote the energy packets consuming for sensing per channel and channel switching per step, respectively.
Input: K,n,n0,S,μK,eKtotal; Output: Action (Active or Silent), EKn(n0,S,μK,eKtotal) and eopttr(n).
1: S=Sn; S^=1,2,,N\S; use Equation (4) to calculate θ(.) for each channel.
2: if eKtotal<eSS+eCS // Remaining energy is not enough for sensing channel n
3:  Action = Silent, EKn(n0,S,μK,eKtotal)=0, eopttr(n)=0
4: else
// Calculate the expected throughput when Action = Silent
5:  if K=1 // the current time slot is the last time slot
6:   EsK(n0,S,μK,eKtotal)=0
7:  else
8:   Use Equation (9) to update μK-1; use Equation (16) to update eK-1total; and use Equation (18) to calculate EsK(n0,S,μ,eKtotal)= EK-1(n0,S=,μK-1,eK-1total), recursively.
9:  end if
// Calculate the expected throughput when the CU stays in the state Active
10:  if K=1 // the current time slot is the last.
11:   EK-1(n0=n,S=,μK-1f,eK-1total)=0, EK-1(n0=n,S=,μK-1b,eK-1total)=0.
12:   if S^= .
13:    set EK(n0,Sn,μKb,eKtotal)=0, use Equation (13) to calculate eopttr(n), and use Equation (15) to calculate EaKn(n0,S,μK,eKtotal).
14:   else
15:    calculate EK(n0,Sn,μKb,eKtotal) recursively, use Equation (13) to calculate eopttr(n) and use Equation (15) to calculate EaKn(n0,S,μK,eKtotal).
16:   end if
17:  else
18:   calculate EK-1(n0=n,S=,μK-1f,eK-1total) and EK-1(n0=n,S=,μK-1b,eK-1total), recursively (use Equation (16) to update eK-1total); then combine with Equation (17) to calculate eopttr(n)
19:   if S^= set EK(n0,Sn,μKb,eKtotal=0
20:   else calculate EK(n0,Sn,μKb,eKtotal) recursively
21:   end if
22:   use Equation (19) to decide the Action (Active or Silent), and calculate EKn(n0,S,μK,eKtotal) and eopttr(n)
23: end if