Пример #1
0
 internal CellChangeEventArgs(
     Cell simulationCell, int iteration, int timestep, DeterministicTransition deterministicPathway,
     Transition probabilisticPathway) : base(simulationCell, iteration, timestep)
 {
     this.m_DeterministicPathway = deterministicPathway;
     this.m_ProbabilisticPathway = probabilisticPathway;
 }
Пример #2
0
        private static DeterministicTransitionClipData DTToClipFormat(DeterministicTransition dt, DataSheet stratumSheet, DataSheet stateClassSheet)
        {
            Debug.Assert(stratumSheet.Name == Strings.DATASHEET_STRATA_NAME);
            Debug.Assert(stateClassSheet.Name == Strings.DATASHEET_STATECLASS_NAME);

            DeterministicTransitionClipData cd = new DeterministicTransitionClipData();

            if (dt.StratumIdSource.HasValue)
            {
                cd.StratumSource = stratumSheet.ValidationTable.GetDisplayName(dt.StratumIdSource.Value);
            }

            cd.StateClassSource = stateClassSheet.ValidationTable.GetDisplayName(dt.StateClassIdSource);

            if (dt.StratumIdDestination.HasValue)
            {
                cd.StratumDest = stratumSheet.ValidationTable.GetDisplayName(dt.StratumIdDestination.Value);
            }

            if (cd.StateClassIdDest.HasValue)
            {
                cd.StateClassDest = stateClassSheet.ValidationTable.GetDisplayName(dt.StateClassIdDestination.Value);
            }

            return(cd);
        }
Пример #3
0
        private int InternalDetermineTargetAgeProbabilistic(int currentCellAge, int?destinationStratumId, int destinationStateClassId, int iteration, int timestep, Transition transition)
        {
            DeterministicTransition dt = this.GetDeterministicTransition(destinationStratumId, destinationStateClassId, iteration, timestep);

            int AgeMin = 0;
            int AgeMax = 0;

            if (dt == null)
            {
                AgeMin = 0;
                AgeMax = int.MaxValue;
            }
            else
            {
                AgeMin = dt.AgeMinimum;
                AgeMax = dt.AgeMaximum;
            }

            int NewAge = 0;

            if (!(transition.AgeReset))
            {
                int TargetSimCellAge = (currentCellAge + transition.AgeRelative);

                if (TargetSimCellAge < AgeMin)
                {
                    NewAge = AgeMin;
                }
                else if (TargetSimCellAge > AgeMax)
                {
                    NewAge = AgeMax;
                }
                else
                {
                    NewAge = TargetSimCellAge;
                }
            }
            else
            {
                int TargetSimCellAge = Math.Max(AgeMin, AgeMin + transition.AgeRelative);

                if (TargetSimCellAge > AgeMax)
                {
                    TargetSimCellAge = AgeMax;
                }

                NewAge = TargetSimCellAge;
            }

            if (NewAge < 0)
            {
                NewAge = 0;
            }

            return(NewAge);
        }
Пример #4
0
        private static DeterministicTransition CreateDT(DataRow dr)
        {
            int?Iteration          = null;
            int?Timestep           = null;
            int?StratumIdSource    = null;
            int StateClassIdSource = Convert.ToInt32(dr[Strings.DATASHEET_DT_STATECLASSIDSOURCE_COLUMN_NAME], CultureInfo.InvariantCulture);
            int?StratumIdDest      = null;
            int?StateClassIdDest   = null;
            int AgeMinimum         = 0;
            int AgeMaximum         = int.MaxValue;

            if (dr[Strings.DATASHEET_ITERATION_COLUMN_NAME] != DBNull.Value)
            {
                Iteration = Convert.ToInt32(dr[Strings.DATASHEET_ITERATION_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            if (dr[Strings.DATASHEET_TIMESTEP_COLUMN_NAME] != DBNull.Value)
            {
                Timestep = Convert.ToInt32(dr[Strings.DATASHEET_TIMESTEP_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            if (dr[Strings.DATASHEET_DT_STRATUMIDSOURCE_COLUMN_NAME] != DBNull.Value)
            {
                StratumIdSource = Convert.ToInt32(dr[Strings.DATASHEET_DT_STRATUMIDSOURCE_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            if (dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME] != DBNull.Value)
            {
                StratumIdDest = Convert.ToInt32(dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            if (dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME] != DBNull.Value)
            {
                StateClassIdDest = Convert.ToInt32(dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            if (dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME] != DBNull.Value)
            {
                AgeMinimum = Convert.ToInt32(dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            if (dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME] != DBNull.Value)
            {
                AgeMaximum = Convert.ToInt32(dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME], CultureInfo.InvariantCulture);
            }

            DeterministicTransition dt = new DeterministicTransition(
                Iteration, Timestep, StratumIdSource, StateClassIdSource,
                StratumIdDest, StateClassIdDest, AgeMinimum, AgeMaximum);

            return(dt);
        }
Пример #5
0
        /// <summary>
        /// Validates that the specified cell has been initialized correctly
        /// </summary>
        /// <param name="c"></param>
        /// <remarks></remarks>
        private void VALIDATE_INITIALIZED_CELL(Cell c, int iteration, int timestep)
        {
            //Make sure the ages are within the correct initial ranges
            DeterministicTransition dt = this.GetDeterministicTransition(c, iteration, timestep);

            if (dt != null)
            {
                Debug.Assert(c.Age >= dt.AgeMinimum);
                Debug.Assert(c.Age <= dt.AgeMaximum);
            }

            Debug.Assert(c.Age >= 0);
        }
Пример #6
0
        private void InitializeCellAge(Cell simulationCell, int stratumId, int stateClassId, int minimumAge, int maximumAge, int iteration, int timestep)
        {
            DeterministicTransition dt = null;

            if (this.m_DeterministicTransitionMap != null)
            {
                dt = this.GetDeterministicTransition(stratumId, stateClassId, iteration, timestep);
            }

            Debug.Assert(minimumAge != int.MaxValue);

            if (dt == null)
            {
                if (maximumAge == int.MaxValue)
                {
                    simulationCell.Age = minimumAge;
                }
                else
                {
                    simulationCell.Age = this.m_RandomGenerator.GetNextInteger(minimumAge, maximumAge + 1);
                }
            }
            else
            {
                int AgeMinOut = 0;
                int AgeMaxOut = 0;

                GetAgeMinMax(dt, minimumAge, maximumAge, ref AgeMinOut, ref AgeMaxOut);

                if (AgeMaxOut == int.MaxValue)
                {
                    simulationCell.Age = AgeMinOut;
                }
                else
                {
                    simulationCell.Age = this.m_RandomGenerator.GetNextInteger(AgeMinOut, AgeMaxOut + 1);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Gets the age min and age max for the specified deterministic transition and age values
        /// </summary>
        /// <param name="dt">The deterministic transition</param>
        /// <param name="ageMinIn">The minimum age IN value</param>
        /// <param name="ageMaxIn">The maximum age IN value</param>
        /// <param name="ageMinOut">The minimum age OUT value</param>
        /// <param name="ageMaxOut">The maximum age OUT value</param>
        /// <remarks></remarks>
        internal static void GetAgeMinMax(DeterministicTransition dt, int ageMinIn, int ageMaxIn, ref int ageMinOut, ref int ageMaxOut)
        {
            //Normalize
            int dtagemin = Math.Min(dt.AgeMinimum, dt.AgeMaximum);
            int dtagemax = Math.Max(dt.AgeMinimum, dt.AgeMaximum);

            //This should already be normalized
            Debug.Assert(ageMinIn <= ageMaxIn);

            //If any age value is outside of the dt value, set the age value equal to the nearest dt value.
            //For example, if ageMinIn > dt.agemax the set ageMinIn = dt.agemax.

            if (ageMinIn < dtagemin)
            {
                ageMinIn = dtagemin;
            }

            if (ageMaxIn < dtagemin)
            {
                ageMaxIn = dtagemin;
            }

            if (ageMinIn > dtagemax)
            {
                ageMinIn = dtagemax;
            }

            if (ageMaxIn > dtagemax)
            {
                ageMaxIn = dtagemax;
            }

            ageMinOut = ageMinIn;
            ageMaxOut = ageMaxIn;

            Debug.Assert(ageMinOut <= ageMaxOut);
        }