예제 #1
0
        private void AddReferenceWithTST(AttributeValueReference attrRef)
        {
            Debug.Assert(attrRef.TSTGroupId != AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMin != AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMax != AttributeValueReference.TST_VALUE_NULL);

            string k = CreateRefKey(attrRef.TSTGroupId, attrRef.TSTMin, attrRef.TSTMax);

            if (this.m_RefWithTSTSeenBefore.ContainsKey(k))
            {
                string s = string.Format(CultureInfo.InvariantCulture,
                                         "An attribute with the TST values {0}-{1} has already been added to the age bin {2}-{3}:",
                                         attrRef.TSTMin,
                                         attrRef.TSTMax == int.MaxValue ? "NULL" : attrRef.TSTMax.ToString(),
                                         this.m_AgeMin,
                                         this.m_AgeMax == int.MaxValue ? "NULL" : this.m_AgeMax.ToString());

                throw new STSimMapDuplicateItemException(s);
            }

            this.m_RefsWithTST.Add(attrRef);
            this.m_RefWithTSTSeenBefore.Add(k, true);

            if (!this.m_TSTGroupHint.ContainsKey(attrRef.TSTGroupId))
            {
                this.m_TSTGroupHint.Add(attrRef.TSTGroupId, true);
            }
        }
예제 #2
0
        public double?GetAttributeValue(
            int stateAttributeTypeId, int stratumId, int?secondaryStratumId, int?tertiaryStratumId,
            int stateClassId, int iteration, int timestep, int age, TstCollection cellTst)
        {
            AttributeValueAgeBinCollection AgeBins = this.GetItem(
                stateAttributeTypeId, stratumId, secondaryStratumId, tertiaryStratumId,
                stateClassId, iteration, timestep);

            if (AgeBins == null)
            {
                return(null);
            }

            AttributeValueAgeBin Bin = AgeBins.GetAgeBin(age);

            if (Bin == null)
            {
                return(null);
            }

            AttributeValueReference AttrRef = Bin.GetReference(cellTst);

            if (AttrRef == null)
            {
                return(null);
            }

            STSimDistributionBase b = AttrRef.ClassRef;

            b.Sample(iteration, timestep, this.m_DistributionProvider, StochasticTime.DistributionFrequency.Always);

            return(b.CurrentValue.Value);
        }
예제 #3
0
        public AttributeValueReference GetReference(TstCollection cellTst)
        {
            AttributeValueReference AttrRef = this.GetReferenceWithTST(cellTst);

            if (AttrRef == null)
            {
                AttrRef = this.GetReferenceWithoutTST();
            }

            return(AttrRef);
        }
예제 #4
0
        public void AddReference(AttributeValueReference attrRef)
        {
            if (attrRef.TSTGroupId == AttributeValueReference.TST_VALUE_NULL)
            {
                this.AddReferenceWithoutTST(attrRef);
            }
            else
            {
                this.AddReferenceWithTST(attrRef);
            }

            Debug.Assert(!this.m_TSTGroupHint.ContainsKey(AttributeValueReference.TST_VALUE_NULL));
        }
예제 #5
0
        private void AddReferenceWithoutTST(AttributeValueReference attrRef)
        {
            Debug.Assert(attrRef.TSTGroupId == AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMin == AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMax == AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(this.m_RefsWithoutTST.Count <= 1);

            if (this.m_RefsWithoutTST.Count == 1)
            {
                throw new STSimMapDuplicateItemException("A duplicate attribute value has been created.");
            }

            this.m_RefsWithoutTST.Add(attrRef);
        }
예제 #6
0
        private void AddReferenceWithoutTST(AttributeValueReference attrRef)
        {
            Debug.Assert(attrRef.TSTGroupId == AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMin == AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMax == AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(this.m_RefsWithoutTST.Count <= 1);

            if (this.m_RefsWithoutTST.Count == 1)
            {
                string s = string.Format(CultureInfo.InvariantCulture,
                                         "An attribute with no TST values has already been added to the age bin {0}-{1}",
                                         this.m_AgeMin,
                                         this.m_AgeMax == int.MaxValue ? "NULL" : this.m_AgeMax.ToString());

                throw new STSimMapDuplicateItemException(s);
            }

            this.m_RefsWithoutTST.Add(attrRef);
        }
예제 #7
0
        private AttributeValueReference GetReferenceWithTST(TstCollection cellTst)
        {
            if (this.m_RefsWithTST.Count == 0 || cellTst.Count == 0)
            {
                return(null);
            }

            Tst tst = this.GetTstWithSmallestValue(cellTst);

            if (!this.m_TSTGroupHint.ContainsKey(tst.TransitionGroupId) &&
                !this.m_TSTGroupHint.ContainsKey(AttributeValueReference.TST_GROUP_WILD))
            {
                return(null);
            }

            AttributeValueReference FinalRef = null;

            foreach (AttributeValueReference attrRef in this.m_RefsWithTST)
            {
                if (attrRef.TSTGroupId != tst.TransitionGroupId &&
                    attrRef.TSTGroupId != AttributeValueReference.TST_GROUP_WILD)
                {
                    continue;
                }

                if (tst.TstValue >= attrRef.TSTMin && tst.TstValue <= attrRef.TSTMax)
                {
                    if (FinalRef == null)
                    {
                        FinalRef = attrRef;
                        continue;
                    }

                    if (attrRef.TSTMin > FinalRef.TSTMin)
                    {
                        FinalRef = attrRef;
                    }
                }
            }

            return(FinalRef);
        }
예제 #8
0
        private void AddReferenceWithTST(AttributeValueReference attrRef)
        {
            Debug.Assert(attrRef.TSTGroupId != AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMin != AttributeValueReference.TST_VALUE_NULL);
            Debug.Assert(attrRef.TSTMax != AttributeValueReference.TST_VALUE_NULL);

            string k = CreateRefKey(attrRef.TSTGroupId, attrRef.TSTMin, attrRef.TSTMax);

            if (this.m_RefWithTSTSeenBefore.ContainsKey(k))
            {
                throw new STSimMapDuplicateItemException("A duplicate attribute value has been created.");
            }

            this.m_RefsWithTST.Add(attrRef);
            this.m_RefWithTSTSeenBefore.Add(k, true);

            if (!this.m_TSTGroupHint.ContainsKey(attrRef.TSTGroupId))
            {
                this.m_TSTGroupHint.Add(attrRef.TSTGroupId, true);
            }
        }