Example #1
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Objects and Lists must be initialized.
        /// </summary>
        public Agent(int sppCount, int ecoCount)
        {
            SppParameters = new ISppParameters[sppCount];
            EcoParameters = new IEcoParameters[ecoCount];
            //DistParameters = new IDistParameters[distCount];
            disturbanceTypes = new List <IDisturbanceType>();
            negSppList       = new List <ISpecies>();
            //advRegenSppList = new List<ISpecies>();
            dispersalNeighbors = new List <RelativeLocation>();
            resourceNeighbors  = new List <RelativeLocationWeighted>();
            severity           = PlugIn.ModelCore.Landscape.NewSiteVar <byte>();
            outbreakZone       = PlugIn.ModelCore.Landscape.NewSiteVar <Zone>();
            climateDataTable   = new DataTable();

            for (int i = 0; i < sppCount; i++)
            {
                SppParameters[i] = new SppParameters();
            }
            for (int i = 0; i < ecoCount; i++)
            {
                EcoParameters[i] = new EcoParameters();
            }
            //for (int i = 0; i < distCount; i++)
            //   DistParameters[i] = new DistParameters();
        }
Example #2
0
        //---------------------------------------------------------------------
        // DamageCohort is a filter to determine which cohorts are removed.
        // Each cohort is passed into the function and tested whether it should
        // be killed.
        bool ICohortDisturbance.MarkCohortForDeath(ICohort cohort)
        {
            //PlugIn.ModelCore.Log.WriteLine("Cohort={0}, {1}, {2}.", cohort.Species.Name, cohort.Age, cohort.Species.Index);

            bool killCohort = false;
            bool BF         = false;

            ISppParameters sppParms = epidemicParms.SppParameters[cohort.Species.Index];

            string mySpecies = cohort.Species.Name;

            if (mySpecies == "abiebals")
            {
                BF = true;
            }

            if (BF && cohort.Age > this.bfAgeCutoff)
            {
                killCohort = true;
            }
            else
            {
                if (cohort.Age >= sppParms.ResistantHostAge)
                {
                    if (this.random <= this.siteVulnerability * sppParms.ResistantHostVuln)
                    {
                        killCohort = true;
                    }
                }

                if (cohort.Age >= sppParms.TolerantHostAge)
                {
                    if (this.random <= this.siteVulnerability * sppParms.TolerantHostVuln)
                    {
                        killCohort = true;
                    }
                }

                if (cohort.Age >= sppParms.VulnerableHostAge)
                {
                    if (this.random <= this.siteVulnerability * sppParms.VulnerableHostVuln)
                    {
                        killCohort = true;
                    }
                }
            }

            if (killCohort)
            {
                this.siteCohortsKilled++;
                if (sppParms.CFSConifer)
                {
                    this.siteCFSconifersKilled++;
                }
            }

            return(killCohort);
        }
Example #3
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Objects and Lists must be initialized.
        /// </summary>
        public Agent(int sppCount, int ecoCount, int distCount)
        {
            SppParameters      = new ISppParameters[sppCount];
            EcoParameters      = new IEcoParameters[ecoCount];
            DistParameters     = new IDistParameters[distCount];
            negSppList         = new List <ISpecies>();
            dispersalNeighbors = new List <RelativeLocation>();
            resourceNeighbors  = new List <RelativeLocationWeighted>();
            severity           = Model.Core.Landscape.NewSiteVar <byte>();
            outbreakZone       = Model.Core.Landscape.NewSiteVar <Zone>();

            for (int i = 0; i < sppCount; i++)
            {
                SppParameters[i] = new SppParameters();
            }
        }
Example #4
0
        //---------------------------------------------------------------------
        // This is a filter to determine which cohorts are removed.
        // Each cohort is passed into the function and tested whether it should
        // be killed.
        bool ICohortDisturbance.MarkCohortForDeath(ICohort cohort)
        {
            bool killCohort = false;

            ISppParameters sppParms = epidemicParms.SppParameters[cohort.Species.Index];

            if (cohort.Age >= sppParms.LowVulnHostAge)
            {
                if (random <= sppParms.LowVulnHostMortProb)
                {
                    killCohort = true;
                }
            }

            if (cohort.Age >= sppParms.MediumVulnHostAge)
            {
                if (random <= sppParms.MediumVulnHostMortProb)
                {
                    killCohort = true;
                }
            }

            if (cohort.Age >= sppParms.HighVulnHostAge)
            {
                if (random <= sppParms.HighVulnHostMortProb)
                {
                    killCohort = true;
                }
            }

            if (killCohort)
            {
                siteCohortsKilled++;

                if (sppParms.CFSConifer)
                {
                    siteCFSconifersKilled++;
                }

                if (sppParms.MortSppFlag)
                {
                    siteMortSppKilled++;
                }
            }

            return(killCohort);
        }
Example #5
0
        //---------------------------------------------------------------------
        // DamageCohort is a filter to determine which cohorts are removed.
        // Each cohort is passed into the function and tested whether it should
        // be killed.
        bool AgeCohort.ICohortDisturbance.Damage(AgeCohort.ICohort cohort)
        {
            bool killCohort = false;

            ISppParameters sppParms = epidemicParms.SppParameters[cohort.Species.Index];

            if (sppParms == null)
            {
                return(killCohort);
            }


            if (this.siteSeverity == 1)
            {
                if (cohort.Age >= sppParms.VulnerableHostAge)
                {
                    killCohort = true;
                }
            }
            if (this.siteSeverity == 2)
            {
                if (cohort.Age >= sppParms.TolerantHostAge)
                {
                    killCohort = true;
                }
            }
            if (this.siteSeverity == 3)
            {
                if (cohort.Age >= sppParms.ResistantHostAge)
                {
                    killCohort = true;
                }
            }

            if (killCohort)
            {
                this.siteCohortsKilled++;
                if (sppParms.CFSConifer)
                {
                    this.siteCFSconifersKilled++;
                }
            }

            return(killCohort);
        }
Example #6
0
        //---------------------------------------------------------------------
        // DamageCohort is a filter to determine which cohorts are removed.
        // Each cohort is passed into the function and tested whether it should
        // be killed.
        bool ICohortDisturbance.MarkCohortForDeath(ICohort cohort)
        {
            //PlugIn.ModelCore.UI.WriteLine("Cohort={0}, {1}, {2}.", cohort.Species.Name, cohort.Age, cohort.Species.Index);

            bool killCohort = false;

            ISppParameters sppParms = epidemicParms.SppParameters[cohort.Species.Index];

            if (this.siteSeverity == 1)
            {
                if (cohort.Age >= sppParms.VulnerableHostAge)
                {
                    killCohort = true;
                }
            }
            if (this.siteSeverity == 2)
            {
                if (cohort.Age >= sppParms.TolerantHostAge)
                {
                    killCohort = true;
                }
            }
            if (this.siteSeverity == 3)
            {
                if (cohort.Age >= sppParms.ResistantHostAge)
                {
                    killCohort = true;
                }
            }

            if (killCohort)
            {
                this.siteCohortsKilled++;
                if (sppParms.CFSConifer)
                {
                    this.siteCFSconifersKilled++;
                }
            }

            return(killCohort);
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// Objects and Lists must be initialized.
        /// </summary>
        public AgentParameters(int sppCount, int ecoCount)
        {
            SppParameters         = new ISppParameters[sppCount];
            EcoParameters         = new IEcoParameters[ecoCount];
            EcoWeatherIndexNormal = new double[ecoCount];
            disturbanceTypes      = new List <IDisturbanceType>();
            negSppList            = new List <ISpecies>();
            climateVarDefn        = new List <IClimateVariableDefinition>();
            derivedClimateVars    = new List <IDerivedClimateVariable>();
            weatherIndexVars      = new List <string>();
            climateDataTable      = new DataTable();

            for (int i = 0; i < sppCount; i++)
            {
                SppParameters[i] = new SppParameters();
            }
            for (int i = 0; i < ecoCount; i++)
            {
                EcoParameters[i] = new EcoParameters();
            }
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// Objects and Lists must be initialized.
        /// </summary>
        public Agent(int sppCount, int ecoCount)
        {
            SppParameters = new ISppParameters[sppCount];
            EcoParameters = new IEcoParameters[ecoCount];
            //DistParameters = new IDistParameters[distCount];
            disturbanceTypes = new List<IDisturbanceType>();
            negSppList = new List<ISpecies>();
            //advRegenSppList = new List<ISpecies>();
            dispersalNeighbors = new List<RelativeLocation>();
            resourceNeighbors = new List<RelativeLocationWeighted>();
            severity       = PlugIn.ModelCore.Landscape.NewSiteVar<byte>();
            outbreakZone   = PlugIn.ModelCore.Landscape.NewSiteVar<Zone>();

            for (int i = 0; i < sppCount; i++)
                SppParameters[i] = new SppParameters();
            for (int i = 0; i < ecoCount; i++)
                EcoParameters[i] = new EcoParameters();
            //for (int i = 0; i < distCount; i++)
            //   DistParameters[i] = new DistParameters();
        }
        //---------------------------------------------------------------------
        ///<summary>
        ///Calculate the Site Resource Dominance (SRD) for all active sites.
        ///The SRD averages the resources for each species as defined in the
        ///BDA species table.
        ///SRD ranges from 0 - 1.
        ///</summary>
        //---------------------------------------------------------------------
        public static void SiteResourceDominance(IAgent agent, int ROS)
        {
            PlugIn.ModelCore.UI.WriteLine("   Calculating BDA Site Resource Dominance.");

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                double sumValue         = 0.0;
                double maxValue         = 0.0;
                int    ageOldestCohort  = 0;
                int    numValidSpp      = 0;
                double speciesHostValue = 0;

                foreach (ISpecies species in PlugIn.ModelCore.Species)
                {
                    ageOldestCohort = Util.GetMaxAge(SiteVars.Cohorts[site][species]);
                    ISppParameters sppParms = agent.SppParameters[species.Index];
                    if (sppParms == null)
                    {
                        continue;
                    }

                    bool negList = false;
                    foreach (ISpecies negSpp in agent.NegSppList)
                    {
                        if (species == negSpp)
                        {
                            negList = true;
                        }
                    }

                    if ((ageOldestCohort > 0) && (!negList))
                    {
                        numValidSpp++;
                        speciesHostValue = 0.0;

                        if (ageOldestCohort >= sppParms.MinorHostAge)
                        {
                            //speciesHostValue = 0.33;
                            speciesHostValue = sppParms.MinorHostSRD;
                        }

                        if (ageOldestCohort >= sppParms.SecondaryHostAge)
                        {
                            //speciesHostValue = 0.66;
                            speciesHostValue = sppParms.SecondaryHostSRD;
                        }

                        if (ageOldestCohort >= sppParms.PrimaryHostAge)
                        {
                            //speciesHostValue = 1.0;
                            speciesHostValue = sppParms.PrimaryHostSRD;
                        }


                        sumValue += speciesHostValue;
                        maxValue  = System.Math.Max(maxValue, speciesHostValue);
                    }
                }

                if (agent.SRDmode == SRDmode.mean)
                {
                    SiteVars.SiteResourceDom[site] = sumValue / (double)numValidSpp;
                }

                if (agent.SRDmode == SRDmode.max)
                {
                    SiteVars.SiteResourceDom[site] = maxValue;
                }
            }
        }  //end siteResourceDom
        //---------------------------------------------------------------------
        /// <summary>
        /// Objects and Lists must be initialized.
        /// </summary>
        public Agent(int sppCount, int ecoCount, int distCount)
        {
            SppParameters = new ISppParameters[sppCount];
            EcoParameters = new IEcoParameters[ecoCount];
            DistParameters = new IDistParameters[distCount];
            negSppList = new List<ISpecies>();
            dispersalNeighbors = new List<RelativeLocation>();
            resourceNeighbors = new List<RelativeLocationWeighted>();
            severity       = Model.Core.Landscape.NewSiteVar<byte>();
            outbreakZone   = Model.Core.Landscape.NewSiteVar<Zone>();

            for(int i=0; i<sppCount; i++)
                SppParameters[i] = new SppParameters();
        }
Example #11
0
        //---------------------------------------------------------------------
        // DamageCohort is a filter to determine which cohorts are removed.
        // Each cohort is passed into the function and tested whether it should
        // be killed.
        bool ICohortDisturbance.MarkCohortForDeath(ICohort cohort)
        {
            //PlugIn.ModelCore.Log.WriteLine("Cohort={0}, {1}, {2}.", cohort.Species.Name, cohort.Age, cohort.Species.Index);

            bool killCohort = false;
            // bool advRegenSpp = false;

            ISppParameters sppParms = epidemicParms.SppParameters[cohort.Species.Index];

            //foreach (ISpecies mySpecies in epidemicParms.AdvRegenSppList)
            //{
            //   if (cohort.Species == mySpecies)
            //   {
            //        advRegenSpp = true;
            //        break;
            //    }

            //}

            if (cohort.Age >= sppParms.ResistantHostAge)
            {
                if (this.random <= this.siteVulnerability * sppParms.ResistantHostVuln)
                {
                    //if (advRegenSpp && cohort.Age <= this.advRegenAgeCutoff)
                    //    killCohort = false;
                    //else
                    killCohort = true;
                }
            }

            if (cohort.Age >= sppParms.TolerantHostAge)
            {
                if (this.random <= this.siteVulnerability * sppParms.TolerantHostVuln)
                {
                    //if (advRegenSpp && cohort.Age <= this.advRegenAgeCutoff)
                    //   killCohort = false;
                    //else
                    killCohort = true;
                }
            }

            if (cohort.Age >= sppParms.VulnerableHostAge)
            {
                if (this.random <= this.siteVulnerability * sppParms.VulnerableHostVuln)
                {
                    //if (advRegenSpp && cohort.Age <= this.advRegenAgeCutoff)
                    //   killCohort = false;
                    //else
                    killCohort = true;
                }
            }


            if (killCohort)
            {
                this.siteCohortsKilled++;
                if (sppParms.CFSConifer)
                {
                    this.siteCFSconifersKilled++;
                }
            }

            return(killCohort);
        }
        //---------------------------------------------------------------------
        ///<summary>
        ///Calculate the Site Host Index (SHI) for all active sites.
        ///The SHI averages the host value for each species as defined in the
        ///EDA species table.
        ///SHI ranges from 0 - 1.
        ///</summary>
        //---------------------------------------------------------------------
        public static void SiteHostIndexCompute(IAgent agent)
        {
            PlugIn.ModelCore.UI.WriteLine("   Calculating EDA Total Site Host Index.");

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                double sumValue         = 0.0;
                double maxValue         = 0.0;
                int    ageOldestCohort  = 0;
                int    numValidSpp      = 0;
                double speciesHostValue = 0;

                foreach (ISpecies species in PlugIn.ModelCore.Species)
                {
                    //get age of oldest cohort: maybe change this to use ALL cohort ages. How to do so?
                    ageOldestCohort = Util.GetMaxAge(SiteVars.Cohorts[site][species]);
                    ISppParameters sppParms = agent.SppParameters[species.Index];
                    if (sppParms == null)
                    {
                        continue;
                    }

                    //this chunk of code check if the current species in the current active site
                    //is part of the ignored species list. If any of the species are in that list, then negList --> true
                    bool negList = false;
                    foreach (ISpecies negSpp in agent.NegSppList)
                    {
                        if (species == negSpp)
                        {
                            negList = true;
                        }
                    }

                    if ((ageOldestCohort > 0) && (!negList))
                    {
                        numValidSpp++;
                        speciesHostValue = 0.0;

                        if (ageOldestCohort >= sppParms.LowHostAge)
                        {
                            //speciesHostValue = 0.33; VALUES ARE READ IN FROM THE EDA Spp Param Table
                            speciesHostValue = sppParms.LowHostScore;
                        }

                        if (ageOldestCohort >= sppParms.MediumHostAge)
                        {
                            //speciesHostValue = 0.66; VALUES ARE READ IN FROM THE EDA Spp Param Table
                            speciesHostValue = sppParms.MediumHostScore;
                        }

                        if (ageOldestCohort >= sppParms.HighHostAge)
                        {
                            //speciesHostValue = 1.0; VALUES ARE READ IN FROM THE EDA Spp Param Table
                            speciesHostValue = sppParms.HighHostScore;
                        }


                        sumValue += speciesHostValue;
                        maxValue  = System.Math.Max(maxValue, speciesHostValue);
                    }
                }

                if (agent.SHImode == SHImode.mean)
                {
                    SiteVars.SiteHostIndex[site] = sumValue / numValidSpp; //division will be (double) because sumValue was initialized to 0.0
                }
                if (agent.SHImode == SHImode.max)
                {
                    SiteVars.SiteHostIndex[site] = maxValue;
                }
            }
        }  //end SiteHostIndexCompute