@@ -108,7 +108,9 @@ public void linkInput(Activation act) {
108108
109109 Activation iAct = s .input .get (act .doc ).getActivation (act .doc , r , false );
110110
111- link (s , iAct , act );
111+ if (iAct != null ) {
112+ link (s , iAct , act );
113+ }
112114 }
113115 }
114116 doc .linker .process ();
@@ -138,32 +140,21 @@ public void process() {
138140 while (!queue .isEmpty ()) {
139141 Link l = queue .pollFirst ();
140142 linkRelated (l .input , l .output , l .synapse .relations );
141- /*
142- for(Map.Entry<Relation.Key, Relation> me: l.synapse.relations.entrySet()) {
143- int relId = me.getKey();
144- if(relId >= 0) {
145- Synapse s = l.output.getNeuron().getSynapseById(relId);
146- if(s != null) {
147- Relation r = me.getValue();
148- linkRelated(l.input, l.output, s, r);
149- }
150- }
151- }
152- */
153143 doc .propagate ();
154144 }
155145 }
156146
157147
158- private void linkRelated (Activation rAct , Activation oAct , Map <Integer , Relation > relations ) {
159- for (Map .Entry <Integer , Relation > me : relations .entrySet ()) {
148+ private void linkRelated (Activation rAct , Activation oAct , Map <Integer , Set < Relation > > relations ) {
149+ for (Map .Entry <Integer , Set < Relation > > me : relations .entrySet ()) {
160150 Integer relId = me .getKey ();
161151 if (relId >= 0 ) {
162152 Synapse s = oAct .getNeuron ().getSynapseById (relId );
163153 if (s != null ) {
164- Relation r = me .getValue ();
165- if (r .follow (rAct , oAct , relations )) {
166- linkRelated (rAct , oAct , s , r );
154+ for (Relation r : me .getValue ()) {
155+ if (r .follow (rAct , oAct , relations )) {
156+ linkRelated (rAct , oAct , s , r );
157+ }
167158 }
168159 }
169160 }
@@ -229,11 +220,12 @@ protected void link(Synapse s, Activation iAct, Activation oAct) {
229220
230221
231222 private boolean checkRelations (Synapse s , Activation iAct , Activation oAct ) {
232- for (Map .Entry <Integer , Relation > me : s .relations .entrySet ()) {
223+ for (Map .Entry <Integer , Set < Relation > > me : s .relations .entrySet ()) {
233224 if (me .getKey () == Synapse .OUTPUT ) {
234- Relation r = me .getValue ();
235- if (!r .test (iAct , oAct )) {
236- return false ;
225+ for (Relation r : me .getValue ()) {
226+ if (!r .test (iAct , oAct )) {
227+ return false ;
228+ }
237229 }
238230 }
239231 // TODO: other relations
0 commit comments