📄 demo_ga_minbool.m
字号:
%% Synthesis of boolean automata using the methodology proposed in
% A. Popov, Kr. Filipova, "Genetic Algorithms - synthesis of finite state
% machines", 27th International Spring Seminar on Electronics Technology.
% IEEE Proc., Catalog N 04EX830, ISBN 0-7803-8422-9, pp.388-392, 13-16 may,
% 2004, Sofia
% The following is a an example of the methodology based on the design
% problem considered in the above paper
%% Design for the activation functions of the J and K inputs
Design_for = 'K3';
min_by = 1; % minimize the number of inversions
switch upper(Design_for)
case 'J1'
N = 8; % number of design variables (states 4, 5, 6, 7, 12, 13, 14, 15)
fill_name = 'fill_J1';
case 'J2'
N = 8; % number of design variables (states 2, 3, 6, 7, 10, 11, 14, 15)
fill_name = 'fill_J2';
case 'J3'
N = 8; % number of design variables (states 1, 3, 5, 7, 9, 11, 13, 15)
fill_name = 'fill_J3';
case 'K1'
N = 10; % number of design variables (states 0, 1, 2, 3, 7, 8, 9, 10, 11, 15)
fill_name = 'fill_K1';
case 'K2'
N = 10; % number of design variables (states 0, 1, 4, 5, 7, 8, 9, 12, 13, 15)
fill_name = 'fill_K2';
case 'K3'
N = 10; % number of design variables (states 0, 2, 4, 6, 7, 8, 10, 12, 14 ,15)
fill_name = 'fill_K3';
end
% initialize the cost evaluation function (set which cost function)
evalBoolFF (fill_name, min_by);
%% Prepare the optimization settings
% lower 0 upper 1 integer
BNDS = [zeros(N,1) ones(N,1) -ones(N,1)];
% Define optimization options
opt = GAopt(-5);
opt.MaxIter = 100;
opt.PopulSize = 30;
opt.Graphics = 'off';
%% Run the optimization
[rGens, rFit] = GAMOminSC('evalBoolFF', BNDS, opt);
%% Show the results
fprintf('\n Results from the optimization\n');
disp(rGens)
nsolutions = size(rGens,1);
for i=1:nsolutions
fprintf('\n Resulting activation function for proposed solution number %d\n',i);
JK = feval(fill_name, rGens(i,:));
% Perform boolean minimization
R = minBool( find(JK)-1 );
fprintf('\t x Q1 Q2 Q3\n');
disp(R(2:end,:))
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -