public double computeStandStocking(Stand stand)
        {
            Ldpoint p = new Ldpoint();

            Landis.Extension.Succession.Landispro.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;

            Landis.Extension.Succession.Landispro.landunit l;
            for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite())
            {
                p      = it.getCurrentSite();
                l      = BoundedPocketStandHarvester.pCoresites.locateLanduPt((uint)p.y, (uint)p.x);
                site   = BoundedPocketStandHarvester.pCoresites[(uint)p.y, (uint)p.x];
                count += 1;
                for (k = 1; k <= BoundedPocketStandHarvester.pCoresites.SpecNum; k++)
                {
                    for (m = 1; m <= site.specAtt(k).Longevity / BoundedPocketStandHarvester.pCoresites.SuccessionTimeStep; 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 double computeStandBA(Stand stand)
        {
            Ldpoint p = new Ldpoint();

            Landis.Extension.Succession.Landispro.site site;
            double count = 0;
            int    m;
            int    k;
            double TmpBasalAreaS = 0;

            Landis.Extension.Succession.Landispro.landunit l;
            for (StandIterator it = new StandIterator(stand); it.moreSites(); it.gotoNextSite())
            {
                p      = it.getCurrentSite();
                site   = BoundedPocketStandHarvester.pCoresites[(uint)p.y, (uint)p.x];
                l      = BoundedPocketStandHarvester.pCoresites.locateLanduPt((uint)p.y, (uint)p.x);
                count += 1;
                for (k = 1; k <= BoundedPocketStandHarvester.pCoresites.SpecNum; k++)
                {
                    for (m = 1; m <= site.specAtt(k).Longevity / BoundedPocketStandHarvester.pCoresites.SuccessionTimeStep; 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);
        }
Пример #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);
        }
Пример #4
0
        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 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 void update()
        {
            //static int count_update = 0;
            //count_update++;

            Ldpoint pt = new Ldpoint();

            Landis.Extension.Succession.Landispro.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[(uint)pt.y, (uint)pt.x];
                        if (BoundedPocketStandHarvester.pCoresites.locateLanduPt((uint)pt.y, (uint)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;
            }
        }
Пример #7
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 BoundedPocketStandHarvester(int targetCut, Ldpoint startPoint, SiteHarvester siteHarvester, HarvestPath path)
        {
            int standId = (int)standMap.getvalue32out((uint)startPoint.y, (uint)startPoint.x); //changed By Qia on Nov 4 2008

            setStand(pstands[standId]);
            setSiteHarvester(siteHarvester);
            setPath(path);
            itsTargetCut  = targetCut;
            itsStartPoint = startPoint;
        }
        public Ldpoint getRandomPoint()
        {
            Ldpoint pt = new Ldpoint();

            do
            {
                pt.x = Landis.Extension.Succession.Landispro.system1.irand(itsMinPoint.x, itsMaxPoint.x);
                pt.y = Landis.Extension.Succession.Landispro.system1.irand(itsMinPoint.y, itsMaxPoint.y);
            } while (!inStand(pt.y, pt.x));
            return(pt);
        }
Пример #10
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);
                        }
                    }
                }
            }
        }
        public void addSiteNeighbor(int r, int c)
        {
            Debug.Assert(currentHarvestEventId > 0);
            Debug.Assert(currentHarvestEventId < 65535);
            bool first_val = getStand().inStand(r, c);

            if (first_val && visitationMap[(uint)r, (uint)c] != currentHarvestEventId)
            {
                Ldpoint p = new Ldpoint(c, r);
                itsNeighborList.Add(p);
                visitationMap[(uint)r, (uint)c] = currentHarvestEventId;
            }
        }
 public Stand()
 {
     itsId = 0;
     itsManagementAreaId  = 0;
     itsTotalSites        = 0;
     itsActiveSites       = 0;
     itsHarvestableSites  = 0;
     itsMeanAge           = 0;
     itsUpdateFlag        = 1;
     itsRecentHarvestFlag = 0;
     itsRank        = 0;
     itsReserveFlag = 0;
     itsMinPoint    = new Ldpoint();
     itsMaxPoint    = new Ldpoint();
 }
        public override int Harvest()
        {
            Ldpoint startPoint      = new Ldpoint();
            int     targetPocketCut = 0;
            BoundedPocketStandHarvester pocketHarvester;
            int pocketCut = 0;
            int sumCut    = 0;

            itsTargetCut = (int)(getStand().numberOfActiveSites() * itsProportion);
            while (sumCut < itsTargetCut)
            {
                if (!getRandomStartPoint(ref startPoint))
                {
                    break;
                }
                targetPocketCut = getRandomGroupSize();
                pocketHarvester = new BoundedPocketStandHarvester(targetPocketCut, startPoint, getSiteHarvester(), null);
                pocketCut       = pocketHarvester.Harvest();
                sumCut         += pocketCut;
                pocketHarvester = null;
                pocketHarvester = null;
            }
            return(sumCut);
        }
 public int inManagementArea(Ldpoint p)
 {
     return(inManagementArea(p.y, p.x));
 }
Пример #15
0
        public int harvest(Ldpoint pt)
        {
            BoundedPocketStandHarvester.pCoresites.BefStChg(pt.y, pt.x);
            //</Add By Qia on Oct 23 2008>
            Landis.Extension.Succession.Landispro.site     site = BoundedPocketStandHarvester.pCoresites[(uint)pt.y, (uint)pt.x];
            Landis.Extension.Succession.Landispro.landunit l;
            l = BoundedPocketStandHarvester.pCoresites.locateLanduPt((uint)pt.y, (uint)pt.x);
            Landis.Extension.Succession.Landispro.agelist a;
            CohortRemovalMask m;
            int cohortCut;
            int siteCut = 0;
            //by wei li
            int sitePlanted = 0;

            //by wei li
            for (int i = 1; i <= BoundedPocketStandHarvester.numberOfSpecies; i++)
            {
                a = (Landis.Extension.Succession.Landispro.agelist)site[i];
                m = itsRemovalMask[i];

                cohortCut = harvestCohorts(a, m);
                //<Add By Qia on Feb 16 2010>
                double tmpBiomass;
                double tmpCarbon;

                for (int age = BoundedPocketStandHarvester.pCoresites.TimeStepHarvest; age <= 320; age += BoundedPocketStandHarvester.pCoresites.TimeStepHarvest)
                {
                    if (m.query(age) == 1 && a.query(age))
                    {
                        tmpBiomass = Math.Exp(BoundedPocketStandHarvester.pCoresites.GetBiomassData(site.specAtt(i).BioMassCoef, 1) + BoundedPocketStandHarvester.pCoresites.GetBiomassData(site.specAtt(i).BioMassCoef, 2) * Math.Log(BoundedPocketStandHarvester.pCoresites.GetGrowthRates(i, age / BoundedPocketStandHarvester.pCoresites.SuccessionTimeStep, l.LtID))) * (BoundedPocketStandHarvester.pCoresites[(uint)pt.y, (uint)pt.x].SpecieIndex(i).getTreeNum(age / BoundedPocketStandHarvester.pCoresites.SuccessionTimeStep, i)) / 1000.00;
                        BoundedPocketStandHarvester.pCoresites.Harvest70outputIncreaseBiomassvalue(pt.y, pt.x, tmpBiomass);
                        tmpCarbon = Math.Exp(BoundedPocketStandHarvester.pCoresites.GetBiomassData(site.specAtt(i).BioMassCoef, 1) + BoundedPocketStandHarvester.pCoresites.GetBiomassData(site.specAtt(i).BioMassCoef, 2) * Math.Log(BoundedPocketStandHarvester.pCoresites.GetGrowthRates(i, age / BoundedPocketStandHarvester.pCoresites.SuccessionTimeStep, l.LtID))) * BoundedPocketStandHarvester.pCoresites[(uint)pt.y, (uint)pt.x].SpecieIndex(i).getTreeNum(age / BoundedPocketStandHarvester.pCoresites.SuccessionTimeStep, i);
                        BoundedPocketStandHarvester.pCoresites.Harvest70outputIncreaseCarbonvalue(pt.y, pt.x, tmpCarbon * site.specAtt(i).CarbonCoef);
                    }
                }

                //</Add By Qia on Feb 16 2010>
                itsReport.addToSpeciesTotal(i, cohortCut);
                if (cohortCut > 0)
                {
                    siteCut = 1;
                }
                //by wei li
                if (itsRemovalMask.plantingCode(i) > 0 && !a.query(BoundedPocketStandHarvester.pCoresites.TimeStepHarvest))
                {
                    a.set(BoundedPocketStandHarvester.pCoresites.TimeStepHarvest);
                    sitePlanted = 1;
                }
                //end by wei li
            }

            if (siteCut == 1)
            {
                itsReport.incrementSiteCount();
                BoundedPocketStandHarvester.pHarvestsites.BefStChg(pt.y, pt.x); //Add By Qia on Nov 07 2008
                //update PDP
                BoundedPocketStandHarvester.m_pPDP.sTSLHarvest[pt.y, pt.x]   = 0;
                BoundedPocketStandHarvester.m_pPDP.cHarvestEvent[pt.y, pt.x] = (char)itsHarvestType;

                BoundedPocketStandHarvester.pHarvestsites[pt.y, pt.x].harvestExpirationDecade = (short)(BoundedPocketStandHarvester.currentDecade + itsDuration);
                BoundedPocketStandHarvester.pHarvestsites.AftStChg(pt.y, pt.x);
                GlobalFunctions.setUpdateFlags(pt.y, pt.x);
            }
            //by wei li
            if (siteCut != 0 || sitePlanted != 0)
            {
                GlobalFunctions.setUpdateFlags(pt.y, pt.x);
            }
            //by wei li
            //<Add By Qia on Oct 23 2008>
            BoundedPocketStandHarvester.pCoresites.AftStChg(pt.y, pt.x);
            //</Add By Qia on Oct 23 2008>
            return(siteCut);
        }
        public override int Harvest()
        {
            Ldpoint pt = new Ldpoint();
            int     i  = 0;
            int     k  = 0;

            int[] r       = new int[4];
            int   siteCut = 0;
            int   sumCut  = 0;
            int   c       = 0;

            visitationMap[(uint)itsStartPoint.y, (uint)itsStartPoint.x] = currentHarvestEventId;
            itsNeighborList.Add(itsStartPoint);
            while (sumCut < itsTargetCut && itsNeighborList.Count > 0)
            {
                c  = itsNeighborList.Count;
                pt = itsNeighborList[0];
                itsNeighborList.RemoveAt(0);

                if (GlobalFunctions.canBeHarvested(pt))
                {
                    siteCut = harvest_EVENT_GROUP_SELECTION_REGIME_70(pt);
                    sumCut += siteCut;
                    if (siteCut > 0)
                    {
                        for (i = 0; i < 4; i++)
                        {
                            r[i] = i;
                        }
                        for (i = 4; i > 0; i--)
                        {
                            k = (int)(i * Landis.Extension.Succession.Landispro.system1.frand());
                            //orignal no control over k, potential out of bound err
                            //<Add By Qia on Nov 1 2012>
                            if (k < 0)
                            {
                                k = 0;
                            }
                            if (k > 3)
                            {
                                k = 3;
                            }
                            switch (r[k])
                            {
                            case 0:
                                addSiteNeighbor(pt.y, pt.x - 1);
                                break;

                            case 1:
                                addSiteNeighbor(pt.y, pt.x + 1);
                                break;

                            case 2:
                                addSiteNeighbor(pt.y - 1, pt.x);
                                break;

                            case 3:
                                addSiteNeighbor(pt.y + 1, pt.x);
                                break;
                            }
                            r[k] = r[i - 1];
                            if (k < 0 || k > 3 || (i - 1) < 0 || (i - 1) > 3)
                            {
                                Console.Write("group selection index error\n");
                            }
                        }
                    }
                }
                return(sumCut);
            }

            return(sumCut);
        }
Пример #17
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 = (int)BoundedPocketStandHarvester.pCoresites.numRows;
            snc = (int)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 = (uint)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((uint)r, (uint)c).active())
                        {
                            stands[id - 1].itsActiveSites++;
                        }
                    }
                }
            }
        }
 public bool isValidStartPoint(Ldpoint pt)
 {
     return(GlobalFunctions.canBeHarvested(pt) && (BoundedPocketStandHarvester.visitationMap[(uint)pt.y, (uint)pt.x] != BoundedPocketStandHarvester.currentHarvestEventId));
 }
Пример #19
0
 public void append(Ldpoint pt)
 {
     Console.WriteLine("HarvestPath::append, pt.x={0}, pt.y={1}", pt.x, pt.y);
     itsPath.Add(pt);
 }
Пример #20
0
 public static bool canBeHarvested(Ldpoint thePoint)
 {
     return(BoundedPocketStandHarvester.pHarvestsites[thePoint.y, thePoint.x].canBeHarvested(thePoint.y, thePoint.x));
 }