Last change
on this file since 62 was 46, checked in by Rick van der Zwet, 15 years ago |
Report finished = sleep
|
-
Property svn:keywords
set to
Id
|
File size:
859 bytes
|
Rev | Line | |
---|
[28] | 1 | % Monte-Carlo Search Algoritm on low-autocorrelation program
|
---|
| 2 | % BSDLicence
|
---|
| 3 | % Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
|
---|
[42] | 4 | % $Id: mcs.m 46 2009-12-18 01:43:33Z rick $
|
---|
[28] | 5 |
|
---|
[30] | 6 | % Brute-force result of length 20
|
---|
| 7 | % best_20 = [-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,1,1,1];
|
---|
| 8 | % autocorrelation(best_20);
|
---|
| 9 |
|
---|
[46] | 10 | function [iteration_history,fitness_history] = mcs(length, iterations)
|
---|
| 11 | iteration_history = [];
|
---|
| 12 | fitness_history = [];
|
---|
| 13 |
|
---|
[42] | 14 | best_fitness = 0;
|
---|
[46] | 15 | for iteration = 1:iterations
|
---|
[42] | 16 | % Generate a random column s={-1,1}^n
|
---|
| 17 | n = length;
|
---|
| 18 | s = rand(n,1);
|
---|
| 19 | s = round(s);
|
---|
| 20 | s = s - (s == 0);
|
---|
| 21 |
|
---|
| 22 | % Find whether we are better than everything else
|
---|
| 23 | fitness = autocorrelation(s);
|
---|
| 24 | if (fitness > best_fitness)
|
---|
| 25 | best_value = s;
|
---|
| 26 | best_fitness = fitness;
|
---|
[38] | 27 | end
|
---|
[46] | 28 | iteration_history = [ iteration_history, iteration ];
|
---|
| 29 | fitness_history = [ fitness_history, best_fitness ];
|
---|
[42] | 30 | end
|
---|
[38] | 31 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.