-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunIsingExperiments.m
83 lines (66 loc) · 2.67 KB
/
RunIsingExperiments.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function[] = RunIsingExperiments()
global Isinglattice;
global Isinginter;
% Parameters of the Ising Model
InstanceNumber = 5;
MaxVal = 112;
n = 64;
[Isinglattice, Isinginter] = LoadIsing(n, InstanceNumber);
%%% Parameters of the EDA
% Cardinality of the variables
Card = 2*ones(1,n);
% Function to be optimized
F = 'EvalIsing';
PopSize = 500;
MaxGen = 20;
% Which information to keep for further analysis (ALL, see Help RunEDA for
% information about what is kept)
cache = [1,1,1,1,1];
% Parameters for the stop condition
stop_cond_params = {MaxGen,MaxVal};
edaparams{1} = {'stop_cond_method','maxgen_maxval',stop_cond_params};
%%% We will run different EDAs and compute the frequency with which they
%%% find the two symmetric solutions of Ising Model (Ising Instance 6)
%%% Solutions are: 1) All ones 2) All zeros
%%% We compare four different EDAs:
% Alg=1 : Tree-EDA
% Alg=2 : UMDA
% Alg=3 : Fixed chain-shaped model where P(X) = P(X1)*P(X2|X1)*P(X3|X2)*...* P(XN|XN-1)
% Alg=4 : Similar to previous model but higher order cliques
% : P(X) = P(X1X2)*P(X3|X1X2)*P(X4|X2X3)*...* P(XN|XN-1XN-2)
% Number of Experiments to be run
NRuns = 10;
for Alg=1:4,
for Exp=1:NRuns,
[Alg,Exp]
if(Alg==1)
edaparams{2} = {'learning_method','LearnTreeModel',{}}; % Tree-EDA
edaparams{3} = {'sampling_method','SampleFDA',{PopSize}};
elseif(Alg==2)
Cliques = CreateMarkovModel(n,0); % Zero-Order Model (UMDA)
edaparams{2} = {'learning_method','LearnFDA',{Cliques}};
edaparams{3} = {'sampling_method','SampleFDA',{PopSize}};
elseif(Alg==3)
Cliques = CreateMarkovModel(n,1); % First-Order Model
edaparams{2} = {'learning_method','LearnFDA',{Cliques}};
edaparams{3} = {'sampling_method','SampleFDA',{PopSize}};
elseif(Alg==4)
Cliques = CreateMarkovModel(n,2); % Second-Order Model
edaparams{2} = {'learning_method','LearnFDA',{Cliques}};
edaparams{3} = {'sampling_method','SampleFDA',{PopSize}};
end,
% The EDA is run
[AllStat,Cache]=RunEDA(PopSize,n,F,Card,cache,edaparams);
% AllOptima saves the Best solution found for analysis
% Any other relevant information can be extracted here from AllStat
% and Cache (see Help RunEDA for description of information
% contained in AllStat and Cache)
AllOptima{Alg,Exp} = AllStat{end,2};
end,
end,
% MatrixOptima saves the number of Ones in the optima learned by the EDAs
for Alg=1:4,
for Exp=1:NRuns,
MatrixOptima(Alg,Exp) = sum(AllOptima{Alg,Exp});
end
end