Esempio n. 1
0
        /// <summary>
        /// Changes a simulation cell's Tst value for a probabilistic transition
        /// </summary>
        /// <param name="simulationCell">The simulation cell to change</param>
        /// <param name="tr">The probabilistic transition</param>
        /// <remarks></remarks>
        private void ChangeCellTstForProbabilisticTransition(Cell simulationCell, Transition tr)
        {
            if (simulationCell.TstValues.Count == 0)
            {
                return;
            }

            TransitionType tt = this.m_TransitionTypes[tr.TransitionTypeId];

            foreach (TransitionGroup tg in tt.TransitionGroups)
            {
                if (simulationCell.TstValues.Contains(tg.TransitionGroupId))
                {
                    Tst  celltst = simulationCell.TstValues[tg.TransitionGroupId];
                    long Value   = celltst.TstValue + tr.TstRelative;

                    if (Value > int.MaxValue)
                    {
                        celltst.TstValue = int.MaxValue;
                    }
                    else if (Value < 0)
                    {
                        celltst.TstValue = 0;
                    }
                    else
                    {
                        celltst.TstValue += tr.TstRelative;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Compares the simulation cell's Tst value to the transitions Tst min and max
        /// </summary>
        /// <param name="simulationCell">The simulation cell</param>
        /// <param name="tr">The transition</param>
        /// <returns>TRUE if the cell's Tst is in range and FALSE if not.</returns>
        /// <remarks></remarks>
        private bool CompareTstValues(Cell simulationCell, Transition tr)
        {
            //If the transition's Transition Type doesn't have an associated Transition Group in
            //Time-Since-Transition groups then return True.

            TstTransitionGroup tstgroup = this.m_TstTransitionGroupMap.GetGroup(
                tr.TransitionTypeId, simulationCell.StratumId,
                simulationCell.SecondaryStratumId, simulationCell.TertiaryStratumId);

            if (tstgroup == null)
            {
                return(true);
            }

            //Get the matching Tst for the simulation cell
            Tst cellTst = simulationCell.TstValues[tstgroup.TSTGroupId];

            //If the cell Tst value is within the Transition's TstMin and TstMax range then return TRUE
            if (cellTst.TstValue >= tr.TstMinimum && cellTst.TstValue <= tr.TstMaximum)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        private void InitTSTFromRamdomize(Cell simulationCell, int iteration)
        {
            if (!this.m_TstRandomizeMap.HasItems)
            {
                return;
            }

            foreach (TransitionGroup tg in this.TransitionGroups)
            {
                if (simulationCell.TstValues.Contains(tg.TransitionGroupId))
                {
                    TstRandomize TstRand = this.m_TstRandomizeMap.GetTstRandomize(
                        tg.TransitionGroupId, simulationCell.StratumId, simulationCell.SecondaryStratumId,
                        simulationCell.TertiaryStratumId, simulationCell.StateClassId, iteration);

                    if (TstRand != null)
                    {
                        int r       = this.m_RandomGenerator.GetNextInteger(TstRand.MinInitialTst, TstRand.MaxInitialTst);
                        Tst cellTst = simulationCell.TstValues[tg.TransitionGroupId];

                        cellTst.TstValue = r;
                    }
                }
            }
        }
Esempio n. 4
0
        private Tst GetTstWithSmallestValue(TstCollection cellTst)
        {
            Tst Smallest = null;

            foreach (Tst tst in cellTst)
            {
                if (this.m_TSTGroupHint.ContainsKey(tst.TransitionGroupId) ||
                    this.m_TSTGroupHint.ContainsKey(AttributeValueReference.TST_GROUP_WILD))
                {
                    if (Smallest == null)
                    {
                        Smallest = tst;
                    }
                    else
                    {
                        if (tst.TstValue < Smallest.TstValue)
                        {
                            Smallest = tst;
                        }
                    }
                }
            }

            return(Smallest);
        }
        private static TransitionMultiplierValue GetMultiplierCheckAgesAndTST(
            List <TransitionMultiplierValue> multipliers,
            Cell simulationCell)
        {
            foreach (TransitionMultiplierValue v in multipliers)
            {
                if (simulationCell.Age >= v.AgeMin && simulationCell.Age <= v.AgeMax)
                {
                    if (!v.TSTGroupId.HasValue)
                    {
                        return(v);
                    }

                    if (simulationCell.TstValues.Contains(v.TSTGroupId.Value))
                    {
                        Tst tst = simulationCell.TstValues[v.TSTGroupId.Value];

                        if (tst.TstValue >= v.TSTMin && tst.TstValue <= v.TSTMax)
                        {
                            return(v);
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 6
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);
        }