public double computeStandStocking(Stand stand) { Ldpoint p = new Ldpoint(); Site site; double count = 0; int m; int k; double num_trees = 0; //N double Diameters = 0; //D double Diameters_square = 0; //D^2 double x = BoundedPocketStandHarvester.pCoresites.stocking_x_value; double y = BoundedPocketStandHarvester.pCoresites.stocking_y_value; double z = BoundedPocketStandHarvester.pCoresites.stocking_z_value; Landunit l; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { p = it.getCurrentSite(); l = BoundedPocketStandHarvester.pCoresites.locateLanduPt(p.y, p.x); site = BoundedPocketStandHarvester.pCoresites[p.y, p.x]; count += 1; for (k = 1; k <= BoundedPocketStandHarvester.pCoresites.specNum; k++) { for (m = 1; m <= site.specAtt(k).longevity / BoundedPocketStandHarvester.pCoresites.TimeStep; m++) { num_trees += site.SpecieIndex(k).getTreeNum(m, k); Diameters += BoundedPocketStandHarvester.pCoresites.GetGrowthRates(k, m, l.ltID) * site.SpecieIndex(k).getTreeNum(m, k) / 2.54; Diameters_square += BoundedPocketStandHarvester.pCoresites.GetGrowthRates(k, m, l.ltID) * BoundedPocketStandHarvester.pCoresites.GetGrowthRates(k, m, l.ltID) * site.SpecieIndex(k).getTreeNum(m, k) / 2.54 / 2.54; } } } return((x * num_trees + y * Diameters + z * Diameters_square) / (BoundedPocketStandHarvester.pCoresites.CellSize * BoundedPocketStandHarvester.pCoresites.CellSize / 4046.86) / stand.numberOfActiveSites()); }
public bool getRandomStartPoint(ref Ldpoint startPoint) { Ldpoint pt = new Ldpoint(); bool found = false; for (int i = 0; i < 100; i++) { pt = getStand().getRandomPoint(); found = isValidStartPoint(pt); if (found) { break; } } if (!found) { Debug.Assert(getStand() != null); for (StandIterator it = new StandIterator(getStand()); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); found = isValidStartPoint(pt); if (found) { break; } } } startPoint = pt; return(found); }
public override int harvestStand(Stand stand) { SitesCut += stand.numberOfActiveSites(); Ldpoint pt = new Ldpoint(); int i; int j; double TmpBasalAreaS; double TmpBasalAreaS_avg; double BA_toCut; double shareCut_ACell; TmpBasalAreaS = 0; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; TmpBasalAreaS += GetBAinACell(i, j); } TmpBasalAreaS_avg = TmpBasalAreaS / BoundedPocketStandHarvester.pCoresites.CellSize / BoundedPocketStandHarvester.pCoresites.CellSize / stand.numberOfActiveSites() * 10000; if (TmpBasalAreaS_avg <= Mininum_BA) { } else { //Cut trees here //printf("Enough to Harvest\n"); StandsCut++; itsStands.Add(stand.getId()); //Add By Qia on June 01 2012 BA_toCut = TmpBasalAreaS_avg - TargetVolume; if (BA_toCut < 0.0) { BA_toCut = TmpBasalAreaS_avg; } BA_toCut = BA_toCut * BoundedPocketStandHarvester.pCoresites.CellSize * BoundedPocketStandHarvester.pCoresites.CellSize * stand.numberOfActiveSites() / 10000; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; shareCut_ACell = GetBAinACell(i, j) / TmpBasalAreaS * BA_toCut; if (shareCut_ACell > 0) { double shareCut = 0.0; shareCut = CutShareBAinACell_LifeSpanPercent(i, j, shareCut_ACell); BoundedPocketStandHarvester.pHarvestsites[i, j].harvestType = (short)GetUserInputId(); BoundedPocketStandHarvester.pHarvestsites[i, j].lastHarvest = (short)BoundedPocketStandHarvester.currentDecade; } else { BoundedPocketStandHarvester.pHarvestsites.SetValueHarvestBA(i, j, shareCut_ACell); } } } //return StandsCut; return(1); }
public double computeStandBA(Stand stand) { Ldpoint p = new Ldpoint(); Site site; double count = 0; int m; int k; double TmpBasalAreaS = 0; Landunit l; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { p = it.getCurrentSite(); site = BoundedPocketStandHarvester.pCoresites[p.y, p.x]; l = BoundedPocketStandHarvester.pCoresites.locateLanduPt(p.y, p.x); count += 1; for (k = 1; k <= BoundedPocketStandHarvester.pCoresites.specNum; k++) { for (m = 1; m <= site.specAtt(k).longevity / BoundedPocketStandHarvester.pCoresites.TimeStep; m++) { TmpBasalAreaS += BoundedPocketStandHarvester.pCoresites.GetGrowthRates(k, m, l.ltID) * BoundedPocketStandHarvester.pCoresites.GetGrowthRates(k, m, l.ltID) / 4 * 3.1415926 * site.SpecieIndex(k).getTreeNum(m, k) / 10000.00; } } } if (count > 0) { TmpBasalAreaS = TmpBasalAreaS / count; } return(TmpBasalAreaS); }
public override int harvestStand(Stand stand) { //printf("before harvest standID: %d, stocking: %lf\n",stand->getId(),computeStandStocking(stand)); SitesCut += stand.numberOfActiveSites(); //printf("sitesinstand:%d SitesCut:%d Target:%d\n",stand->numberOfActiveSites(),SitesCut,itsTargetCut); Ldpoint pt = new Ldpoint(); int m; int k; int i; int j; double TmpStockingS; double TmpStockingS_avg; double Stocking_toCut; double shareCut_ACell; TmpStockingS = 0; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; TmpStockingS += GetStockinginACell(i, j); } TmpStockingS = TmpStockingS / stand.numberOfActiveSites(); //TmpStockingS_avg = TmpStockingS / pCoresites->CellSize/pCoresites->CellSize/stand->numberOfActiveSites()*10000; TmpStockingS_avg = TmpStockingS / stand.numberOfActiveSites(); if (TmpStockingS <= Mininum_Stocking) { } else { //Cut trees here //printf("Enough to Harvest\n"); StandsCut++; itsStands.Add(stand.getId()); //Add By Qia on June 01 2012 Stocking_toCut = TmpStockingS - TargetStocking; //Stocking_toCut = Stocking_toCut * pCoresites->CellSize * pCoresites->CellSize * stand->numberOfActiveSites()/10000; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; shareCut_ACell = GetStockinginACell(i, j) / TmpStockingS * Stocking_toCut; if (shareCut_ACell > 0.0) { //CutShareStockinginACell(i,j,shareCut_ACell); //SitesCut++; CutShareStockinginACell_LifeSpanPercent(i, j, shareCut_ACell); BoundedPocketStandHarvester.pHarvestsites[i, j].harvestType = (short)GetUserInputId(); BoundedPocketStandHarvester.pHarvestsites[i, j].lastHarvest = (short)BoundedPocketStandHarvester.currentDecade; } else { //pHarvestsites->SetValueHarvestBA(i,j,shareCut_ACell); } } } //return StandsCut; //printf("after harvest standID: %d, stocking: %lf\n",stand->getId(),computeStandStocking(stand)); return(1); }
public void update() { //static int count_update = 0; //count_update++; Ldpoint pt = new Ldpoint(); Site site; if (itsUpdateFlag == 1) { if (itsActiveSites == 0) { itsMeanAge = 0; itsHarvestableSites = 0; itsRecentHarvestFlag = 0; } else { //static int get_updatecount = 0; //get_updatecount++; int sum = 0; int rcount = 0; itsHarvestableSites = 0; Ldpoint tmp_pt = this.getMinPoint(); Ldpoint tmp_ptmax = this.getMaxPoint(); int temp_id = this.getId(); for (StandIterator it = new StandIterator(this); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); site = BoundedPocketStandHarvester.pCoresites[pt.y, pt.x]; if (BoundedPocketStandHarvester.pCoresites.locateLanduPt(pt.y, pt.x).active()) //original landis4.0: site->landUnit->active() { BoundedPocketStandHarvester.pHarvestsites.BefStChg(pt.y, pt.x); //Add By Qia on Nov 10 2008 sum += BoundedPocketStandHarvester.pHarvestsites[pt.y, pt.x].getMaxAge(pt.y, pt.x); BoundedPocketStandHarvester.pHarvestsites.AftStChg(pt.y, pt.x); //Add By Qia on Nov 10 2008 if (BoundedPocketStandHarvester.standMap.getvalue32out((uint)pt.y, (uint)pt.x) > 0 && BoundedPocketStandHarvester.pHarvestsites[pt.y, pt.x].canBeHarvested(pt.y, pt.x)) //change by Qia on Nov 4 2008 { itsHarvestableSites++; } if (BoundedPocketStandHarvester.pHarvestsites[pt.y, pt.x].wasRecentlyHarvested()) { rcount++; } } } itsMeanAge = sum / numberOfActiveSites(); if ((float)rcount / numberOfActiveSites() < BoundedPocketStandHarvester.fParamharvestThreshold) { itsRecentHarvestFlag = 0; } else { itsRecentHarvestFlag = 1; } } itsUpdateFlag = 0; } }
public void reharvest() { Stand stand = new Stand(); //Console.WriteLine(itsStands.Count); //Console.ReadLine(); for (int ii = 0; ii < itsStands.Count; ii++) { stand.Copy(BoundedPocketStandHarvester.pstands[itsStands[ii]]); SitesCut += stand.numberOfActiveSites(); Ldpoint pt = new Ldpoint(); int m; int k; int i; int j; double TmpBasalAreaS; double TmpBasalAreaS_avg; double BA_toCut; double shareCut_ACell; TmpBasalAreaS = 0; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; TmpBasalAreaS += GetBAinACell(i, j); } TmpBasalAreaS_avg = TmpBasalAreaS / BoundedPocketStandHarvester.pCoresites.CellSize / BoundedPocketStandHarvester.pCoresites.CellSize / stand.numberOfActiveSites() * 10000; if (TmpBasalAreaS_avg <= Mininum_BA) { } else { //Cut trees here StandsCut++; BA_toCut = TmpBasalAreaS_avg - TargetVolume; BA_toCut = BA_toCut * BoundedPocketStandHarvester.pCoresites.CellSize * BoundedPocketStandHarvester.pCoresites.CellSize * stand.numberOfActiveSites() / 10000; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; shareCut_ACell = GetBAinACell(i, j) / TmpBasalAreaS * BA_toCut; // Console.WriteLine(shareCut_ACell); if (shareCut_ACell > 0) { CutShareBAinACell_LifeSpanPercent(i, j, shareCut_ACell); BoundedPocketStandHarvester.pHarvestsites[i, j].harvestType = (short)GetUserInputId(); BoundedPocketStandHarvester.pHarvestsites[i, j].lastHarvest = (short)BoundedPocketStandHarvester.currentDecade; } else { BoundedPocketStandHarvester.pHarvestsites.SetValueHarvestBA(i, j, shareCut_ACell); } } } } }
public void reharvest() { Stand stand = new Stand(); for (int ii = 0; ii < itsStands.Count; ii++) { stand.Copy(BoundedPocketStandHarvester.pstands[itsStands[ii]]); SitesCut += stand.numberOfActiveSites(); double stocking_debug = computeStandStocking(stand); Ldpoint pt = new Ldpoint(); int m; int k; int i; int j; double TmpStockingS; double TmpStockingS_avg; double Stocking_toCut; double shareCut_ACell; TmpStockingS = 0; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; TmpStockingS += GetStockinginACell(i, j); } TmpStockingS = TmpStockingS / stand.numberOfActiveSites(); if (TmpStockingS <= Mininum_Stocking) { } else { //Cut trees here StandsCut++; Stocking_toCut = TmpStockingS - TargetStocking; for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite()) { pt = it.getCurrentSite(); i = pt.y; j = pt.x; shareCut_ACell = GetStockinginACell(i, j) / TmpStockingS * Stocking_toCut; if (shareCut_ACell > 0.0) { CutShareStockinginACell_LifeSpanPercent(i, j, shareCut_ACell); BoundedPocketStandHarvester.pHarvestsites[i, j].harvestType = (short)GetUserInputId(); BoundedPocketStandHarvester.pHarvestsites[i, j].lastHarvest = (short)BoundedPocketStandHarvester.currentDecade; } else { //pHarvestsites->SetValueHarvestBA(i,j,shareCut_ACell); } } } } }