Skip to content

Commit 53a9462

Browse files
author
Lukas Molzberger
committed
fixed addConflict
1 parent e9bf730 commit 53a9462

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

src/main/java/org/aika/neuron/activation/Activation.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,20 @@ public void adjustSelectedNeuronInputs(Decision d) {
354354

355355

356356
public static boolean checkSelfReferencing(Activation nx, Activation ny, boolean onlySelected, int depth) {
357-
if (nx == ny) return true;
357+
if (nx == ny) {
358+
return true;
359+
}
358360

359-
if (depth > MAX_SELF_REFERENCING_DEPTH) return false;
361+
if (depth > MAX_SELF_REFERENCING_DEPTH) {
362+
return false;
363+
}
360364

361-
Set<SynapseActivation> inputs = onlySelected ? ny.selectedNeuronInputs : ny.neuronInputs;
362-
for (SynapseActivation sa: inputs) {
363-
if (checkSelfReferencing(nx, sa.input, onlySelected, depth + 1)) return true;
365+
for (SynapseActivation sa: onlySelected ? ny.selectedNeuronInputs : ny.neuronInputs) {
366+
if(!sa.synapse.key.isRecurrent) {
367+
if (checkSelfReferencing(nx, sa.input, onlySelected, depth + 1)) {
368+
return true;
369+
}
370+
}
364371
}
365372

366373
return false;

src/main/java/org/aika/neuron/activation/Conflicts.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.aika.neuron.activation;
1818

1919

20+
import org.aika.neuron.INeuron;
2021
import org.aika.neuron.activation.Linker.Direction;
2122

2223
import java.util.*;
@@ -48,19 +49,19 @@ public static void linkConflicts(Activation act, long v, Direction dir) {
4849
Activation oAct = (dir == INPUT ? act : sa.output);
4950
Activation iAct = (dir == INPUT ? sa.input : act);
5051

51-
markConflicts(iAct, oAct, v);
52-
5352
addConflict(oAct, iAct, v);
5453
}
5554
}
5655
}
5756

5857

5958
private static void addConflict(Activation oAct, Activation iAct, long v) {
60-
if (iAct.markedConflict == v) {
61-
if (iAct != oAct) {
62-
add(oAct, iAct);
63-
}
59+
if(oAct == iAct) {
60+
return;
61+
}
62+
63+
if (iAct.getINeuron().type != INeuron.Type.INHIBITORY) {
64+
add(oAct, iAct);
6465
} else {
6566
for (Activation.SynapseActivation sa : iAct.neuronInputs) {
6667
if(!sa.synapse.key.isRecurrent) {
@@ -71,16 +72,6 @@ private static void addConflict(Activation oAct, Activation iAct, long v) {
7172
}
7273

7374

74-
private static void markConflicts(Activation iAct, Activation oAct, long v) {
75-
oAct.markedConflict = v;
76-
for (Activation.SynapseActivation sa : iAct.neuronOutputs) {
77-
if (sa.synapse.key.isRecurrent && sa.synapse.isNegative()) {
78-
sa.output.markedConflict = v;
79-
}
80-
}
81-
}
82-
83-
8475
public static Collection<Activation> getConflicting(Activation n) {
8576
ArrayList<Activation> conflicts = new ArrayList<>();
8677
Conflicts.collectConflicting(conflicts, n);

0 commit comments

Comments
 (0)