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);
        }
 public bool isValidStartPoint(Ldpoint pt)
 {
     return(GlobalFunctions.canBeHarvested(pt) && (BoundedPocketStandHarvester.visitationMap[(uint)pt.y, (uint)pt.x] != BoundedPocketStandHarvester.currentHarvestEventId));
 }
コード例 #3
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);
        }