Inheritance: AgeCohort.ICohortDisturbance
コード例 #1
0
 //---------------------------------------------------------------------
 private void LogEvent(int currentTime,
                       Epidemic CurrentEvent,
                       int ROS)
 {
     log.Write("{0},{1},{2},{3},{4:0.0}",
               currentTime,
               ROS,
               CurrentEvent.CohortsKilled,
               CurrentEvent.TotalSitesDamaged,
               CurrentEvent.MeanSeverity);
     //foreach (IEcoregion ecoregion in Model.Ecoregions)
     //{
     //if(ecoregion.Active)
     //log.Write(",{0}", CurrentEvent.SitesInEvent[ecoregion.Index]);
     //}
     log.WriteLine("");
 }
コード例 #2
0
        //---------------------------------------------------------------------
        ///<summary>
        ///Simulate an Epidemic - This is the controlling function that calls the
        ///subsequent function.  The basic logic of an epidemic resides here.
        ///</summary>
        public static Epidemic Simulate(IAgent agent,
                                        int currentTime,
                                        int timestep,
                                        int ROS)
        {
            Epidemic CurrentEpidemic = new Epidemic(agent);

            UI.WriteLine("   New BDA Epidemic Activated:  {0}.", agent.AgentName);

            SiteResources.SiteResourceDominance(agent, ROS);
            SiteResources.SiteResourceDominanceModifier(agent);

            if (agent.Dispersal)
            {
                //Asynchronous - Simulate Agent Dispersal

                // Calculate Site Vulnerability without considering the Neighborhood
                // If neither disturbance modifiers nor ecoregion modifiers are active,
                //  Vulnerability will equal SiteReourceDominance.
                SiteResources.SiteVulnerability(agent, ROS, false);

                Epicenters.NewEpicenters(agent, timestep);
            }
            else
            {
                //Synchronous:  assume that all Active sites can potentially be
                //disturbed without regard to initial locations.
                foreach (ActiveSite site in Model.Core.Landscape)
                {
                    agent.OutbreakZone[site] = Zone.Newzone;
                }
            }

            //Consider the Neighborhood if requested:
            if (agent.NeighborFlag)
            {
                SiteResources.NeighborResourceDominance(agent);
            }

            //Recalculate Site Vulnerability considering neighbors if necessary:
            SiteResources.SiteVulnerability(agent, ROS, agent.NeighborFlag);

            CurrentEpidemic.DisturbSites(agent);

            return(CurrentEpidemic);
        }
コード例 #3
0
        //---------------------------------------------------------------------
        ///<summary>
        ///Simulate an Epidemic - This is the controlling function that calls the 
        ///subsequent function.  The basic logic of an epidemic resides here.
        ///</summary>
        public static Epidemic Simulate(IAgent agent, 
                                        int currentTime, 
                                        int timestep,
                                        int ROS)
        {


            Epidemic CurrentEpidemic = new Epidemic(agent);
            UI.WriteLine("   New BDA Epidemic Activated:  {0}.", agent.AgentName);

            SiteResources.SiteResourceDominance(agent, ROS);
            SiteResources.SiteResourceDominanceModifier(agent);

            if(agent.Dispersal) {
                //Asynchronous - Simulate Agent Dispersal
                
                // Calculate Site Vulnerability without considering the Neighborhood
                // If neither disturbance modifiers nor ecoregion modifiers are active,
                //  Vulnerability will equal SiteReourceDominance.
                SiteResources.SiteVulnerability(agent, ROS, false);  

                Epicenters.NewEpicenters(agent, timestep);
                
            } else 
            {
                //Synchronous:  assume that all Active sites can potentially be
                //disturbed without regard to initial locations.  
                foreach (ActiveSite site in Model.Core.Landscape) 
                    agent.OutbreakZone[site] = Zone.Newzone;

            }
            
            //Consider the Neighborhood if requested:
            if (agent.NeighborFlag)
                SiteResources.NeighborResourceDominance(agent);
                    
            //Recalculate Site Vulnerability considering neighbors if necessary:
            SiteResources.SiteVulnerability(agent, ROS, agent.NeighborFlag);

            CurrentEpidemic.DisturbSites(agent);

            return CurrentEpidemic;
        }
コード例 #4
0
 //---------------------------------------------------------------------
 private void LogEvent(int   currentTime,
                       Epidemic CurrentEvent,
                       int ROS)
 {
     log.Write("{0},{1},{2},{3},{4:0.0}",
               currentTime,
               ROS,
               CurrentEvent.CohortsKilled,
               CurrentEvent.TotalSitesDamaged,
               CurrentEvent.MeanSeverity);
     //foreach (IEcoregion ecoregion in Model.Ecoregions)
     //{
         //if(ecoregion.Active)
             //log.Write(",{0}", CurrentEvent.SitesInEvent[ecoregion.Index]);
     //}
     log.WriteLine("");
 }
コード例 #5
0
        //---------------------------------------------------------------------
        ///<summary>
        /// Run the BDA extension at a particular timestep.
        ///</summary>
        public override void Run()
        {
            UI.WriteLine("Processing landscape for BDA events ...");

            //SiteVars.Epidemic.SiteValues = null;

            int eventCount = 0;

            foreach (IAgent activeAgent in manyAgentParameters)
            {
                activeAgent.TimeSinceLastEpidemic += Timestep;
                //UI.WriteLine("TimeSince={0}, TimeToNext={1}", activeAgent.TimeSinceLastEpidemic, activeAgent.TimeToNextEpidemic);
                //(activeAgent.TimeSinceLastEpidemic+ activeAgent.TimeToNextEpidemic));

                int ROS = RegionalOutbreakStatus(activeAgent, Timestep);

                if (ROS > 0)
                {
                    Epidemic.Initialize(activeAgent);
                    Epidemic currentEpic = Epidemic.Simulate(activeAgent,
                                                             Model.Core.CurrentTime,
                                                             Timestep,
                                                             ROS);
                    //activeAgent.TimeSinceLastEpidemic = activeAgent.TimeSinceLastEpidemic + Timestep;

                    if (currentEpic != null)
                    {
                        LogEvent(Model.Core.CurrentTime, currentEpic, ROS);

                        //----- Write BDA severity maps --------
                        IOutputRaster <SeverityPixel> map = CreateMap(Model.Core.CurrentTime, activeAgent.AgentName);
                        using (map) {
                            SeverityPixel pixel = new SeverityPixel();
                            foreach (Site site in Model.Core.Landscape.AllSites)
                            {
                                if (site.IsActive)
                                {
                                    if (SiteVars.Disturbed[site])
                                    {
                                        pixel.Band0 = (byte)(activeAgent.Severity[site] + 1);
                                    }
                                    else
                                    {
                                        pixel.Band0 = 1;
                                    }
                                }
                                else
                                {
                                    //  Inactive site
                                    pixel.Band0 = 0;
                                }
                                map.WritePixel(pixel);
                            }
                        }
                        if (!(srdMapNames == ""))
                        {
                            //----- Write BDA SRD maps --------
                            IOutputRaster <UShortPixel> srdmap = CreateSRDMap(Model.Core.CurrentTime, activeAgent.AgentName);
                            using (srdmap)
                            {
                                UShortPixel pixel = new UShortPixel();
                                foreach (Site site in Model.Core.Landscape.AllSites)
                                {
                                    if (site.IsActive)
                                    {
                                        pixel.Band0 = (ushort)System.Math.Round(SiteVars.SiteResourceDom[site] * 100.00);
                                    }
                                    else
                                    {
                                        //  Inactive site
                                        pixel.Band0 = 0;
                                    }
                                    srdmap.WritePixel(pixel);
                                }
                            }
                        }
                        if (!(nrdMapNames == ""))
                        {
                            //----- Write BDA NRD maps --------
                            IOutputRaster <UShortPixel> nrdmap = CreateNRDMap(Model.Core.CurrentTime, activeAgent.AgentName);
                            using (nrdmap)
                            {
                                UShortPixel pixel = new UShortPixel();
                                foreach (Site site in Model.Core.Landscape.AllSites)
                                {
                                    if (site.IsActive)
                                    {
                                        pixel.Band0 = (ushort)System.Math.Round(SiteVars.NeighborResourceDom[site] * 100.00);
                                    }
                                    else
                                    {
                                        //  Inactive site
                                        pixel.Band0 = 0;
                                    }
                                    nrdmap.WritePixel(pixel);
                                }
                            }
                        }

                        //----- Write Site Vulnerability or OutbreakZone maps --------
                        //----- USED FOR LANDSCAPE TESTING -----------

                        /*IOutputRaster<UShortPixel> dmap = CreateUShortMap(Model.Core.CurrentTimestep, activeAgent.AgentName);
                         * using (dmap) {
                         *  UShortPixel pixel = new UShortPixel();
                         *  foreach (Site site in Model.Core.Landscape.AllSites) {
                         *      if (site.IsActive) {
                         *          //pixel.Band0 = (ushort) (activeAgent.OutbreakZone[site]);
                         *          pixel.Band0 = (ushort) (SiteVars.Vulnerability[site] * 100);
                         *      }
                         *      else {
                         *          //  Inactive site
                         *          pixel.Band0 = 0;
                         *      }
                         *      dmap.WritePixel(pixel);
                         *  }
                         * }*/

                        /*IOutputRaster<UShortPixel> nmap = CreateUShortMap2(Model.Core.CurrentTimestep, activeAgent.AgentName);
                         * using (nmap) {
                         *  UShortPixel pixel = new UShortPixel();
                         *  foreach (Site site in Model.Landscape.AllSites) {
                         *      if (site.IsActive) {
                         *          //pixel.Band0 = (ushort) (activeAgent.OutbreakZone[site]);
                         *          pixel.Band0 = (ushort) System.Math.Round(SiteVars.NeighborResourceDom[site] * 100.00);
                         *      }
                         *      else {
                         *          //  Inactive site
                         *          pixel.Band0 = 0;
                         *      }
                         *      nmap.WritePixel(pixel);
                         *  }
                         * }*/

                        eventCount++;
                    }
                }
            }
        }