-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCANTNet.java
More file actions
executable file
·734 lines (634 loc) · 24.4 KB
/
CANTNet.java
File metadata and controls
executable file
·734 lines (634 loc) · 24.4 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
import java.io.*;
import java.util.*;
import java.net.*; //for URL
public class CANTNet {
private static int LONGEST_TIME_NEURON_ACTIVE =0;
protected int cols = 10;
protected int rows = 10;
private String name;
protected int topology;
protected CANTFrame cantFrame;
protected Vector patterns = new Vector();
public CANTNeuron neurons[];
protected int totalNeurons =0;
private int curPattern = -1;
boolean associationTest = false;
boolean allowRunOn=true;
public String netFileName="Net.dat";
private double activationThreshold;
private double axonalStrengthMedian;
private boolean changeEachTime;
private int compensatoryDivisor;
private boolean compensatoryLearningOn;
private double connectionStrength;
private double connectivity;
private float decay;
private float fatigueRecoveryRate;
private int learningOn; // 0 no, 1 yes, 2 only to nets with 1, 3 subclass
private float learningRate;
private int likelihoodOfInhibitoryNeuron;
private boolean neuronsFatigue;
private int neuronsToStimulate;
private float saturationBase;
private boolean spontaneousActivationOn;
private float fatigueRate;
private int cyclesPerRun;
protected int cyclesToStimulatePerRun=10;
private boolean isBaseNet;
public boolean recordingActivation=true;
public Measure measure;
public int getTotalNeurons() {return totalNeurons;}
public int getCurrentPattern() {return curPattern;}
public void setCurrentPattern(int newPattern)
{curPattern = newPattern;}
public int getTotalPatterns() {return patterns.size();}
public CANTPattern getPattern(int index )
{return (CANTPattern)patterns.get(index);}
public int getRows() {return rows;}
public int getCols() {return cols;}
public int size() {return (cols*rows);}
public int getSize() {return (cols*rows);}
public void setName(String Name) {name = Name;}
public String getName() {return name;}
public void setLearningOn(int newLearningOn)
{learningOn=newLearningOn;}
public void setLearningOn(boolean newLearningOn) {
if (newLearningOn)
learningOn = 1;
else
learningOn = 0;
}
public int getLearningOn() {return learningOn;}
public boolean isLearningOn() {
if (learningOn == 1) return true;
else return false;
}
public void setCompensatoryLearningOn(boolean newCompensatoryLearningOn)
{compensatoryLearningOn = newCompensatoryLearningOn;}
public boolean isCompensatoryLearningOn()
{return compensatoryLearningOn;}
public void setSpontaneousActivationOn(boolean newSpontaneousActivationOn) {
spontaneousActivationOn = newSpontaneousActivationOn;}
public boolean isSpontaneousActivationOn() {return spontaneousActivationOn;}
public void setChangeEachTime(boolean newChangeEachTime) {
changeEachTime = newChangeEachTime;}
public boolean isChangeEachTime() {return changeEachTime;}
public void setNeuronsFatigue(boolean newNeuronsFatigue) {
neuronsFatigue = newNeuronsFatigue;}
public boolean isNeuronsFatigue() {return neuronsFatigue;}
public void setLikelihoodOfInhibitoryNeuron(int newLikelihoodOfInhibitoryNeuron) {
likelihoodOfInhibitoryNeuron = newLikelihoodOfInhibitoryNeuron;}
public int getLikelihoodOfInhibitoryNeuron() {
return likelihoodOfInhibitoryNeuron;}
public void setDecay(float newDecay) {decay = newDecay;}
public float getDecay() {return decay;}
public void setFatigueRate(float newFatigueRate) {
fatigueRate = newFatigueRate;}
public float getFatigueRate() {return fatigueRate;}
public void setFatigueRecoveryRate(float newFatigueRecoveryRate) {
fatigueRecoveryRate = newFatigueRecoveryRate;}
public float getFatigueRecoveryRate() {
return fatigueRecoveryRate;}
public void setLearningRate(float newLearningRate) {
learningRate = newLearningRate;}
public float getLearningRate() {
return learningRate;}
public void setCompensatoryDivisor(int newCompensatoryDivisor) {
compensatoryDivisor = newCompensatoryDivisor;}
public int getCompensatoryDivisor() {
return compensatoryDivisor;}
public void setSaturationBase(float newSaturationBase) {
saturationBase = newSaturationBase;}
public float getSaturationBase() {
return saturationBase;}
public void setAxonalStrengthMedian(double newAxonalStrengthMedian) {
axonalStrengthMedian = newAxonalStrengthMedian;}
public double getAxonalStrengthMedian() {
return axonalStrengthMedian;}
public void setActivationThreshold(double newActivationThreshold) {
activationThreshold = newActivationThreshold;}
public double getActivationThreshold() {return activationThreshold;}
public void setConnectivity(double newConnectivity) {
connectivity = newConnectivity;}
public double getConnectivity() {return connectivity;}
public void setConnectionStrength(double newConnectionStrength)
{connectionStrength = newConnectionStrength;}
public double getConnectionStrength() {return connectionStrength;}
public void setNeuronsToStimulate(int newNeuronsToStimulate)
{neuronsToStimulate = newNeuronsToStimulate;}
public int getNeuronsToStimulate() {return neuronsToStimulate;}
public int getCyclesPerRun() {return cyclesPerRun;}
public void setCyclesPerRun(int cycles) {cyclesPerRun = cycles;}
public void setCyclesToStimulatePerRun(int cycles)
{cyclesToStimulatePerRun = cycles;}
public int getCyclesToStimulatePerRun()
{return (cyclesToStimulatePerRun);}
public void setRecordingActivation(boolean rA) {recordingActivation = rA;}
//----real code starts here----
public CANTNet(){}
public CANTNet(String name,int cols, int rows,int topology){
this.cols = cols;
this.rows = rows;
this.name = name;
this.topology = topology;
measure = new Measure(cols*rows);
netFileName = name + ".dat";
}
public CANTNet getNewNet(String name,int cols, int rows,int topology){
//System.out.println("get new base net ");
CANTNet net = new CANTNet (name,cols,rows,topology);
return (net);
}
public void initializeNeurons() {
createNeurons();
if (topology < 0){
setConnections(0,size());
}
else System.out.println("bad topology specified "+ topology);
}
//---------------IO Functions -------
protected void createNeurons() {
totalNeurons = 0;
neurons = new CANTNeuron[cols*rows];
for(int i=0;i< cols*rows;i++)
neurons[i] = new CANTNeuron(totalNeurons++,this);
}
protected void createNeurons(int synapsesPerNeuron) {
totalNeurons = 0;
neurons = new CANTNeuron[cols*rows];
for(int i=0;i< cols*rows;i++)
neurons[i] = new CANTNeuron(totalNeurons++,this,synapsesPerNeuron);
}
public void readBetweenAllNets() {
System.out.println("CANT23 read Between Connections Called: None Will Be Read");
//if you get this message and you want to read connections between nets,
//you need to put it in the subclass.
}
private LineNumberReader inputFile;
private void openReadFile() {
DataInputStream dIS;
InputStreamReader inputSR;
try{
dIS = new DataInputStream(new FileInputStream(netFileName));
inputSR = new InputStreamReader(dIS);
inputFile = new LineNumberReader (inputSR);
}
catch (IOException e) {
System.err.println("input file not opened properly\n" +
e.toString());
System.exit(1);
}
}
public static void readAllNets() {
System.out.println("read all nets");
Enumeration eNum = CANT23.nets.elements();
while (eNum.hasMoreElements()) {
CANTNet net = (CANTNet)eNum.nextElement();
net.readNet(false);
}
}
protected void readConnectTo(CANTNet toNet) {
System.out.println("read Between " +getName() + " and " + toNet.getName());
String inputLine;
openReadFile();
try {
inputLine = inputFile.readLine(); //read row
inputLine= inputFile.readLine(); //read col
//read the neurons
for (int cNeurons=0; cNeurons < (rows*cols); cNeurons++) {
neurons[cNeurons].readNeuronConnectTo(inputFile,toNet);
}
inputFile.close();
}
catch (IOException e) {
System.err.println("input file not read properly\n" +
e.toString());
System.exit(1);}
}
public void readNet(boolean readInterConnections){
System.out.println("read net " + netFileName);
String inputLine;
openReadFile();
try {
inputLine = inputFile.readLine();
rows=Integer.parseInt(inputLine);
System.out.print ( Integer.toString(rows) + "\n");
inputLine= inputFile.readLine();
cols=Integer.parseInt(inputLine);
System.out.print ( Integer.toString(cols) + "\n");
//Create new neurons
createNeurons();
//read the neurons
for (int cNeurons=0; cNeurons < (rows*cols); cNeurons++) {
neurons[cNeurons].readNeuron(inputFile,readInterConnections);
}
inputFile.close();
}
catch (IOException e) {
System.err.println("input file not read properly\n" +
e.toString());
System.exit(1);}
}
public void write(){
DataOutputStream output;
try {
output = new DataOutputStream(new FileOutputStream(netFileName));
output.writeBytes(Integer.toString(rows)+"\n"+Integer.toString(cols) +"\n");
for ( int i=0;i<(size()); i++ ) {
output.writeBytes( Integer.toString(i) + " Neuron\n");
if (neurons[i].getCurrentSynapses()==0)
output.writeBytes("0 Axons\n");
else
for (int j=0; j< neurons[i].getCurrentSynapses() ; j++ ) {
if (j==0)
output.writeBytes(Integer.toString(neurons[i].getCurrentSynapses()) + " Axons\n");
CANTNeuron toNeuron = neurons[i].synapses[j].toNeuron;
output.writeBytes(toNeuron.parentNet.getName() + " ");
output.writeBytes(Integer.toString(toNeuron.id) +
" " + Double.toString(neurons[i].synapses[j].weight) + "\n");
}
}
System.out.println("Network saved");
output.close();
}
catch (IOException e) {
System.err.println("output file not opened properly\n" +
e.toString());
System.exit(1); }
}
public void makeFrame() {
boolean isBase = name.equalsIgnoreCase("BaseNet");
cantFrame = new CANTFrame(this,cols,rows,isBase);
cantFrame.setVisible(true);
}
// kailash
public void addNewPattern(CANTPattern pattern) {
patterns = new Vector();
patterns.add(pattern);
}
public void addPattern(CANTPattern pattern) {
patterns.add(pattern);
}
public void clear() {
//System.out.println("clear " + getName());
for (int cNeuron = 0 ; cNeuron < size(); cNeuron++)
neurons[cNeuron].clear();
}
protected int getLeftNeighbor(int neuronID) {
if ((neuronID % cols) == 0)
return (neuronID + cols - 1);
else
return (neuronID - 1);
}
protected int getRightNeighbor(int neuronID) {
if ((neuronID % cols) == (cols -1))
return (neuronID - cols + 1);
else
return (neuronID + 1);
}
protected int getTopNeighbor(int neuronID) {
if (neuronID < cols)
return (neuronID + ((rows-1) * cols));
else
return (neuronID - cols);
}
protected int getBottomNeighbor(int neuronID) {
if ((neuronID / cols) == (rows -1))
return (neuronID - ((rows-1) * cols));
else
return (neuronID + cols);
}
protected void addConnection(int fromNeuron, int toNeuron, double weight) {
if (toNeuron == fromNeuron) return;
Assert(toNeuron < size());
weight = neurons[fromNeuron].isInhibitory()? weight*-1:weight;
neurons[fromNeuron].addConnection(neurons[toNeuron],weight);
}
//Set the connection strength of this axon, then recursively
//call to set up connections (at a lower likelihood) to other connections.
protected void recursiveSetConnections (int fromNeuron, int toNeuron, int distance) {
int N1,N2,N3,N4;
double weight;
//Set up the initial Weight
weight = (float)(((CANT23.random.nextFloat()) + 1) * connectionStrength);
//with a probability lessening as distance increases
if (CANT23.random.nextFloat() < (1.0 / (distance * connectivity)))
addConnection(fromNeuron,toNeuron,weight);
//call for children if they're close.
if (distance < 4) {
N1 = getLeftNeighbor(toNeuron);
N2 = getRightNeighbor(toNeuron);
N3 = getTopNeighbor(toNeuron);
N4 = getBottomNeighbor(toNeuron);
recursiveSetConnections(fromNeuron,N1,distance + 1);
recursiveSetConnections(fromNeuron,N2,distance + 1);
recursiveSetConnections(fromNeuron,N3,distance + 1);
recursiveSetConnections(fromNeuron,N4,distance + 1);
}
}
//Set up a distance bias set of
//connections. Assume that the Neurons are
//in a 2-D space. Those next to it (lr and td) are
//likely to be connected, next step away less so.
protected void setConnections(int startNeuron, int endNeuron) {
int currentFromNeuron;
int N1 = -1,N2 = -1,N3 = -1,N4 = -1;
int cNeurons = size();
Assert(cNeurons >= endNeuron);
//For Each Neuron
for (currentFromNeuron = startNeuron ; currentFromNeuron < endNeuron;
currentFromNeuron ++) {
//Get it's neighbors Make N1 a long distance connection
N1 = (int)(N1 + (CANT23.random.nextFloat() * size()))%size();
N2 = getRightNeighbor(currentFromNeuron);
N3 = getTopNeighbor(currentFromNeuron);
N4 = getBottomNeighbor(currentFromNeuron);
recursiveSetConnections(currentFromNeuron,N1,1);
recursiveSetConnections(currentFromNeuron,N2,1);
recursiveSetConnections(currentFromNeuron,N3,1);
recursiveSetConnections(currentFromNeuron,N4,1);
}
}
protected void setConnectionsRandomly(int neuronNum,int numConnections, double weight) {
for (int connection=0; connection < numConnections; connection++)
{
int curConnections=neurons[neuronNum].getCurrentSynapses();
addConnection(neuronNum,(int)(CANT23.random.nextFloat()*size()),weight);
if (curConnections==neurons[neuronNum].getCurrentSynapses())
connection--;
}
}
public int getActives() {
int totalActives = 0;
for (int index = 0; index < size(); index++) {
if (neurons[index].getFired())
totalActives++;
}
return totalActives;
}
//call measure for recording the state of the net.
public void setMeasure(int cantStep) {
for (int index = 0; index < size(); index++)
if (neurons[index].getFired())
measure.setActiveState(cantStep,index,1);
else
measure.setActiveState(cantStep,index,0);
}
//This is called from step in frame and makes
//all of the nets run one step
public void runAllOneStep(int cantStep) {
Enumeration eNum = CANT23.nets.elements();
while (eNum.hasMoreElements()) {
CANTNet net = (CANTNet)eNum.nextElement();
net.runOneStep(cantStep);
}
}
public void runOneStep(int cantStep) {
changePattern(cantStep);
setExternalActivation(cantStep);
propogateChange();
learn();
cantFrame.runOneStep(cantStep+1);
if (recordingActivation) setMeasure(cantStep);
}
public void subclassLearn() {
System.out.println(getName() + " Youve got learningOn = 3, subclass it or no learning");
}
public void learn() {
if (learningOn == 0) return;
//System.out.println(getName() + " " + axonalStrengthMedian + " " + saturationBase);
//This is relatively new. If learning is 3, we call learn in the subclass.
if (learningOn == 3) {
subclassLearn();
return;
}
int totalNeurons = size();
for (int neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++)
{
if (learningOn == 2) //only learn if the to neurons net is of learn type 1
neurons[neuronIndex].restrictedLearn();
else
neurons[neuronIndex].learn4();
}
}
public void spontaneousActivate () {
int neuronIndex;
int totalNeurons = size();
//spontaneously activate
for (neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++) {
if (neurons[neuronIndex].spontaneouslyActivate())
activate(neuronIndex,(activationThreshold*2));
}
}
public void setNeuronsFired () {
int neuronIndex;
int totalNeurons = size();
//Set whether neuron has fired.
for (neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++)
{
neurons[neuronIndex].setFired();
//if (neurons[neuronIndex].getFired())
// System.out.println(getName() + " " + neuronIndex + " Fired " + CANT23.CANTStep);
}
}
public void setDecay () {
int neuronIndex;
int totalNeurons = size();
//resetActivation and apply decay
for (neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++)
neurons[neuronIndex].resetActivation();
}
public void spreadActivation () {
int neuronIndex;
int totalNeurons = size();
//for each formally active neuron spread activation
for (neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++){
if ((!associationTest) && (neurons[neuronIndex].getFired()))
neurons[neuronIndex].spreadActivation();
}
}
public void setFatigue () {
int neuronIndex;
int totalNeurons = size();
//modify fatigue
if (neuronsFatigue)
for (neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++) {
neurons[neuronIndex].modifyFatigue();
}
}
//New activation may have come externally. Current is that activation +
//any remaining from last time.
public void propogateChange(){
spontaneousActivate();
setNeuronsFired();
setDecay ();
spreadActivation();
setFatigue();
}
private void activate (int neuronNumber, double activation) {
Assert(neuronNumber < size());
if (neuronNumber >= size())
System.out.println(getName());
double currentActivation = neurons[neuronNumber].getActivation();
activation += currentActivation;
neurons[neuronNumber].setActivation(activation);
}
public void setExternalActivation(int cantStep){
if ((!changeEachTime) &&
(cantStep% cyclesPerRun > cyclesToStimulatePerRun) &&
(allowRunOn))
return;
CANTPattern pattern = (CANTPattern)patterns.get(curPattern);
int neuronsToStimulateNow = neuronsToStimulate > pattern.size()?pattern.size():neuronsToStimulate;
for (int i= 0; i < neuronsToStimulateNow; i++) {
activate(pattern.getPatternIndex(i),
(activationThreshold+(CANT23.random.nextFloat()*activationThreshold)));
}
}
public void changePattern(int cantStep)
{
if (changeEachTime || (cantStep %cyclesPerRun)==0){
CANT23.experiment.endEpoch();
curPattern = CANT23.experiment.selectPattern(curPattern, patterns.size(),this);
((CANTPattern)patterns.get(curPattern)).arrange(neuronsToStimulate);
}
}
//read in a new file of patterns and set the patterns for this
//net to them.
public void getNewPatterns(String fileName) {
patterns = new Vector();
NetManager.readPatternFile(fileName,this);
}
private void checkExcitatoryConnections() {
int totalNeurons = size();
int inhibitoryCount =0;
for (int neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++)
if (!neurons[neuronIndex].isInhibitory()) {
inhibitoryCount++;
CANTNeuron neuron = neurons[neuronIndex];
for (int synIndex =0; synIndex < neuron.getCurrentSynapses(); synIndex++ ) {
double weight = neuron.synapses[synIndex].getWeight();
CANTNeuron toNeuron = neuron.synapses[synIndex].getTo();
System.out.println("Exc "+neuronIndex+ "---"+toNeuron.getId()+" = "+ weight);
}
}
System.out.println("total excitatory neurons = "+inhibitoryCount);
}
private void checkInhibitoryConnections() {
int totalNeurons = size();
int inhibitoryCount =0;
for (int neuronIndex = 0; neuronIndex < totalNeurons; neuronIndex++)
if (neurons[neuronIndex].isInhibitory()) {
inhibitoryCount++;
CANTNeuron neuron = neurons[neuronIndex];
for (int synIndex =0; synIndex < neuron.getCurrentSynapses(); synIndex++ ) {
double weight = neuron.synapses[synIndex].getWeight();
CANTNeuron toNeuron = neuron.synapses[synIndex].getTo();
System.out.println("Inh "+neuronIndex+ "---"+toNeuron.getId()+" = "+ weight);
}
}
System.out.println("total inhibitory neurons = "+inhibitoryCount);
}
//Set Connections from this net to another net.
public void setOtherConnections(CANTNet otherNet, int connectionsPerNeuron) {
int toSize = otherNet.size();
for (int neuronIndex = 0; neuronIndex < size(); neuronIndex++){
for (int newConnection = 0; newConnection < connectionsPerNeuron; newConnection++){
int toNeuron = (int)(CANT23.random.nextFloat()*toSize);
double weight = neurons[neuronIndex].isInhibitory()? -0.1:0.1;
neurons[neuronIndex].addConnection(otherNet.neurons[toNeuron],weight);
}
}
}
public void recordNeuronActiveTime(int time){
if (time > LONGEST_TIME_NEURON_ACTIVE)
LONGEST_TIME_NEURON_ACTIVE = time;
}
private boolean Assert(boolean test) {
int x = -1;
if (! test)
try{
x = (1 / (1 +x));
}
catch(Exception e){
System.out.println("Nettest = "+test);
return false;
}
return true;
}
public void printNeuronsFired(){
int neuronsFired=0;
for (int i = 0; i < size(); i++)
{
if (neurons[i].getFired()) neuronsFired++;
}
System.out.println(getName() + " "+neuronsFired+ " ");
}
public void kludge() {
//this is just a function for debugging purposes. Subclass it so you can
//call it from the interface.
System.out.println("CANTNet kludge ");
}
private void printAverageFatigue(){
float averageFatigue=0;
float maxfatigue =0;
int maxI=-1;
for(int i=0;i<size();i++){
if (maxfatigue< neurons[i].getFatigue()){
maxfatigue = neurons[i].getFatigue();
maxI = i;
}
}
// System.out.println("Max Fatigue = "+maxfatigue+ "Neuron= "+maxI);
}
public boolean selectPattern(int patternNum) {
if (patternNum >= patterns.size() || patternNum<0)
return false ;
curPattern = patternNum;
((CANTPattern)patterns.get(curPattern)).arrange(neuronsToStimulate);
return true;
}
public void writeParameters() {
int LearningValue;
DataOutputStream OutputFile;
String outString="";
outString=Integer.toString(likelihoodOfInhibitoryNeuron);
outString=outString + " Likelihood of Inhibitory Neuron\n";
outString=outString + Float.toString(decay);
outString=outString + " Decay\n";
outString=outString + Float.toString(fatigueRate);
outString=outString +" Fatigue Rate\n";
outString=outString + Float.toString(fatigueRecoveryRate);
outString=outString + " Fatigue Recovery RAte\n";
outString=outString + Float.toString(learningRate);
outString=outString + " Learning Rate\n";
outString=outString + Integer.toString(compensatoryDivisor);
outString=outString + " Compensatory Divisor\n";
outString=outString + Float.toString(saturationBase);
outString=outString + " Saturation Base\n";
outString=outString + Double.toString(axonalStrengthMedian);
outString=outString + " Axonal Strength Median\n";
outString=outString + Double.toString(activationThreshold);
outString=outString + " Activation Threshold\n";
outString=outString + Double.toString(connectivity);
outString=outString + " Connectivity\n";
outString=outString + Double.toString(connectionStrength);
outString=outString + " Connection Strength\n";
if (learningOn == 0) LearningValue = 0;
else if (!compensatoryLearningOn) LearningValue = 1;
else LearningValue = 2;
outString=outString + Integer.toString(LearningValue);
outString=outString + " Learning On\n";
outString=outString + Integer.toString(neuronsToStimulate);
outString=outString + " Neurons To Stimulate\n";
outString=outString + changeEachTime;
outString=outString + " Change Each Time\n";
outString=outString + neuronsFatigue;
outString=outString + " Neurons Fatigue\n";
outString=outString + spontaneousActivationOn;
outString=outString + " Spontaneous Activation\n";
outString=outString + cyclesPerRun;
outString=outString + " Cycles Per Run\n";
System.out.println(outString);
}
}