Changeset 42 for liacs/nc


Ignore:
Timestamp:
Dec 17, 2009, 10:18:08 PM (15 years ago)
Author:
Rick van der Zwet
Message:

Make files look pretty and neat on display

Location:
liacs/nc/low-correlation
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • liacs/nc/low-correlation/Makefile

    r31 r42  
    22CFLAGS=-lm
    33
     4SOURCE=autocorrelation.m.tex initseq.m.tex  mcs-call.m.tex \
     5       mcs.m.tex  mutation.m.tex  randint.m.tex  sa-call.m.tex  sa.m.tex
     6
     7include latex.mk
     8
    49mcs: mcs.m
    510        @octave --silent mcs.m
     11
     12
     13%.m.tex: %.m
     14        highlight --linenumbers --no-doc --latex --input $< --output $@
  • liacs/nc/low-correlation/initseq.m

    • Property svn:keywords set to autocorrelation.m
    r38 r42  
    22% BSDLicence
    33% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
     4% $Id$
    45
    56function s = initseq(n)
    6     % Generate a random column s={-1,1}^n
    7     s = rand(n,1);
    8     s = round(s);
    9     s = s - (s == 0);
     7  % Generate a random column s={-1,1}^n
     8  s = rand(n,1);
     9  s = round(s);
     10  s = s - (s == 0);
    1011end
  • liacs/nc/low-correlation/mcs-call.m

    • Property svn:keywords set to autocorrelation.m
    r38 r42  
    22% BSDLicence
    33% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
     4% $Id$
    45
    56% Brute-force result of length 20
     
    1415fitnesses = [];
    1516for iteration = iterations
    16     fitness = [];
    17     for rep = 1:repetitions
    18         fprintf('Iter:%i, Rep:%i\n',iteration,rep);
    19         [new_fitness, value] =  mcs(length,iteration);
    20         fitness = [fitness, new_fitness];
     17  fitness = [];
     18  for rep = 1:repetitions
     19    fprintf('Iter:%i, Rep:%i\n',iteration,rep);
     20    [new_fitness, value] =  mcs(length,iteration);
     21    fitness = [fitness, new_fitness];
    2122
    22         % Little hack to display output nicely
    23         % disp(rot90(value,-1));
    24     end
    25     fitnesses = [fitnesses,mean(fitness)];
     23    % Little hack to display output nicely
     24    % disp(rot90(value,-1));
     25  end
     26  fitnesses = [fitnesses,mean(fitness)];
    2627end
    2728
  • liacs/nc/low-correlation/mcs.m

    • Property svn:keywords set to autocorrelation.m
    r38 r42  
    22% BSDLicence
    33% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
     4% $Id$
    45
    56% Brute-force result of length 20
     
    89
    910function [fitness,value] = mcs(length, iterations)
    10     best_fitness = 0;
    11     for i = 1:iterations
    12         % Generate a random column s={-1,1}^n
    13         n = length;
    14         s = rand(n,1);
    15         s = round(s);
    16         s = s - (s == 0);
    17    
    18         % Find whether we are better than everything else
    19         fitness = autocorrelation(s);
    20         if (fitness > best_fitness)
    21             best_value = s;
    22             best_fitness = fitness;
    23         end
     11  best_fitness = 0;
     12  for i = 1:iterations
     13    % Generate a random column s={-1,1}^n
     14    n = length;
     15    s = rand(n,1);
     16    s = round(s);
     17    s = s - (s == 0);
     18 
     19    % Find whether we are better than everything else
     20    fitness = autocorrelation(s);
     21    if (fitness > best_fitness)
     22      best_value = s;
     23      best_fitness = fitness;
    2424    end
    25     fitness = best_fitness;
    26     value = best_value;
     25  end
     26  fitness = best_fitness;
     27  value = best_value;
    2728end
  • liacs/nc/low-correlation/mutation.m

    • Property svn:keywords set to autocorrelation.m
    r38 r42  
    22% BSDLicence
    33% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
     4% $Id$
    45
    56function new = mutation(old)
    6     loc = randint(1,length(old));
    7     old(loc) = old(loc) * -1;
    8     new = old;
     7  loc = randint(1,length(old));
     8  old(loc) = old(loc) * -1;
     9  new = old;
    910end
  • liacs/nc/low-correlation/randint.m

    • Property svn:keywords set to autocorrelation.m
    r38 r42  
    22% BSDLicence
    33% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
     4% $Id$
    45
    56function number = randint(low,high)
    6     number = round(rand() * (high - low)) + low;
     7  number = round(rand() * (high - low)) + low;
    78end
  • liacs/nc/low-correlation/sa-call.m

    • Property svn:keywords set to autocorrelation.m
    r39 r42  
    22% BSDLicence
    33% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
     4% $Id$
    45
    56%% Basic variables
  • liacs/nc/low-correlation/sa.m

    • Property svn:keywords set to autocorrelation.m
Note: See TracChangeset for help on using the changeset viewer.