public void Propagate(Term t) { //for(int i=0; i<2; i++) { this.Changed.Clear(); t.Accept(this); #if RecPropDEBUG Console.WriteLine("Queued Terms: "); foreach (Term q in this.Changed) { Console.WriteLine(q); } Console.WriteLine("------------------------------------"); #endif /* * foreach(Term q in this.Changed) { * q.Accept(this.sp); * } * while(this.Changed.Count > 0) { * Term cur = this.Changed.Dequeue(); * cur.Accept(this.dp); * cur.Accept(this.up); * }*/ Term cur = this.Changed.First; while (cur != null) { cur.Accept(this.sp); cur = cur.Next; } cur = this.Changed.Dequeue(); while (cur != null) { cur.Accept(this.dp); cur.Accept(this.up); cur = this.Changed.Dequeue(); } //} /*cur = this.Changed.First; * while(cur!=null) { * cur.Accept(this.dp); * //Term next = cur.Next; * * if(cur.Accept(this.up)) { * /*Term prev = cur.Prev; * this.Changed.MoveToEnd(cur); * if (prev == null) cur = this.Changed.First; * else cur = prev.Next;*/ //cur = cur.Next; // } // cur = cur.Next; //} //*/ }
public static Term Substitute(this Term term, IDictionary <Variable, double> substitutions) { var visitor = new SubsitutionVisitor(substitutions); var result = term.Accept(visitor).Term; return(result); }
public bool Propagate(Term term) { term.Accept(this.ri); //term.Accept(this.sp); term.Min = 1; term.Max = 1; updates = 0; try { this.rp.Propagate(term); } catch (UnsolveableException) { #if RecPropDEBUG Console.WriteLine("Unsolvable: " + ue); Console.WriteLine("{0} update steps", updates); #endif return(false); } #if RecPropDEBUG Console.WriteLine("{0} update steps", updates); #endif return(true); }