Home > Mateda2.0 > ScriptsMateda > OptimizationScripts > EBNA_PLS_MPC_NKRandom.m

EBNA_PLS_MPC_NKRandom

PURPOSE ^

EXAMPLE 16:

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 EXAMPLE 16:  
 Compares a Bayesian network based EDA that uses Probabilistic Logic Sampling
 with a Bayesian network based EDA that adds the Most Probable Configuration (i.e.
 the most probable individual from the net is added to the population
 during sampling) on a set of Number_Inst random instances of the NK circular
 model

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001  % EXAMPLE 16:
0002  % Compares a Bayesian network based EDA that uses Probabilistic Logic Sampling
0003  % with a Bayesian network based EDA that adds the Most Probable Configuration (i.e.
0004  % the most probable individual from the net is added to the population
0005  % during sampling) on a set of Number_Inst random instances of the NK circular
0006  % model
0007  
0008  
0009  n = 50; cache = [1,1,1,1,1]; Card = 2*ones(1,n); 
0010  global FunctionTables;
0011  global FunctionStructure;
0012  global FunctionAccCard;
0013  Number_Inst = 50;  k = 4;  nam = 'TestMPE';  NumberVar = 50;
0014  
0015  % First the structure of the NK function is generated
0016  [FunctionStructure] =  CreateListFactorsCircularNK(n,4); % The circular structure is created
0017  
0018  % The Number_Inst instaces  of the problem are created and saved on files
0019  % with prefix "nam" (see above).
0020  
0021  for i=1:Number_Inst,
0022   filename = [nam,num2str(i),'.txt'];   
0023   [Table] = CreateRandomFunctions(FunctionStructure,Card);
0024   SaveFunctionValues(filename,NumberVar,FunctionStructure,Table);
0025  end,
0026 
0027 % The function is the sum of the values for each definition set of NK circular function
0028 
0029 F = 'SumEvaluateGeneralFunction';  % General function that uses global variables FunctionTables, FunctionStructure and FunctionAccCard.
0030 MaxGen = 100; PopSize = 500; n = 50; cache = [1,1,1,1,1]; Card = 2*ones(1,n); 
0031 
0032 % The parameters of the Bayesian network based EDA are defined.
0033  stop_cond_params = {MaxGen};
0034  BN_params(1:6) = {'k2',10,0.05,'pearson','bic','no'};
0035  selparams(1:2) = {0.5,'ParetoRank_ordering'};
0036  edaparams{1} = {'selection_method','truncation_selection',selparams};
0037  edaparams{2} = {'replacement_method','best_elitism',{'ParetoRank_ordering'}};
0038  edaparams{3} = {'learning_method','LearnBN',BN_params};
0039  edaparams{4} = {'stop_cond_method','max_gen',stop_cond_params};
0040  
0041 %The initial population for each of the instances is fixed in order to
0042 %compare algorithms on a common ground.
0043 
0044 InitPop = fix(2*rand(Number_Inst*PopSize,n));
0045 nruns = 30;  % Number of runs
0046 
0047 % The Number_Inst*nruns*2 runs are executed within the following nested loops
0048 % and their results are saved in the file ResultsTest.mat
0049 
0050 for i=1:Number_Inst,
0051    edaparams{6} = {'seeding_pop_method','seed_thispop',{InitPop((i-1)*PopSize+1:i*PopSize,:)}};   
0052    filename = [nam,num2str(i),'.txt'];
0053   [FunctionTables] = ReadFunctionsFromData(filename,FunctionStructure,Card); % Values are read from a file
0054   [FunctionAccCard] = FindListCard(FunctionStructure,Card); % Auxiliary structure for function evaluation
0055  
0056   for j=1:2,
0057     if j==1
0058       edaparams{5} = {'sampling_method','SampleBN',{PopSize}};
0059     else
0060       edaparams{5} = {'sampling_method',' SampleMPE_BN',{PopSize}};
0061     end
0062     for k=1:nruns,
0063      [i,j,k] % To show the current run
0064      [AllStat,Cache]=RunEDA(PopSize,n,F,Card,cache,edaparams);
0065      ResultsTestsAllStat{i,j,k} = AllStat;
0066      ResultsTestsCache{i,j,k} = AllStat;
0067      save ResultsTest.mat InitPop ResultsTestsAllStat ResultsTestsCache
0068     end
0069   end, 
0070 end

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003