[28] | 1 | % Monte-Carlo Search Algoritm on low-autocorrelation program
|
---|
| 2 | % BSDLicence
|
---|
| 3 | % Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>
|
---|
| 4 |
|
---|
[30] | 5 | % Brute-force result of length 20
|
---|
| 6 | % best_20 = [-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,1,1,1];
|
---|
| 7 |
|
---|
[31] | 8 | % Basic variables
|
---|
| 9 | iterations = [1:10:200];
|
---|
| 10 | repetitions = 20;
|
---|
| 11 | length = 20;
|
---|
[28] | 12 |
|
---|
[31] | 13 | % Plot the stuff
|
---|
| 14 | fitnesses = [];
|
---|
| 15 | for iteration = iterations
|
---|
| 16 | fitness = [];
|
---|
| 17 | for rep = 1:repetitions
|
---|
[38] | 18 | fprintf('Iter:%i, Rep:%i\n',iteration,rep);
|
---|
[31] | 19 | [new_fitness, value] = mcs(length,iteration);
|
---|
| 20 | fitness = [fitness, new_fitness];
|
---|
| 21 |
|
---|
[28] | 22 | % Little hack to display output nicely
|
---|
[31] | 23 | % disp(rot90(value,-1));
|
---|
[38] | 24 | end
|
---|
[31] | 25 | fitnesses = [fitnesses,mean(fitness)];
|
---|
[38] | 26 | end
|
---|
[28] | 27 |
|
---|
[31] | 28 | plot(iterations,fitnesses);
|
---|
| 29 | title(sprintf('Monte-Carlo Search on Low-Corretation set - repetitions %i',repetitions));
|
---|
| 30 | ylabel('fitness');
|
---|
| 31 | xlabel('iterations');
|
---|
| 32 | grid on;
|
---|
| 33 | legend(sprintf('Length %i',length));
|
---|
[38] | 34 | print('mcs-fitness.eps','-depsc2');
|
---|
[31] | 35 |
|
---|