function [dlen,cnt] = rateSearch(resposition,target,yposition,resAdjust) %% =========================================================================== % Copyright (C): % 2002-2009 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Description : ETSI VDSL performance simulations % % Project : B1, FTW % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % % Reference: % % CVS: $Id: rateSearch.m 752 2009-01-02 13:03:52Z tono $ %% =========================================================================== %% =========================================================================== % Change History % 2002-06-14 (ToNo) Created as a seperate search function % 2003-11-03 (ToNo) Lists now use cell arrays for both Octave and Matlab %% =========================================================================== global ex; DEBUG=0; if nargin<3, error('Not enough input arguments.'); end if nargin<4, yposition = 2; end if nargin<5, DoAdjustForNID = 0; DoAdjustForMN = 0; else DoAdjustForNID = resAdjust.DoAdjustForNID; DoAdjustForMN = resAdjust.DoAdjustForMN; end ds_target = target.ds; us_target = target.us; %% ======================================================================== % Prepare the search, by setting a lower and upper bound on the reach value minlen=2; %% ======================================================================== % Prepare the search for reach, by setting a lower and upper bound % on the reach. %%%% Get first bitrate at a minimum distance xlen=minlen; ex.tt.topology{yposition}{1}=xlen; result = evalExperiment; % Adjust for VDSL performance tests if DoAdjustForNID, AdjustForNID; end; % Adjust for noise inject.dev. if DoAdjustForMN, AdjustForMN; end; % Floor for modem noise [bitrate_LT, bitrate_NT, margin_LT, margin_NT] = calcXDSLresult(ex,result); low_rate_ds=bitrate_NT(resposition); % XXX/rsoh-framingoh low_rate_us=bitrate_LT(resposition); % XXX/rsoh-framingoh cnt=1; low_xlen_ds=xlen; low_xlen_us=xlen; if DEBUG, fprintf('\n'); end; xlen=1500; high_xlen_ds=xlen-1; high_xlen_us=xlen-1; high_rate_ds=low_rate_ds-1; high_rate_us=low_rate_us-1; %%% Now get the upper bound (if first bitrate is valid). Focus on DS direction if (low_rate_ds < ds_target) || (low_rate_us < us_target) quitloop=1; else quitloop=0; contsearch=1; while contsearch ex.tt.topology{yposition}{1}=xlen; result = evalExperiment; % Adjust for VDSL performance tests if DoAdjustForNID, AdjustForNID; end; % Adjust for noise inject.dev. if DoAdjustForMN, AdjustForMN; end; % Floor for modem noise [bitrate_LT, bitrate_NT, margin_LT, margin_NT] = calcXDSLresult(ex,result); if DEBUG, fprintf('Itr #%d (%.0f m) -- Rate:(US=>%.2f,DS=>%.2f), Margin:(%.3f,%.3f)\n',... cnt,xlen,bitrate_LT, bitrate_NT, margin_LT, margin_NT); end; high_rate_ds=bitrate_NT(resposition); % XXX/rsoh-framingoh high_rate_us=bitrate_LT(resposition); % XXX/rsoh-framingoh cnt=cnt+1; if high_rate_ds<=0, % To far out -- no bitrate at all xlen = low_xlen_ds + (xlen-low_xlen_ds)/2; elseif (high_rate_ds < ds_target) % A useful distance outside reach contsearch=0; high_xlen_ds=xlen; else % Still above target bitrate aim higher and move minimum distance lenrate=(low_xlen_ds-xlen)/(low_rate_ds-high_rate_ds); low_rate_ds=high_rate_ds; low_xlen_ds=xlen; xlen=low_xlen_ds + lenrate*(ds_target-high_rate_ds) + 100; end; if DEBUG, fprintf('Itr #%d-- Pre, DS High:(%.1f,%.1f),Low:(%.1f,%.1f)\n\n',... cnt,high_xlen_ds,high_rate_ds*1e3,low_xlen_ds,low_rate_ds*1e3); end; end; end; %% ======================================================================== % Now search for the DS reach, between upper and lower bound, % downto a 1m accuracy. xlen=low_xlen_ds + (high_xlen_ds-low_xlen_ds)/2; while ~quitloop cnt=cnt+1; ex.tt.topology{yposition}{1}=xlen; result = evalExperiment; % Adjust for VDSL performance tests if DoAdjustForNID, AdjustForNID; end; % Adjust for noise inject.dev. if DoAdjustForMN, AdjustForMN; end; % Floor for modem noise [bitrate_LT, bitrate_NT, margin_LT, margin_NT] = calcXDSLresult(ex,result); if DEBUG, fprintf('Itr #%d (%.0f m) -- Rate:(%.2f,%.2f), Margin:(%.3f,%.3f)\n',... cnt,xlen,bitrate_LT, bitrate_NT, margin_LT, margin_NT); end; new_rate_ds=bitrate_NT(resposition); % XXX/rsoh-framingoh new_rate_us=bitrate_LT(resposition); % XXX/rsoh-framingoh if new_rate_ds>ds_target, low_rate_ds=new_rate_ds; low_xlen_ds=xlen; else high_rate_ds=new_rate_ds; high_rate_us=new_rate_us; high_xlen_ds=xlen; high_xlen_us=xlen; end; xlen=low_xlen_ds + (high_xlen_ds-low_xlen_ds)/2; if high_xlen_ds-xlen < 0.5, quitloop=1; end; if DEBUG, fprintf('Itr #%d -- DS High:(%.1f,%.1f),Low:(%.1f,%.1f)\n\n',... cnt,high_xlen_ds,high_rate_ds*1e3,low_xlen_ds,low_rate_ds*1e3); end; end %while ds_xlen=low_xlen_ds; %% ======================================================================== % Search for the US reach (if needed) if ds_xlen us_target) % Print result if US is OK and DS is determining the reach %fprintf('Loop %d, Len=%.0fm, IL = %.1fdB (@300kHz), DS\n',... % loopno,ds_xlen+offsetlen(loopno),... % VDSLIL(loopno,f_T,ds_xlen+offsetlen(loopno))); dlen = ds_xlen; else % Search US reach (between starting reach and DS reach) xlen=low_xlen_us + (high_xlen_us-low_xlen_us)/2; quitloop=0; while ~quitloop cnt=cnt+1; ex.tt.topology{yposition}{1}=xlen; % Adjust for VDSL performance tests if DoAdjustForNID, AdjustForNID; end; % Adjust for noise inject.dev. if DoAdjustForMN, AdjustForMN; end; % Floor for modem noise result = evalExperiment; [bitrate_LT, bitrate_NT, margin_LT, margin_NT] = calcXDSLresult(ex,result); if DEBUG, fprintf('Itr #%d (%.0f m) -- Rate:(%.2f,%.2f), Margin:(%.3f,%.3f)\n',... cnt,xlen,bitrate_LT, bitrate_NT, margin_LT, margin_NT); end; new_rate_ds=bitrate_NT(resposition); % XXX/rsoh-framingoh new_rate_us=bitrate_LT(resposition); % XXX/rsoh-framingoh if new_rate_us>us_target, low_rate_us=new_rate_us; low_xlen_us=xlen; else high_rate_ds=new_rate_ds; high_rate_us=new_rate_us; high_xlen_ds=xlen; high_xlen_us=xlen; end; xlen=low_xlen_us + (high_xlen_us-low_xlen_us)/2; if high_xlen_us-xlen < 0.5, quitloop=1; end; if DEBUG, fprintf('Itr #%d -- US High:(%.1f,%.1f),Low:(%.1f,%.1f)\n',... cnt,high_xlen_us,high_rate_us*1e3,low_xlen_us,low_rate_us*1e3); end; end %while us_xlen=low_xlen_us; dlen = us_xlen; end;