Site Variables for a disturbance plug-in that simulates Biological Agents.
コード例 #1
0
        //---------------------------------------------------------------------


        /// <summary>
        /// Initializes the extension with a data file.
        /// </summary>
        public override void Initialize()
        {
            Timestep        = parameters.Timestep;
            mapNameTemplate = parameters.MapNamesTemplate;
            srdMapNames     = parameters.SRDMapNames;
            nrdMapNames     = parameters.NRDMapNames;
            vulnMapNames    = parameters.VulnMapNames;

            SiteVars.Initialize(modelCore);

            manyAgentParameters = parameters.ManyAgentParameters;
            foreach (IAgent activeAgent in manyAgentParameters)
            {
                if (activeAgent == null)
                {
                    PlugIn.ModelCore.Log.WriteLine("Agent Parameters NOT loading correctly.");
                }
                activeAgent.TimeToNextEpidemic = TimeToNext(activeAgent, Timestep);
                int timeOfNext = PlugIn.ModelCore.CurrentTime + activeAgent.TimeToNextEpidemic - activeAgent.TimeSinceLastEpidemic;
                if (timeOfNext < Timestep)
                {
                    timeOfNext = Timestep;
                }
                SiteVars.TimeOfNext.ActiveSiteValues = timeOfNext;

                int i = 0;

                activeAgent.DispersalNeighbors
                    = GetDispersalNeighborhood(activeAgent, Timestep);
                if (activeAgent.DispersalNeighbors != null)
                {
                    foreach (RelativeLocation reloc in activeAgent.DispersalNeighbors)
                    {
                        i++;
                    }
                    PlugIn.ModelCore.Log.WriteLine("Dispersal Neighborhood = {0} neighbors.", i);
                }

                i = 0;
                activeAgent.ResourceNeighbors = GetResourceNeighborhood(activeAgent);
                if (activeAgent.ResourceNeighbors != null)
                {
                    foreach (RelativeLocationWeighted reloc in activeAgent.ResourceNeighbors)
                    {
                        i++;
                    }
                    PlugIn.ModelCore.Log.WriteLine("Resource Neighborhood = {0} neighbors.", i);
                }
            }

            string logFileName = parameters.LogFileName;

            PlugIn.ModelCore.Log.WriteLine("Opening BDA log file \"{0}\" ...", logFileName);
            log           = PlugIn.ModelCore.CreateTextFile(logFileName);
            log.AutoFlush = true;
            log.Write("CurrentTime, ROS, AgentName, NumCohortsKilled, NumSitesDamaged, MeanSeverity");
            log.WriteLine("");
        }
コード例 #2
0
 public new void InitializePhase2()
 {
     SiteVars.InitializeTimeOfLastDisturbances();
 }