Skip to main content
. 2026 Jan 20;26(2):684. doi: 10.3390/s26020684
Algorithm 1: RL-Based Routing with Entropy & Gini Reward
Input: Current Node ni , Neighbor Set Ni
Output: Next Hop nnext
1:  Observe State St=Eres,Distsink,Qlen //
2: // Action Selection (Epsilon-Greedy)
3:  IF random()<ε  THEN Select random nnext  form Ni
4:  ELSE nnext=argmaxnjQSt,nj
5:  Forward Packet to nnext  and Observe St+1
6: // Reward Calculation (Core Innovation)
7:  Compute Rprogress and Renergy using Equations (23) and (24)
8:  Compute Requilibrium based on Entropy Equation (27) & Gini Equation (28)
9:  Rtotal=w1Rprogress+w2Renergy+w3Requilibrium
10: // Update Q-Value
11:  Q(St,nnext)=(1α)Q(St,nnext)+α(Rtotal+γmax(Q(St+1)))