% /*M-FILE SCRIPT SwarmFF_demo_MO_NSGAII MMM SwarmsLAB */ %
% /*==================================================================================================
% Swarm Optimisation and Algorithm Laboratory Toolbox for MATLAB
%
% Copyright 2012 The SxLAB Family - Yi Chen - leo.chen.yi@live.co.uk
% ====================================================================================================
% File description:
%
% options(7)-- Pareto ranking method
% 'Goldberg','G' -- Goldberg's method: rank = rank + 1;
% 'Fonceca','Fleming','MO','F' -- Fonceca and Fleming's ranking method
% current rank = the number of its dominating individulas + 1
%
%Appendix comments:
%
%Usage:
%
%===================================================================================================
% See Also:
%
%===================================================================================================
%===================================================================================================
%Revision -
%Date Name Description of Change email
%31-Jul-2012 Chen Yi Initial version leo.chen.yi@live.co.uk
%HISTORY$
%==================================================================================================*/
%==================================================================================================*/
% SwarmFF_demo_MO_NSGAII Begin
% fresh
clear ;
close ('all');
warning off
% to delete old output_*.txt
!del SwarmFF_O_*.*
% set working path
% begin to count time during calculating
home ;
tic % timer start >>
% data preparation
% open data files
%%%input data files
fid1 = fopen('SwarmFF_I_min_confines.txt' , 'r' );
fid2 = fopen('SwarmFF_I_max_confines.txt' , 'r' );
fid3 = fopen('SwarmFF_I_randomness.txt' , 'r' );
% fid4 = fopen('SwarmFF_I_original_attractiveness.txt' , 'r' );
fid5 = fopen('SwarmFF_I_population.txt' , 'r' );
% fid6 = fopen('SwarmFF_I_steps.txt' , 'r' );
fid7 = fopen('SwarmFF_I_max_generation.txt' , 'r' );
fid8 = fopen('SwarmFF_I_absorption_coefficient.txt' , 'r' );
% fid9 = fopen('INPUT_max_no_change_probability_crossover_generation.txt','r');
% fid10 = fopen('INPUT_deta_fitness_max.txt','r');
% fid11 = fopen('INPUT_max_probability_crossover.txt','r');
% fid12 = fopen('INPUT_probability_crossover_step.txt','r');
% fid13 = fopen('INPUT_max_no_change_fitness_generation.txt','r');
% fid22 = fopen('INPUT_tournament_size.txt','r');
fid20= fopen('SwarmFF_I_randomness_reduction.txt','r');
% set total test number
fid1000= fopen('SwarmFF_I_testnumber.txt','r');
%output data files
fid120 = fopen('SwarmFF_O_bestfitness.txt','a+');
fid130 = fopen('SwarmFF_O_maxfitness.txt','a+');
fid140 = fopen('SwarmFF_O_minfitness.txt','a+');
fid150 = fopen('SwarmFF_O_meanfitness.txt','a+');
fid160 = fopen('SwarmFF_O_best_result_space.txt','a+');
% fid19 = fopen('OUTPUT_best_coding_space.txt','w+');
% fid20 = fopen('OUTPUT_now_generation.txt','w+');
% fid21 = fopen('OUTPUT_now_probability_crossover.txt','w+');
% begin to load data from file
% read data from these files
disp('/*==================================================================================================*/')
disp('/* Swarm Optimisation and Algorithm Laboratory Toolbox 1.0.0.1 */ ')
disp('');
disp(' 28-Jun-2013 Chen Yi leo.chen.yi@live.co.uk Glasgow ')
disp('/*==================================================================================================*/')
disp('>>>>')
disp(' Begin to evaluate...Waiting please ...');
min_confines = fscanf( fid1 , '%g' ); min_confines = min_confines' ;
max_confines = fscanf( fid2 , '%g' ); max_confines = max_confines';
%
alpha = fscanf( fid3 , '%g' );
%probability_mutation = fscanf(fid4,'%g');
%
population = fscanf( fid5 , '%g' );
%
% step = fscanf( fid6 , '%g' );
%
max_generation = fscanf( fid7 , '%g' );
% %
% brightness0 = fscanf( fid3 , '%g' );
% %
% attractiveness0 = fscanf( fid4 , '%g' );
%
gamma = fscanf( fid8 , '%g' );
%
% max_probability_crossover = fscanf( fid11,'%g' );
%
% probability_crossover_step = fscanf(fid12,'%g');
%
% max_no_change_fitness_generation = fscanf(fid13,'%g');
%
%
% now_probability_crossover = probability_crossover;
%
delta = fscanf(fid20,'%g');
% %
testnumber = fscanf(fid1000,'%g');
disp(' the total test number is');
disp(testnumber);
% Step into SGALAB()
%
eachtimeplot = 0; % plot each test time
statisticalplot = [1,1,1,1,1,0];
%statisticalplot(1) - plot MIN,MEAN,MAX or not, 0-NO, 1-YES
%statisticalplot(2) - plot mAP or not, 0-NO, 1-YES
%statisticalplot(3) - plot mSTD or not, 0-NO, 1-YES
%statisticalplot(4) - plot mmAP or not, 0-NO, 1-YES
%statisticalplot(5) - plot mmSTD or not, 0-NO, 1-YES
%statisticalplot(6) - plot fitness of all test, 0-NO, 1-YES
% delta = SGA__cell2str(options(1));
% attractiveness0 = SGA__cell2str(options(2));
% brightness0 = SGA__cell2str(options(3));
% gamma = SGA__cell2str(options(4));
% eachtimeplot = SGA__cell2str(options(5));
% statisticalplot = SGA__cell2str(options(6));
%delta=0.9 to 0.99 will be a good choice.
options = { ...
delta, % 1, randomness reduction, for alpha updates
alpha, % 2, alpha
'NSGAII', % 3, Multi-objective algorithm types
gamma, % 4, absorption coefficient, 1.0
eachtimeplot, % 5, plot each test, 1 - plot each time, 0 - no plots
statisticalplot, % 6, statistical plots, 1 - yes , 0 - no plots
'Goldberg', % 7, ranking method, Goldberg, Fleming}
'1' }; % 8, '1', -- Save; Pareto front neet this; '0' -- not save
SwarmFF_Procedure_h = timebar('SwarmsLAB::SwarmFirefly','Total Progress...');
for idx = 1 : 1 : testnumber
% Output
timebar( SwarmFF_Procedure_h , idx/testnumber );
disp('Test NO.'); disp(idx);
disp('');
[ fitness_data ,...
best_decimal_space ,...
error_status ]= SwarmFF__entry_MO_Pareto_NSGAII...
( options,...
min_confines ,...
max_confines ,...
population ,...
max_generation,...
[testnumber,idx] );
disp('');
if ( error_status ~= 0 ) return ; end
%write data to output files
% OUTPUT_bestfitness.txt
% fprintf( fid120 , '%f\n', fitness_data(1));
%
% % OUTPUT_maxfitness.txt
% fprintf( fid130 , '%f\n', fitness_data(2));
%
% % OUTPUT_minfitness.txt
% fprintf( fid140, '%f\n', fitness_data(3));
%
% % OUTPUT_meanfitness.txt
% fprintf( fid150, '%f\n', fitness_data(4));
% OUTPUT_best_result_space.txt
fprintf( fid160, '%f\n', best_decimal_space );
% % OUTPUT_best_coding_space
% fprintf( fid19 , '%f\n' , best_coding_space );
% % OUTPUT_now_generation.txt
% fprintf( fid20, '%f\n' , now_generation );
%
% % OUTPUT_now_probability_crossover.txt
% fprintf( fid21, '%f\n' , now_probability_crossover );
end
figure
SGA__pareto_replot_2D_NSGAII
saveas_filename = ['SwarmFF_Paretofront_NSGAII_2D'];
saveas(gcf,saveas_filename, 'fig');
saveas(gcf,saveas_filename, 'jpg');
saveas(gcf,saveas_filename, 'eps');
saveas(gcf,saveas_filename, 'pdf');
%close files
close( SwarmFF_Procedure_h );
status = fclose( 'all' );
disp('End SwarmFirefly Evaluating');
disp('');
disp(' More detail result in text files with " SwarmFF_O_*.txt " ' )
disp('----------------------------------------------------------------------------------------')
result_files = list_current_dir_files ('SwarmFF_O_*.*')
disp('----------------------------------------------------------------------------------------')
% timer end
toc
clear all
% SwarmFF_demo_MO_NSGAII End