/// <summary> implementation will Remove the template from the HashMap /// and it will Remove the ObjectTypeNode from the network. /// </summary> public virtual void removeTemplate(ITemplate temp, Rete engine, IWorkingMemory mem) { deftemplates.Remove(temp.Name); if (temp.ClassName != null) { deftemplates.Remove(temp.ClassName); } ObjectTypeNode otn = mem.RuleCompiler.getObjectTypeNode(temp); mem.RuleCompiler.removeObjectTypeNode(otn); }
/// <summary> Retracting from the left is different than retractRight for couple /// of reasons. /// <ul> /// <li> NotJoin will only propogate the facts from the left</li> /// <li> NotJoin never needs to merge the left and right</li> /// </ul> /// </summary> /// <param name="">factInstance /// </param> /// <param name="">engine /// /// </param> public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this); leftmem.Remove(linx); propogateRetract(linx, engine, mem); }
/// <summary> /// </summary> public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this); if (leftmem.ContainsKey(linx)) { // the memory Contains the key, so we retract and propogate leftmem.Remove(linx); propogateRetract(linx, engine, mem); } }
public override bool removeNode(BaseNode n) { bool rem = base.removeNode(n); successor2.Remove(n); if (n is AlphaNode) { entries.Remove(((AlphaNode)n).HashIndex); } return(rem); }
/// <summary> Remove a partial match from the memory /// </summary> public virtual int removePartialMatch(IHashIndex index, IFact fact) { IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory[index]; list.Remove(fact); if (list.Count == 0) { memory.Remove(index); } counter--; return(list.Count); }
/// <summary> Retracting from the left requires that we propogate the /// /// </summary> /// <param name="">factInstance /// </param> /// <param name="">engine /// /// </param> public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this); leftmem.Remove(linx); NotEqHashIndex eqinx = new NotEqHashIndex(NodeUtils.getLeftBindValues(binds, linx.Facts)); HashedNeqAlphaMemory rightmem = (HashedNeqAlphaMemory)mem.getBetaRightMemory(this); Object[] objs = rightmem.iterator(eqinx); for (int idx = 0; idx < objs.Length; idx++) { propogateRetract(linx.add((IFact)objs[idx]), engine, mem); } }
/// <summary> Retract from the right works in the following order. /// 1. Remove the fact from the right memory /// 2. check which left memory matched /// 3. propogate the retract /// </summary> /// <param name="">factInstance /// </param> /// <param name="">engine /// /// </param> public override void retractRight(IFact rfact, Rete engine, IWorkingMemory mem) { Index inx = new Index(new IFact[] { rfact }); IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this); if (rightmem.ContainsKey(inx)) { int count = rightmem.Count; rightmem.Remove(inx); if (count == 1 && rightmem.Count == 0) { propogateRetract(inx, engine, mem); } } }
/// <summary> Retracting from the left requires that we propogate the /// /// </summary> /// <param name="">factInstance /// </param> /// <param name="">engine /// /// </param> public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this); leftmem.Remove(linx); IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this); IEnumerator itr = rightmem.Keys.GetEnumerator(); if (itr != null) { while (itr.MoveNext()) { propogateRetract(linx.add((IFact)itr.Current), engine, mem); } } }
/// <summary> Remove a partial match from the memory /// </summary> public virtual int removePartialMatch(NotEqHashIndex index, IFact fact) { IGenericMap <Object, Object> match = (IGenericMap <Object, Object>)memory.Get(index); if (match != null) { IGenericMap <Object, Object> submatch = (IGenericMap <Object, Object>)match.Get(index.SubIndex); submatch.Remove(fact); if (submatch.Count == 0) { match.Remove(index.SubIndex); } counter--; return(submatch.Count); } return(-1); }
/// <summary> Retract from the right works in the following order. 1. Remove the fact /// from the right memory 2. check which left memory matched 3. propogate the /// retract /// /// </summary> /// <param name="">factInstance /// </param> /// <param name="">engine /// /// </param> public override void retractRight(IFact rfact, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this); rightmem.Remove(rfact); IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this); IEnumerator itr = leftmem.Values.GetEnumerator(); while (itr.MoveNext()) { IBetaMemory bmem = (IBetaMemory)itr.Current; if (evaluate(bmem.LeftFacts, rfact, engine)) { bmem.removeMatch(rfact); propogateRetract(bmem.Index, engine, mem); } } }
/// <summary> /// Retracting from the left requires that we propogate the /// </summary> /// <param name="linx">The linx.</param> /// <param name="engine">The engine.</param> /// <param name="mem">The mem.</param> public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> leftmem = mem.getBetaLeftMemory(this); leftmem.Remove(linx); IGenericMap <IFact, IFact> rightmem = (IGenericMap <IFact, IFact>)mem.getBetaRightMemory(this); foreach (IFact itr in rightmem.Values) { propogateRetract(linx.add(itr), engine, mem); } //IEnumerator itr = rightmem.Values.GetEnumerator(); //while (itr.MoveNext()) //{ // propogateRetract(linx.add((IFact) itr.Current), engine, mem); //} }
public virtual void retractFact(IFact fact) { Deffact f = (Deffact)fact; deffactMap.Remove(f.equalityIndex()); if (profileRetract_Renamed_Field) { retractFactWProfile(f); } else { if (watchFact_Renamed_Field) { engine.writeMessage("<== " + fact.toFactString() + Constants.LINEBREAK, "t"); } root.retractObject(f, engine, this); } }
/// <summary> Retracting from the left requires that we propogate the /// /// </summary> /// <param name="">factInstance /// </param> /// <param name="">engine /// /// </param> public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem) { IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this); leftmem.Remove(linx); EqHashIndex eqinx = new EqHashIndex(NodeUtils.getLeftValues(binds, linx.Facts)); HashedAlphaMemoryImpl rightmem = (HashedAlphaMemoryImpl)mem.getBetaRightMemory(this); // now we propogate the retract. To do that, we have // merge each item in the list with the Fact array // and call retract in the successor nodes IEnumerator itr = rightmem.iterator(eqinx); if (itr != null) { while (itr.MoveNext()) { propogateRetract(linx.add((IFact)itr.Current), engine, mem); } } }
/// <summary> /// Retract from the right works in the following order. /// 1. Remove the fact from the right memory /// 2. check which left memory matched /// 3. propogate the retract /// </summary> /// <param name="rfact"></param> /// <param name="engine"></param> /// <param name="mem"></param> public override void retractRight(IFact rfact, Rete engine, IWorkingMemory mem) { IGenericMap <IFact, IFact> rightmem = (IGenericMap <IFact, IFact>)mem.getBetaRightMemory(this); rightmem.Remove(rfact); IGenericMap <Object, Object> leftmem = mem.getBetaLeftMemory(this); foreach (Index bmem in leftmem.Values) { propogateRetract(bmem.add(rfact), engine, mem); } //IEnumerator itr = leftmem.Values.GetEnumerator(); //while (itr.MoveNext()) //{ // Index bmem = (Index) itr.Current; // // now we propogate // propogateRetract(bmem.add(rfact), engine, mem); //} }
/// <summary> Remove a rule from this module /// </summary> public virtual void removeRule(Rule.IRule rl, Rete engine, IWorkingMemory mem) { rules.Remove(rl.Name); // we should iterate over the nodes of the rule and Remove // them if they are not shared ICondition[] cnds = rl.Conditions; // first Remove the alpha nodes for (int idx = 0; idx < cnds.Length; idx++) { ICondition cnd = cnds[idx]; if (cnd is ObjectCondition) { ObjectCondition oc = (ObjectCondition)cnd; String templ = oc.TemplateName; Deftemplate temp = (Deftemplate)deftemplates.Get(templ); ObjectTypeNode otn = mem.RuleCompiler.getObjectTypeNode(temp); removeAlphaNodes(oc.Nodes, otn); } } // now Remove the betaNodes, since the engine currently // doesn't share the betaNodes, we can just Remove it IList bjl = rl.Joins; for (int idx = 0; idx < bjl.Count; idx++) { BaseJoin bjoin = (BaseJoin)bjl[idx]; ICondition cnd = cnds[idx + 1]; if (cnd is ObjectCondition) { ObjectCondition oc = (ObjectCondition)cnd; String templ = oc.TemplateName; Deftemplate temp = (Deftemplate)deftemplates.Get(templ); ObjectTypeNode otn = mem.RuleCompiler.getObjectTypeNode(temp); otn.removeNode(bjoin); } } }
public virtual void removeMatch(IFact rightfact) { matches.Remove(rightfact); }
public virtual void removeAlphaMemory(Object key) { alphaMemories.Remove(key); }
/// <summary> Method will Remove the ObjectTypeNode and call Clear on it. /// </summary> public virtual void removeObjectTypeNode(ObjectTypeNode node) { inputnodes.Remove(node.Deftemplate); node.clear(memory); node.clearSuccessors(); }
/// <summary> /// Remove the LinkedActivation from TerminalNode2. This is necessary /// when the activation is fired and the actions executed. /// </summary> /// <param name="mem">The mem.</param> /// <param name="activation">The activation.</param> public virtual void removeActivation(IWorkingMemory mem, LinkedActivation activation) { IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this); tmem.Remove(activation.Index); }
/// <summary> The current implementation just removes the ObjectTypeNode /// and doesn't prevent the removal. The method should be called /// with care, since removing the ObjectTypeNode can have serious /// negative effects. This would generally occur when an undeftemplate /// occurs. /// </summary> public virtual void removeObjectTypeNode(ObjectTypeNode node) { inputNodes.Remove(node.Deftemplate); }