Changeset 2442

Show
Ignore:
Timestamp:
09/30/09 16:28:40 (6 months ago)
Author:
wark
Message:

Added calculation of num desc for binary tree

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • HydroWatch/Tim/matlab/testadapt2.m

    r2437 r2442  
    107107    sys.Tdata = 1*24*3600; 
    108108    sys.TreportCurrent  = user.Treportmin; 
    109      
     109 
     110    % Details around the actual nodes 
     111    % Need to put in details of node children here (assume binary tree 
     112    % currently) 
     113    sys.Nlevel = 2; 
     114    sys.nodehop = [1, 2]; 
     115     
     116 
     117    %%%%%%%%%%%%%%%%%%% 
    110118    % Now read in the specified range of historical data 
    111119    env.Edailyharvest = parseData(data); 
     
    180188    Eharvest = []; 
    181189 
    182     % Number of nodes 
    183     Nnode = 1 
     190    % Sort fixed params for the nodes 
     191    for n=1:length(sys.nodehop) 
     192 
     193        % Get the number of descendants for this node 
     194        % (currently just assuming this is a binary tree) 
     195        sys.numDesc(n) = 2^(sys.Nlevel - sys.nodehop(n) + 1) - 2; 
     196 
     197        % Now calculate the forwarding and gamma(n) parameters which will 
     198        % feed into the optimization 
     199        % assume bin tree 
     200        sys.gamma(n) =  sys.numDesc(n);  
     201 
     202    end 
     203 
    184204     
    185205    % Now loop through the various intervals/days 
     
    201221        % Init just have the additional Elr + Ehr (minus gaurd times) 
    202222 
    203         % TODO: Have an additional loop in here for the nodes 
    204         for n=1:Nnode  
    205          
    206             % Calculate the appropriate min and target 
    207             % energy for start of NEXT day interval 
    208             % as we set parameters for current interval to be  
    209             % bound by this.  
    210             sys.Emin(k+1) = sys.Emin(k) - Ec_min;    
    211             sys.Etarget(k+1) = sys.Etarget(k) - (sys.Etarget(k) / (user.L - k + 1));  
    212  
    213             % Calculate the various system variables 
    214             % 1. Interval when to send back latest batch of high-res data 
    215             sys = BestDataSendInterval(user, sys, env); 
    216             % 2. Get Tsamp 
    217             sys = Eoptimize(user, sys, env); 
    218  
    219             % Update the number of buffered samples given the newly 
    220             % calculated sample rate for this interval (includes the 
    221             % samples for this interval) 
    222             sys = getNumBufferedSamples(sys, user, k); 
    223       
    224             % Now calculate the consumed energy for the various parameters 
    225             % determined by the optmization for this interval 
    226             % (In the real deployment case iCount could be used here) 
    227             Ec = Econsump(user, sys); 
    228  
    229             % Now get the actual energy that will remain at start of next interval 
    230             sys.Ea(k+1) = sys.Ea(k) - Ec + Eharvest; 
    231  
    232         end    
     223                   
     224        % Calculate the appropriate min and target 
     225        % energy for start of NEXT day interval 
     226        % as we set parameters for current interval to be  
     227        % bound by this.  
     228        sys.Emin(k+1) = sys.Emin(k) - Ec_min;    
     229        sys.Etarget(k+1) = sys.Etarget(k) - (sys.Etarget(k) / (user.L - k + 1));  
     230 
     231        % Calculate the various system variables 
     232        % 1. Interval when to send back latest batch of high-res data 
     233        sys = BestDataSendInterval(user, sys, env); 
     234        % 2. Get Tsamp 
     235        sys = Eoptimize(user, sys, env); 
     236 
     237        % Update the number of buffered samples given the newly 
     238        % calculated sample rate for this interval (includes the 
     239        % samples for this interval) 
     240        sys = getNumBufferedSamples(sys, user, k); 
     241  
     242        % Now calculate the consumed energy for the various parameters 
     243        % determined by the optmization for this interval 
     244        % (In the real deployment case iCount could be used here) 
     245        Ec = Econsump(user, sys); 
     246 
     247        % Now get the actual energy that will remain at start of next interval 
     248        sys.Ea(k+1) = sys.Ea(k) - Ec + Eharvest; 
    233249 
    234250    end