October 09, 2020
Work in progress

Usage

Maven POM

The following dependency includes the Aika software library to an existing maven project.

<dependency>
    <groupId>org.aika-software</groupId>
    <artifactId>aika</artifactId>
    <version>2.0.0-SNAPSHOT</version>
</dependency>

Mutual exclusion example

				
    @Test
    public void testMutualExclusion() {
        Model m = new TextModel();

        PatternNeuron in = new PatternNeuron(m, "I", "IN", true);
        PatternPartNeuron na = new PatternPartNeuron(m, "A", false);
        PatternPartNeuron nb = new PatternPartNeuron(m, "B", false);
        PatternPartNeuron nc = new PatternPartNeuron(m, "C", false);
        InhibitoryNeuron inhib = new InhibitoryNeuron(m, "I", false);

        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(in, na, false, false, true, false);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                na.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(inhib, na, true, true, false, false);

                s.linkOutput();
                s.addWeight(-100.0);
            }

            na.setBias(1.0);
        }

        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(in, nb, false, false, true, false);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                nb.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(inhib, nb, true, true, false, false);

                s.linkOutput();
                s.addWeight(-100.0);
            }
            nb.setBias(1.5);
        }


        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(in, nc, false, false, true, false);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                nc.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(inhib, nc, true, true, false, false);

                s.linkOutput();
                s.addWeight(-100.0);
            }

            nc.setBias(1.2);
        }

        {
            {
                InhibitorySynapse s = new InhibitorySynapse(na, inhib);
                s.linkInput();
                s.addWeight(1.0);
            }
            {
                InhibitorySynapse s = new InhibitorySynapse(nb, inhib);
                s.linkInput();
                s.addWeight(1.0);
            }
            {
                InhibitorySynapse s = new InhibitorySynapse(nc, inhib);
                s.linkInput();
                s.addWeight(1.0);
            }

            inhib.setBias(0.0);
        }

        Document doc = new Document("test");

        Activation act = new Activation(doc, in);
        act.setValue(1.0);
        act.setFired(0);

        act.propagateInput();

        doc.process();

        System.out.println(doc.activationsToString());

        Set nbActs = doc.getActivations(nb);
        Activation nbAct = nbActs.iterator().next();

        assertTrue(nbAct.getValue() > 0.38);
    }
                
			

Pattern matching example

				
    public TextModel initModel() {
        TextModel m = new TextModel();

        PatternNeuron nA = m.lookupToken("A");
        PatternNeuron nB = m.lookupToken("B");
        PatternNeuron nC = m.lookupToken("C");

        PatternPartNeuron eA = new PatternPartNeuron(m, "E A", false);
        PatternPartNeuron eB = new PatternPartNeuron(m, "E B", false);
        PatternPartNeuron eC = new PatternPartNeuron(m, "E C", false);

        PatternNeuron out = new PatternNeuron(m, "ABC", "OUT", false);

        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(nA, eA, false, false, true, false);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                eA.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(out, eA, false, true, false, false);

                s.linkInput();
                s.linkOutput();
                s.setWeight(10.0);
                eA.addConjunctiveBias(-10.0, true);
            }
            eA.setBias(4.0);
        }

        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(nB, eB, false, false, true, false);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                eB.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(eA, eB, false, false, false, true);

                s.linkOutput();
                s.addWeight(10.0);
                eB.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(lookupPPPT(m, nB), eB, false, false, true, false);

                s.linkOutput();
                s.addWeight(10.0);
                eB.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(out, eB, false, true, false, false);

                s.linkOutput();
                s.addWeight(10.0);
                eB.addConjunctiveBias(-10.0, true);
            }
            eB.setBias(4.0);
        }

        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(nC, eC, false, false, true, false);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                eC.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(eB, eC, false, false, false, true);

                s.linkOutput();
                s.addWeight(10.0);
                eC.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(lookupPPPT(m, nC), eC, false, false, true, false);

                s.linkOutput();
                s.addWeight(10.0);
                eC.addConjunctiveBias(-10.0, false);
            }

            {
                ExcitatorySynapse s = new ExcitatorySynapse(out, eC, false, true, false, false);

                s.linkOutput();
                s.addWeight(10.0);
                eC.addConjunctiveBias(-10.0, true);
            }
            eC.setBias(4.0);
        }

        {
            {
                ExcitatorySynapse s = new ExcitatorySynapse(eA, out, false, false, false, true);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                out.addConjunctiveBias(-10.0, false);
            }
            {
                ExcitatorySynapse s = new ExcitatorySynapse(eB, out, false, false, false, true);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                out.addConjunctiveBias(-10.0, false);
            }
            {
                ExcitatorySynapse s = new ExcitatorySynapse(eC, out, false, false, false, true);

                s.linkInput();
                s.linkOutput();
                s.addWeight(10.0);
                out.addConjunctiveBias(-10.0, false);
            }
            out.setBias(4.0);
        }
        return m;
    }

    public PatternPartNeuron lookupPPPT(TextModel tm, PatternNeuron pn) {
        return (PatternPartNeuron) pn.getOutputSynapses()
                .map(s -> s.getOutput())
                .filter(n -> isPTNeuron(tm, n))
                .findAny()
                .orElse(null);
    }

    private boolean isPTNeuron(TextModel tm, Neuron n) {
        return n.getOutputSynapses()
                .map(s -> s.getOutput())
                .anyMatch(in -> in == tm.getPrevTokenInhib());
    }
				
			
				
Activation ID - Neuron Type - Final Decision - Slots | Identity - Neuron Label - Upper Bound -
Value | Net | Weight - Input Value | Target Value

0   INPUT      -          - (0:0, 1:2) "a " () - a - V:1.0 UB:1.0 Net:0.0 W:0.0 - IV:1.0
1   INPUT      -          - (0:2, 1:4) "b " () - b - V:1.0 UB:1.0 Net:0.0 W:0.0 - IV:1.0
5   EXCITATORY - SELECTED - (0:2, 1:10) "b c d e " () - BCDE - V:1.0 UB:1.0 Net:5.0 W:0.0
2   INPUT      -          - (0:4, 1:6) "c " () - c - V:1.0 UB:1.0 Net:0.0 W:0.0 - IV:1.0
3   INPUT      -          - (0:6, 1:8) "d " () - d - V:1.0 UB:1.0 Net:0.0 W:0.0 - IV:1.0
4   INPUT      -          - (0:8, 1:10) "e " () - e - V:1.0 UB:1.0 Net:0.0 W:0.0 - IV:1.0

 Final SearchNode:1  WeightSum:0.0