public ParticleSet perceptionUpdate(String perception, Randomizer r) { // compute Particle Weight foreach (Particle p in particles) { double particleWeight = hmm.sensorModel().get(p.getState(), perception); p.setWeight(particleWeight); } // weighted sample to create new ParticleSet ParticleSet result = new ParticleSet(hmm); while (result.size() != size()) { foreach (Particle p in particles) { double probability = r.nextDouble(); if (probability <= p.getWeight()) { if (result.size() < size()) { result.add(new Particle(p.getState(), p.getWeight())); } } } } return(result); }
public void setUp() { rainman = HMMFactory.createRainmanHMM(); robot = HMMFactory.createRobotHMM(); randomizer = new MockRandomizer(new double[] { 0.1, 0.9 }); particleSet = new ParticleSet(rainman); particleSet.add(new Particle(HmmConstants.RAINING)); particleSet.add(new Particle(HmmConstants.RAINING)); particleSet.add(new Particle(HmmConstants.RAINING)); particleSet.add(new Particle(HmmConstants.NOT_RAINING)); }
public ParticleSet generateParticleSetForPredictedState(String action, Randomizer randomizer) { ParticleSet predictedParticleSet = new ParticleSet(this.hmm); foreach (Particle p in particles) { String newState = hmm.transitionModel().getStateForProbability( p.getState(), action, randomizer.nextDouble()); Particle generatedParticle = new Particle(newState); predictedParticleSet.add(generatedParticle); } return(predictedParticleSet); }
public ParticleSet generateParticleSetForPredictedState(String action, Randomizer randomizer) { ParticleSet predictedParticleSet = new ParticleSet(this.hmm); foreach (Particle p in particles) { String newState = hmm.transitionModel().getStateForProbability( p.getState(), action, randomizer.nextDouble()); Particle generatedParticle = new Particle(newState); predictedParticleSet.add(generatedParticle); } return predictedParticleSet; }
public ParticleSet perceptionUpdate(String perception, Randomizer r) { // compute Particle Weight foreach (Particle p in particles) { double particleWeight = hmm.sensorModel().get(p.getState(), perception); p.setWeight(particleWeight); } // weighted sample to create new ParticleSet ParticleSet result = new ParticleSet(hmm); while (result.size() != size()) { foreach (Particle p in particles) { double probability = r.nextDouble(); if (probability <= p.getWeight()) { if (result.size() < size()) { result.add(new Particle(p.getState(), p.getWeight())); } } } } return result; }