Home > atmlab > gridcreation > annealing > loop_anneal.m

loop_anneal

PURPOSE ^

LOOP_ANNEAL Loop annealing algorithm until desired accuracy

SYNOPSIS ^

function R = loop_anneal(H, y_mono, n_start, n_incr, acc, C)

DESCRIPTION ^

 LOOP_ANNEAL Loop annealing algorithm until desired accuracy
 reached

 This is a higher level function, that uses the lower level
 function find_best_freq_set_anneal.

 It starts by calling find_best_freq_set_anneal with n_start
 frequencies and storing the result. Then it calles it over again
 with one frequency more, and so on until the desired accuracy is
 reached.

 FORMAT R = loop_anneal(H, y_mono, n_start, n_incr, acc, C)

 OUT R       An array of structures. Each structure has elements sb, Wb,
             eb, h, which correspond to the output arguments of
             find_best_freq_set_anneal.
 IN  n_start The starting number of frequencies. (You should take
             at least one per channel.)
     n_incr  By how much to increment n in each iteration.
     acc     The desired accuracy, at which the looping is
             stopped. This is the RMS error in the solution, as
             returned by find_best_freq_set_anneal in eb.
     H, y_mono, C  Parameters of find_best_freq_set_anneal.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

loop_anneal.m

SOURCE CODE ^

0001 % LOOP_ANNEAL Loop annealing algorithm until desired accuracy
0002 % reached
0003 %
0004 % This is a higher level function, that uses the lower level
0005 % function find_best_freq_set_anneal.
0006 %
0007 % It starts by calling find_best_freq_set_anneal with n_start
0008 % frequencies and storing the result. Then it calles it over again
0009 % with one frequency more, and so on until the desired accuracy is
0010 % reached.
0011 %
0012 % FORMAT R = loop_anneal(H, y_mono, n_start, n_incr, acc, C)
0013 %
0014 % OUT R       An array of structures. Each structure has elements sb, Wb,
0015 %             eb, h, which correspond to the output arguments of
0016 %             find_best_freq_set_anneal.
0017 % IN  n_start The starting number of frequencies. (You should take
0018 %             at least one per channel.)
0019 %     n_incr  By how much to increment n in each iteration.
0020 %     acc     The desired accuracy, at which the looping is
0021 %             stopped. This is the RMS error in the solution, as
0022 %             returned by find_best_freq_set_anneal in eb.
0023 %     H, y_mono, C  Parameters of find_best_freq_set_anneal.
0024 
0025 % 2008-09-25 Created by Stefan Buehler.
0026 
0027 function R = loop_anneal(H, y_mono, n_start, n_incr, acc, C)
0028 
0029 
0030 % Check input
0031 if nargin == 6
0032   % Control parameter C is provided! If C is not provided,
0033   % find_best_freq_set_anneal will use default values
0034   %
0035   % Set values
0036   % Set verbosity of find_best_freq_set_anneal to 0:
0037   C.verb = 1;
0038 end
0039 
0040 disp('****************************************')
0041 disp(sprintf('Starting with n = %d.', n_start))
0042 
0043 go_on = true;
0044 i = 1;
0045 n = n_start;
0046 while go_on
0047   
0048    if nargin == 6
0049      % Control parameter C is provided!
0050      [sb, Wb, eb, h] = find_best_freq_set_anneal(H,...
0051                                                  y_mono,...
0052                                                  n,...
0053                                                  C);
0054    else 
0055      [sb, Wb, eb, h] = find_best_freq_set_anneal(H,...
0056                                               y_mono,...
0057                                               n);
0058    end
0059    
0060   R(i).sb = sb;
0061   R(i).Wb = Wb;
0062   R(i).eb = eb;
0063   R(i).h  = h;
0064   
0065   disp('****************************************')
0066 
0067   if nargin == 6
0068      % Control parameter C is provided!
0069      if (C.use_rel_error)
0070        disp(sprintf('n = %d, acc = %g [fractional]', n, eb))
0071      else
0072        disp(sprintf('n = %d, acc = %g K', n, eb))
0073      end
0074    end
0075 
0076   if eb<=acc
0077     go_on = false;
0078   else
0079     i = i+1;
0080     n = n+n_incr;
0081   end
0082 end
0083

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005