示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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);
        }
示例#4
0
        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;
        }
示例#5
0
        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;
        }