Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

A (one dimensional) cellular automaton is a function1 F : Σ → Σ with the property that there is a K > 0 such that F (x)i depends only on the 2K + 1 coordinates xi−K , xi−K+1, . . . , xi−1, xi, xi+1, . . . , xi+K . A periodic point of σ is any x such that σ^p (x) = x for some p ∈ N, and a periodic point of F is any x such that F^q (x) = x for some q ∈ N. Given a cellular automaton F, a point x ∈ Σ is jointly periodic if there are p, q ∈ N such that σ^p (x) = F^q (x) = x, that is, it is a periodic point under both functions.

This project aims to explore the nature of one-dimensional Cellular Automata, in the hope of finding the structure of cellular automata through its periodic points.

2034 views
License: MIT
ubuntu2004
1
/*
2
* Copyright (C) 2004 Bryant Lee
3
*
4
* This file is part of FPeriod.
5
*
6
* FPeriod is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* FPeriod is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with FPeriod; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
/*
22
* RecNode
23
* A record node. Stores information for all the runs for a given period.
24
*
25
* Written by: Bryant Lee
26
* Date: 11/4/04
27
*/
28
29
#include "RecNode.h"
30
31
#include <map>
32
33
//constructor
34
RecNode::RecNode(unsigned int icPeriod, unsigned long long iNumTrials) {
35
currPeriod = icPeriod;
36
sumPeriod = 0;
37
sumPreperiod = 0;
38
numPeriodic = 0;
39
numTrials = iNumTrials;
40
largestorbit = 0;
41
42
//for FProbPeriod: pending flag says that this RecNode is not filled in yet
43
// which is helpful in case of a crash
44
//for FPeriod and FDense: this is not used
45
pending = true;
46
}
47
48
//recordOrbit
49
void RecNode::recordOrbit(unsigned long long orbit) {
50
map<unsigned long long, unsigned long long>::iterator mult;
51
52
if((mult = orbitMap.find(orbit)) != orbitMap.end()) {
53
mult->second++;
54
}
55
else {
56
orbitMap.insert(pair<unsigned long long, unsigned long long>(orbit,1));
57
}
58
}
59
60
//recordperiod
61
void RecNode::recordPeriod(unsigned long long period,
62
unsigned long long preperiod) {
63
map<unsigned long long, unsigned long long>::iterator mult;
64
65
if(period > largestorbit)
66
largestorbit = period;
67
68
sumPeriod += period;
69
sumPreperiod += preperiod;
70
71
if((mult = periodMap.find(period)) != periodMap.end()) {
72
mult->second++;
73
}
74
else {
75
periodMap.insert(pair<unsigned long long, unsigned long long>(period,1));
76
}
77
78
if((mult = preperiodMap.find(preperiod)) != preperiodMap.end()) {
79
mult->second++;
80
}
81
else {
82
preperiodMap.insert(pair<unsigned long long,unsigned long long>(preperiod,1));
83
}
84
}
85
86
//recordPeriodicPeriod
87
void RecNode::recordPeriodicPeriod(unsigned long long period) {
88
map<unsigned long long,unsigned long long>::iterator mult;
89
90
if((mult = periodicPeriodMap.find(period)) != periodicPeriodMap.end()) {
91
mult->second++;
92
}
93
else {
94
periodicPeriodMap.insert(pair<unsigned long long,unsigned long long>(period,1));
95
}
96
}
97
98
//fractionperiodic
99
double RecNode::fractionPeriodic() {
100
return ((double) numPeriodic)/((double) numTrials);
101
}
102
103
//numnonperiodic
104
unsigned long long RecNode::numNonPeriodic() {
105
return numTrials - numPeriodic;
106
}
107
108
//avgperiod
109
double RecNode::avgPeriod() {
110
return ((double) sumPeriod)/((double) numTrials);
111
}
112
113
//avgpreperiod
114
double RecNode::avgPreperiod() {
115
return ((double) sumPreperiod)/((double) numTrials);
116
}
117
118
//maxpreperiod
119
double RecNode::maxPreperiod() {
120
map<unsigned long long, unsigned long long>::const_reverse_iterator rit;
121
122
rit = preperiodMap.rbegin();
123
if(rit !=
124
(map<unsigned long long, unsigned long long>::const_reverse_iterator)
125
preperiodMap.rend())
126
return rit->first;
127
else
128
return 0;
129
}
130
131
//max period
132
double RecNode::maxPeriod() {
133
map<unsigned long long,unsigned long long>::const_reverse_iterator rit;
134
135
rit = periodMap.rbegin();
136
if(rit !=
137
(map<unsigned long long,unsigned long long>::const_reverse_iterator)
138
periodMap.rend())
139
return rit->first;
140
else
141
return 0;
142
}
143
144
145
146
147
148