示例#1
0
        public GrowEventRecord RemoveRecord()
        {
            double r = this.m_RandomGenerator.GetNextDouble();
            double InverseCumulativeProb = 1.0;

            Debug.Assert(this.m_Map.Count > 0);
            Debug.Assert(this.m_TotalLikelihood > 0.0);

            foreach (GrowEventRecord v in this.m_Map.Values)
            {
                InverseCumulativeProb -= (v.Likelihood / this.m_TotalLikelihood);
                Debug.Assert(MathUtils.CompareDoublesGTEqual(InverseCumulativeProb, 0.0, 0.00001));

                if (r >= InverseCumulativeProb)
                {
                    this.m_Map.Remove(v.Cell.CellId);

                    Debug.Assert(this.m_TotalLikelihood >= 0.0);
                    this.m_TotalLikelihood -= v.Likelihood;

                    return(v);
                }
            }

            Debug.Assert(false);

            GrowEventRecord first = this.m_Map.First().Value;

            this.m_Map.Remove(first.Cell.CellId);
            this.m_TotalLikelihood -= first.Likelihood;

            Debug.Assert(this.m_TotalLikelihood >= 0.0);
            return(first);
        }
示例#2
0
        public void AddRecord(GrowEventRecord record)
        {
            this.m_Map.Add(record.Cell.CellId, record);
            this.m_TotalLikelihood += record.Likelihood;

            Debug.Assert(MathUtils.CompareDoublesGTEqual(this.m_TotalLikelihood, record.Likelihood, 0.000001));
        }