public void quickFilter(string actionList, string observationList) { Console.WriteLine("QF: {0} , {1}", actionList, observationList); string [] actArry = actionList.Split('|'); string [] obsArry = observationList.Split('|'); inputAct = new PFAction(); inputObservation = new Observation(); foreach (string a in actArry) { inputAct.actParms.Add(a, 1.0); } foreach (string o in obsArry) { inputObservation.observable.Add(o, 1.0); } updateModel(inputObservation); if (traceStack < traceDepth - 1) { traceStack++; } else { for (int i = 0; i < traceDepth; i++) { traceSet[i] = traceSet[i + 1]; } } defMeanParticle(); traceSet[traceStack] = new Particle(meanParticle); }
public Particle transformParticle(PFAction act, Particle p) { //Particle nextParticle = new Particle(p); Particle nextParticle = new Particle(); //nextParticle.variables = p.variables; nextParticle.prob = p.prob; double maxProb = minimumP; string[] statekeys = p.variables.Keys.ToArray(); foreach (string state in statekeys) { double stateP = p.variables[state]; if (stateP < minimumP) { stateP = minimumP; } foreach (string actv in act.actParms.Keys) { double actP = act.actParms[actv]; string key = String.Format("{0}|{1}", state, actv); if (state_act_tansition.ContainsKey(key)) { Estimator myEstimate = state_act_tansition[key]; // fill in each facet foreach (string facet in myEstimate.estimate.Keys) { double estP = (myEstimate.estimate[facet] * stateP * actP); double noise = (estP * 0.01 * rgen.NextDouble()) - (estP * 0.005); estP = Math.Abs(estP + noise); //double estP = (myEstimate.estimate[facet] * stateP) ; if ((!nextParticle.variables.ContainsKey(facet)) || (estP > nextParticle.variables[facet])) { nextParticle.variables[facet] = estP; nextParticle.prob = estP; } if (estP > maxProb) { maxProb = estP; } // Then what ??? } } else { Console.WriteLine("Not found:'{0}'", key); } } } if (maxProb < minimumP) { maxProb = minimumP; } nextParticle.prob = maxProb; // go with the strongest frame facet for now if (maxProb == 0) { Console.WriteLine("maxProb==0"); } return(nextParticle); }