The Geometric Water-Filling (GWF) algorithm has two advantages over the Conventional Water -Filling (CWF) approach; it can compute the exact solution with less computation without determining the water level and it can handle more constraints. The target problem has a fundamental form of RRA problem as
The problem needed to be solved has two constraints: the first constraint tells us that the power allocated for each channel must be non-negative. The second constraint states that the sum of all the allocated power must equal to the total power.
To explain the procedure of the GWF algorithm, an example from the published paper can be used; Fig.1 shows a problem with 4 stairs/steps.
This algorithm can be extended to weighted cases as well; this is further shown in the paper, but the methodology remains the same.
The proposed algorithm can be written in MATLAB to view the results. From the code below, it is evident that the steps taken are as described above.
*Note: To run this function, the input parameters (power, gain and weight) must be inputted to the GWF function and the function must be assigned to and array of output parameters (water_level, index, value, si and height) to receive an output.
function [water_level,index,value,si,height] = GWF(power,gain,weight)
power=power; %Assign total power
count=0;
a=sort(gain,'descend');
w=weight
[height,ind]=sort(1./(w.*a));
weight=weight(ind);
original_size=length(a); %size of gain array, i.e total # of channels.
channel=length(a);
isdone=false;
while isdone==false
Ptest=0; %Ptest is total 'empty space' under highest channel under water.
for i= 1:(channel-1)
Ptest=Ptest + (height(channel)-height(i))*weight(i);
end
if (power-Ptest)>0 || (power-Ptest)==0 %If power is greater than Ptest, index(or k*) is equal to channel.
index=channel; %Otherwise decrement channel and run while loop again.
break;
end
channel=channel-1;
end
value=power-Ptest; %'value' is P2(k*).
water_level=value/sum(weight(1:(index))) + height(index);
si=(water_level - height).*weight;
si(si(:)<0)=[0];
end
A user friendly script has also been developed which makes visualizing the output easier. This file (called GWF_call.m) can be accessed here along with the GWF algorithm file.
Using the aforementioned example in the algorithm section, the GWF_Call file can be used to generate the optimal solution along with a figure of the output. Assuming a total power of 6 units, the simulation can be ran to output the optimal power allocation