Home > Mateda2.0 > ScriptsMateda > FitnessModScripts > BN_MPCsFitness.m

BN_MPCsFitness

PURPOSE ^

EXAMPLE 5:

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 EXAMPLE 5:  
 An EDA based on Bayesian networks is used for the solution of the evalfuncntrap function
 The algorithm stops after a maxgen number of generations is reached.
 The fitness values of the most probable explanations the computation of the probabilities given by the model to
 the best solutions found by the algorithm are computed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001  % EXAMPLE 5:
0002  % An EDA based on Bayesian networks is used for the solution of the evalfuncntrap function
0003  % The algorithm stops after a maxgen number of generations is reached.
0004  % The fitness values of the most probable explanations the computation of the probabilities given by the model to
0005  % the best solutions found by the algorithm are computed.
0006  
0007  
0008   PopSize = 500; n = 30; cache  = [1,1,1,1,1]; Card = 2*ones(1,n); maxgen = 10;
0009   F = 'evalfunctrapn'; % Trap function of parameter k=5;
0010   global ntrapparam;
0011   ntrapparam = 5;           % The parameter of the function is passed as a global variable
0012   
0013  edaparams{1} = {'replacement_method','elitism',{10,'fitness_ordering'}};
0014  selparams(1:2) = {0.3,'ParetoRank_ordering'};
0015  edaparams{2} = {'selection_method','truncation_selection',selparams};
0016  BN_params(1:6) = {'k2',10,0.05,'pearson','bayesian','no'};
0017  edaparams{3} = {'learning_method','LearnBN',BN_params};
0018  edaparams{4} = {'stop_cond_method','max_gen',{maxgen}};
0019  [AllStat,Cache]=RunEDA(PopSize,n,F,Card,cache,edaparams)
0020   
0021   
0022  for i=1:maxgen
0023    bnets{i}=Cache{3,i};            % The Bayesian networks are extracted from the Cache
0024  end
0025  [MPEs] = Most_probable_explanations(bnets, F); % Most probable explanations are found
0026 
0027  % The most probable explanation given by the Bayesian network in
0028  % each generation is computed and the function values at each generation for the most probable
0029  % explanations are plotted.
0030  
0031  for i=1:maxgen
0032    fo_mpes(i)=MPEs{3,i};           % The fitness values of the most probable explanations are displayed
0033  end
0034  X=[1:maxgen];
0035  plot(X,fo_mpes);
0036 
0037  %%%  The best point reached by the algorithm is found and the probabilities given by the models
0038  %%%  to this point are computed and ploted
0039 
0040  optimal_point = AllStat{maxgen,2};  %The best point reached by the algorithm is found
0041  [P] = Probability_monitor(bnets, optimal_point); % The probabilities given by the models to this point are computed.
0042                                                   % and ploted
0043  figure 
0044  plot(X,P);
0045

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