Site Variables for a disturbance plug-in that simulates Biological Agents.
Exemplo n.º 1
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Initializes the extension with a data file.
        /// </summary>
        public override void Initialize(string dataFile,
                                        PlugIns.ICore modelCore)
        {
            Model.Core = modelCore;

            InputParameterParser.EcoregionsDataset = Model.Core.Ecoregions;
            InputParameterParser parser     = new InputParameterParser();
            IInputParameters     parameters = Data.Load <IInputParameters>(dataFile, parser);

            Timestep        = parameters.Timestep;
            mapNameTemplate = parameters.MapNamesTemplate;
            srdMapNames     = parameters.SRDMapNames;
            nrdMapNames     = parameters.NRDMapNames;

            cohorts = Model.Core.SuccessionCohorts as ILandscapeCohorts;
            if (cohorts == null)
            {
                throw new ApplicationException("Error: Cohorts don't support age-cohort interface");
            }

            SiteVars.Initialize(cohorts);

            manyAgentParameters = parameters.ManyAgentParameters;
            foreach (IAgent activeAgent in manyAgentParameters)
            //   UI.WriteLine("Parameters did not load successfully.");

            {
                //foreach (ISpecies spp in Model.Species)
                //    UI.WriteLine("Spp={0}, MinorHostAge={1}.", spp.Name, activeAgent.SppParameters[spp.Index].SecondaryHostAge);

                if (activeAgent == null)
                {
                    UI.WriteLine("Agent Parameters NOT loading correctly.");
                }
                //UI.WriteLine("Name of Agent = {0}", activeAgent.AgentName);
                activeAgent.TimeToNextEpidemic = TimeToNext(activeAgent, Timestep);

                int i = 0;

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

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

            string logFileName = parameters.LogFileName;

            UI.WriteLine("Opening BDA log file \"{0}\" ...", logFileName);
            log           = Data.CreateTextFile(logFileName);
            log.AutoFlush = true;
            log.Write("CurrentTime, ROS, NumCohortsKilled, NumSitesDamaged, MeanSeverity");
            log.WriteLine("");
        }
Exemplo n.º 2
0
 public void InitializePhase2() //InitializePhase2
 {
     SiteVars.InitializeTimeOfLastDisturbances();
 }