Esempio n. 1
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);
        }
        private Dictionary <string, STSimDistributionValue> GetValueDictionary(STSimDistributionBase t)
        {
            Dictionary <string, STSimDistributionValue> l = null;

            if (!t.StratumId.HasValue && !t.SecondaryStratumId.HasValue)
            {
                l = this.m_1.GetItemExact(t.DistributionTypeId);
            }
            else if (t.StratumId.HasValue)
            {
                l = this.m_2.GetItemExact(t.DistributionTypeId, t.StratumId.Value);
            }
            else
            {
                l = this.m_3.GetItemExact(t.DistributionTypeId, t.SecondaryStratumId.Value);
            }

#if DEBUG
            if (l != null)
            {
                Debug.Assert(l.Count > 0);
            }
#endif

            return(l);
        }
 private static bool ExpansionRequired(STSimDistributionBase t)
 {
     if (!t.DistributionTypeId.HasValue)
     {
         return(false);
     }
     else if (t.StratumId.HasValue && t.SecondaryStratumId.HasValue)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        private IEnumerable <STSimDistributionBase> InternalExpand(IEnumerable <STSimDistributionBase> items)
        {
            Debug.Assert(items.Count() > 0);
            Debug.Assert(this.m_Provider.Values.Count > 0);

            if (this.m_Provider.Values.Count == 0 || items.Count() == 0)
            {
                return(items);
            }

            List <STSimDistributionBase> Expanded = new List <STSimDistributionBase>();

            foreach (STSimDistributionBase t in items)
            {
                if (!ExpansionRequired(t))
                {
                    Expanded.Add(t);
                    continue;
                }

                Dictionary <string, STSimDistributionValue> l = this.GetValueDictionary(t);

                if (l == null)
                {
                    Expanded.Add(t);
                    continue;
                }

                foreach (STSimDistributionValue v in l.Values)
                {
                    STSimDistributionBase n = t.Clone();

                    n.StratumId          = v.StratumId;
                    n.SecondaryStratumId = v.SecondaryStratumId;

                    Expanded.Add(n);
                }
            }

            Debug.Assert(Expanded.Count() >= items.Count());
            return(Expanded);
        }
Esempio n. 5
0
        public AttributeValueReference(
            int?tstGroupId,
            int?tstMin,
            int?tstMax,
            STSimDistributionBase classRef)
        {
            if (!tstGroupId.HasValue && !tstMin.HasValue && !tstMax.HasValue)
            {
                this.m_TSTGroupId = AttributeValueReference.TST_VALUE_NULL;
                this.m_TSTMin     = AttributeValueReference.TST_VALUE_NULL;
                this.m_TSTMax     = AttributeValueReference.TST_VALUE_NULL;
            }
            else
            {
                this.m_TSTGroupId = tstGroupId.HasValue ? tstGroupId.Value : AttributeValueReference.TST_GROUP_WILD;
                this.m_TSTMin     = tstMin.HasValue ? tstMin.Value : 0;
                this.m_TSTMax     = tstMax.HasValue ? tstMax.Value : int.MaxValue;
            }

            this.m_ClassRef = classRef;
            Debug.Assert(this.m_TSTMin <= this.m_TSTMax);
        }