% Simulated Annealing low-autocorrelation program
% BSDLicence
% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>

%% Basic variables
iterations = [1:10:1000];
repetitions = 20;
length = 20;
temperature = 1000;

iteration_history = [];
fitness_history = [];

% Plot the stuff
for iteration = iterations
    fitness = [];
    for rep = 1:repetitions
        fprintf('Iter:%i, Rep:%i\n',iteration,rep);
        [new_fitness, value] =  sa(length,iteration,temperature);
        fitness = [fitness, new_fitness];

        % Little hack to display output nicely
        % disp(rot90(value,-1));
   end
    iteration_history = [iteration_history,iteration];
    fitness_history = [fitness_history,mean(fitness)];
end

plot(iteration_history,fitness_history);
title(sprintf('Simulated Annealing on Low-Corretation set - repetitions %i',repetitions));
ylabel('fitness');
xlabel('iterations');
grid on;
legend(sprintf('Length %i',length));
print('sa-fitness.eps','-depsc2');

