Information Technology Reference
In-Depth Information
the gene parameters (in our case the values of the ,,s) many other local oolean
functions can be implemented. In [2] an d [1] a detailed procedure is given to
represent any arbitrary oolean function us ing a piecewise-linear representation as
above. oreover, one can simply change the cell structure and use any other
nonlinear function. For example, as seen in the last lines, while a sign function is
employed, the result is a CA emulatin g a binary cellular automaton. One may
also use continuous valued functions with or without saturation, resulting in a
CA with continuous states (the last lines of the code).
et us now have a look at the code C.M to implement the generalied
cellular automata. It is implemented in the form of a atlab function with two
input parameters. The first is a scalar and represents the number of iteration steps
until stop (a faster stop can be achieved by pressing the keys CTL and C). The
second may be absent but if not it represents the name (a string) of a file contain-
ing the initial state. The initial state gives also information about the sie (number
of cells) of the C. A periodic boundary condition is implemented, the lattice is
square with a oore neighborhood indexed as explained in the source code:
function gca_u(steps,init_cond)
% e.g. steps=100 (runs the GCA for 100 iterations)
% e.g. init_cond='cross199'
% The inital state should be previously saved as matrix x0. For example:
% x0=ones(199,199); x0(90:110,90:110)=1
% save one199 x0
% The neighborhood index is chosen as follows:
% 9 8 7
% 6 5 4
% 3 2 1
if nargin<2
% by default the "cross199" initial state is loaded if no input file is specified
init_cond='cross199';
x0=-ones(199,199); x0(90:110,90:110)=1;
else
eval(['load ',init_cond]);
% load the initial state
end
[m n]=size(x0);
i=1:m; % row index
j=1:n; % column index
left_j=[n,1:n-1]; right_j=[2:n,1];
% indexes of cells on the left and right
up_i=[m,1:m-1]; low_i=[2:m,1];
% indexes of cells upper and lower
y=x0;
% current output is loaded with x0
for s=1:steps
% Computes the inputs in the next step
u9=y(up_i,left_j); u8=y(up_i,j); u7=y(up_i,right_j);
u6=y(i,left_j); u5=y; u4=y(i,right_j);
u3=y(low_i,left_j); u2=y(low_i,j); u1=y(low_i,right_j);
% Compute the new output using the cell function
y=gca_u_cell(u1,u2,u3,u4,u5,u6,u7,u8,u9);
Search WWH ::




Custom Search