//--------------------------------------------------------------------- /// <summary> /// Computes the rank for a stand. /// </summary> protected override double ComputeRank(Stand stand, int i) { double standEconImportance = 0.0; //Model.Core.UI.WriteLine("Base Harvest: EconomicRank.cs: ComputeRank: there are {0} sites in this stand.", stand.SiteCount); foreach (ActiveSite site in stand) { double siteEconImportance = 0.0; foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site]) { EconomicRankParameters rankingParameters = rankTable[speciesCohorts.Species]; foreach (ICohort cohort in speciesCohorts) { if (rankingParameters.MinimumAge > 0 && rankingParameters.MinimumAge <= cohort.Age) { siteEconImportance += (double)rankingParameters.Rank / rankingParameters.MinimumAge * cohort.Age; } } } standEconImportance += siteEconImportance; } standEconImportance /= stand.SiteCount; return(standEconImportance); }
//--------------------------------------------------------------------- protected EconomicRankTable ReadEconomicRankTable() { SpeciesLineNumbers.Clear(); // in case parser re-used InputVar <byte> rank = new InputVar <byte>("Economic Rank"); InputVar <ushort> minAge = new InputVar <ushort>("Minimum Age"); string lastColumn = "the " + minAge.Name + " column"; EconomicRankTable table = new EconomicRankTable(); while (!AtEndOfInput && !namesThatFollowRankingMethod.Contains(CurrentName)) { StringReader currentLine = new StringReader(CurrentLine); // Species name ISpecies species = ReadSpecies(currentLine); // Economic rank ReadValue(rank, currentLine); const byte maxRank = 100; if (rank.Value.Actual > maxRank) { throw new InputValueException(rank.Value.String, "Economic rank must be between 0 and {0}", maxRank); } // Minimum age ReadValue(minAge, currentLine); CheckNoDataAfter(lastColumn, currentLine); table[species] = new EconomicRankParameters(rank.Value.Actual, minAge.Value.Actual); GetNextLine(); } if (SpeciesLineNumbers.Count == 0) { throw NewParseException("Expected a line starting with a species name"); } return(table); }