예제 #1
0
        public override void Harvest()
        {
            List <int> rankedList = new List <int>();
            Stand      stand      = new Stand();
            int        standCut;

            itsRankAlgorithm.rankStands(ref rankedList);
            getReport().reset();
            // length of rankedList should be equal to length of  theLength;

            foreach (int it in rankedList)
            {
                if (isHarvestDone() == 0)
                {
                    stand.Copy(BoundedPocketStandHarvester.pstands[it]);
                    if (stand.canBeHarvested() && (BoundedPocketStandHarvester.iParamstandAdjacencyFlag == 0 || !stand.neighborsWereRecentlyHarvested()))
                    {
                        standCut = harvestStand(BoundedPocketStandHarvester.pstands[it]);
                    }
                }
                else
                {
                    break;
                }
            }

            writeReport(BoundedPocketStandHarvester.harvestOutputFile2);
        }
        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);
        }
예제 #3
0
        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 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());
        }
예제 #5
0
        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 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);
                        }
                    }
                }
            }
        }
예제 #7
0
 public MultiplePocketStandHarvester(Stand stand, double proportion, double meanGroupSize, double standardDeviation, SiteHarvester siteHarvester)
 {
     itsProportion        = proportion;
     itsMeanGroupSize     = meanGroupSize;
     itsStandardDeviation = standardDeviation;
     itsTargetCut         = 0;
     setStand(stand);
     setSiteHarvester(siteHarvester);
 }
예제 #8
0
        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);
                        }
                    }
                }
            }
        }
예제 #9
0
 public StandIterator(Stand s)
 {
     stand.Copy(s);
     p.x = s.itsMinPoint.x;
     p.y = s.itsMinPoint.y;
     if (s.itsMinPoint.x <= 0 && s.itsMinPoint.y <= 0)
     {
         throw new Exception("Invaild stand point");
     }
     while (moreSites() && !stand.inStand(p.y, p.x))
     {
         advance();
     }
 }
        public override int harvestStand(Stand stand)
        {
            SitesCut += stand.numberOfActiveSites();
            //printf("sitesinstand:%d SitesCut:%d Target:%d\n",stand->numberOfActiveSites(),SitesCut,itsTargetCut);
            SiteHarvester theSiteHarvester = new SiteHarvester(GetUserInputId(), getRemovalMask(), getReport(), getDuration());
            MultiplePocketStandHarvester theStandHarvester = new MultiplePocketStandHarvester(stand, itsStandProportion, itsMeanGroupSize, itsStandardDeviation, theSiteHarvester);
            int standCut = theStandHarvester.Harvest();

            if (standCut > 0)
            {
                stand.reserve();
                itsStands.Add(stand.getId());
                itsTotalNumberOfStands++;
            }
            return(1);
        }
        public void reharvest()
        {
            Stand stand = new Stand();
            MultiplePocketStandHarvester theStandHarvester;
            int           standCut;
            SiteHarvester theSiteHarvester = new SiteHarvester(GetUserInputId(), getRemovalMask(), getReport(), getDuration());

            getReport().reset();

            for (int i = 0; i < itsStands.Count; i++)
            {
                //        stand = stands(it.current());  Modified by Vera
                stand.Copy(BoundedPocketStandHarvester.pstands[itsStands[i]]);
                theStandHarvester = new MultiplePocketStandHarvester(stand, itsStandProportion, itsMeanGroupSize, itsStandardDeviation, theSiteHarvester);
                standCut          = theStandHarvester.Harvest();
                theStandHarvester = null;
            }
            writeReport(BoundedPocketStandHarvester.harvestOutputFile2);
        }
예제 #12
0
 public void Copy(Stand s)
 {
     itsId = s.itsId;
     itsManagementAreaId  = s.itsManagementAreaId;
     itsTotalSites        = s.itsTotalSites;
     itsActiveSites       = s.itsActiveSites;
     itsHarvestableSites  = s.itsHarvestableSites;
     itsMeanAge           = s.itsMeanAge;
     itsUpdateFlag        = s.itsUpdateFlag;
     itsRecentHarvestFlag = s.itsRecentHarvestFlag;
     itsRank        = s.itsRank;
     itsReserveFlag = s.itsReserveFlag;
     itsMinPoint.x  = s.itsMinPoint.x;
     itsMinPoint.y  = s.itsMinPoint.y;
     itsMaxPoint.x  = s.itsMaxPoint.x;
     itsMaxPoint.y  = s.itsMaxPoint.y;
     for (int i = 0; i < s.itsNeighborList.Count; i++)
     {
         itsNeighborList[i] = s.itsNeighborList[i];
     }
 }
        public void filter(ref IntArray theStandArray, ref IntArray theAgeArray, ref int theLength)
        {
            Stand stand = new Stand();

            int theNewLength = 0;

            List <int> it = new List <int>();

            it = itsManagementArea.itsStandList;
            for (int i = 0; i < it.Count; i++)
            {
                int id = it[i];
                stand.Copy(BoundedPocketStandHarvester.pstands[id]);
                if (stand.canBeHarvested() && stand.getAge() >= itsRotationAge)
                {
                    theNewLength++;
                    theStandArray[theNewLength] = id;
                    theAgeArray[theNewLength]   = stand.getAge();
                }
            }
            theLength = theNewLength;
        }
예제 #14
0
        public void construct()
        {
            int  i;
            int  r;
            int  c;
            uint id;
            uint nid;
            int  snr;
            int  snc;
            uint mid;
            uint currMid;

            Ldpoint pmin        = new Ldpoint();
            Ldpoint pmax        = new Ldpoint();
            string  errorString = "";

            numStands = BoundedPocketStandHarvester.standMap.high();
            if (stands != null)
            {
                stands = null;
            }
            stands = new Stand[numStands];
            for (int k = 0; k < numStands; k++)
            {
                stands[k] = new Stand();
            }

            snr = BoundedPocketStandHarvester.pCoresites.numRows();
            snc = BoundedPocketStandHarvester.pCoresites.numColumns();

            for (i = 0; i < numStands; i++)
            {
                stands[i].itsId         = i + 1;
                stands[i].itsMinPoint.x = snc;
                stands[i].itsMinPoint.y = snr;
                stands[i].itsMaxPoint.x = 1;
                stands[i].itsMaxPoint.y = 1;
            }

            for (r = 1; r <= snr; r++)
            {
                for (c = 1; c <= snc; c++)
                {
                    id = BoundedPocketStandHarvester.standMap.getvalue32out((uint)r, (uint)c);
                    if (id > 0)
                    {
                        pmin = stands[id - 1].itsMinPoint;
                        pmax = stands[id - 1].itsMaxPoint;
                        if (r < pmin.y)
                        {
                            pmin.y = r;
                        }
                        if (r > pmax.y)
                        {
                            pmax.y = r;
                        }
                        if (c < pmin.x)
                        {
                            pmin.x = c;
                        }
                        if (c > pmax.x)
                        {
                            pmax.x = c;
                        }
                        stands[id - 1].itsMinPoint = pmin;
                        stands[id - 1].itsMaxPoint = pmax;
                        //Console.WriteLine("{0}:{1}, {2}, {3}, {4}",id, pmin.x, pmin.y, pmax.x, pmax.y);
                        mid = BoundedPocketStandHarvester.managementAreaMap[(uint)r, (uint)c];
                        if (mid <= 0)
                        {
                            errorString = string.Format("No management area defined at (x,y) = ({0:D},{1:D}) StandID: {2:D}", c, r, id);
                            throw new Exception(errorString);
                        }
                        if ((currMid = stands[id - 1].itsManagementAreaId) > 0 && currMid != mid)
                        {
                            errorString = string.Format("Stand {0:D} crosses management area boundary at (x,y):currMid:{1:D}, mid: {2:D} = ({3:D},{4:D})", id, c, r, currMid, mid);
                            throw new Exception(errorString);
                        }
                        stands[id - 1].itsManagementAreaId = mid;
                        if (c < snc)
                        {
                            if ((nid = stands[id - 1].isNeighbor(r, c + 1)) > 0)
                            {
                                stands[id - 1].addNeighbor(nid);
                                stands[nid - 1].addNeighbor(id);
                            }
                        }
                        if (r > 1)
                        {
                            if ((nid = stands[id - 1].isNeighbor(r - 1, c)) > 0)
                            {
                                stands[id - 1].addNeighbor(nid);
                                stands[nid - 1].addNeighbor(id);
                            }
                        }
                        stands[id - 1].itsTotalSites++;
                        if (BoundedPocketStandHarvester.pCoresites.locateLanduPt(r, c).active())
                        {
                            stands[id - 1].itsActiveSites++;
                        }
                    }
                }
            }
        }
예제 #15
0
 public virtual int harvestStand(Stand stand)
 {
     return(0);
 }
예제 #16
0
 public StandHarvest()
 {
     itsStand         = null;
     itsSiteHarvester = null;
     itsPath          = null;
 }
예제 #17
0
 public void setStand(Stand stand)
 {
     itsStand = stand;
 }