Skip to content

Commit bfcb4ff

Browse files
author
Lukas Molzberger
committed
Merge remote-tracking branch 'origin/master'
2 parents a625c52 + 256b49f commit bfcb4ff

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/main/java/network/aika/neuron/INeuron.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public Activation addInput(Document doc, Activation.Builder input) {
427427
Activation act = getActivation(doc, input);
428428

429429
if (act == null) {
430-
act = new Activation(doc, this, input.getSlots(doc));
430+
act = createActivation(doc, input.getSlots(doc));
431431
}
432432

433433
act.setInputState(input);
@@ -448,6 +448,11 @@ public Activation addInput(Document doc, Activation.Builder input) {
448448
}
449449

450450

451+
protected Activation createActivation(Document doc, Map<Integer, Position> slots) {
452+
return new Activation(doc, this, slots);
453+
}
454+
455+
451456
private Activation getActivation(Document doc, Activation.Builder input) {
452457
Integer firstSlot = input.positions.firstKey();
453458
Position firstPos = doc.lookupFinalPosition(input.positions.get(firstSlot));

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @author Lukas Molzberger
4848
*/
49-
public final class Activation implements Comparable<Activation> {
49+
public class Activation implements Comparable<Activation> {
5050

5151
public static int BEGIN = 0;
5252
public static int END = 1;
@@ -1162,7 +1162,7 @@ public Activation getActivation() {
11621162
}
11631163

11641164

1165-
public class Option {
1165+
public class Option implements Comparable<Option> {
11661166
public int snId;
11671167
public State state;
11681168
public Decision decision;
@@ -1232,6 +1232,13 @@ public Activation getAct() {
12321232
public String toString() {
12331233
return " snId:" + snId + " d:" + decision + " cacheFactor:" + cacheFactor + " w:" + Utils.round(weight) + " p:" + p + " " + state;
12341234
}
1235+
1236+
@Override
1237+
public int compareTo(Option o) {
1238+
int r = Integer.compare(getAct().getId(), o.getAct().getId());
1239+
if(r != 0) return r;
1240+
return Integer.compare(snId, o.snId);
1241+
}
12351242
}
12361243

12371244

0 commit comments

Comments
 (0)