Esempio n. 1
0
        public int harvest(Ldpoint pt)
        {
            BoundedPocketStandHarvester.pCoresites.BefStChg(pt.y, pt.x);
            //</Add By Qia on Oct 23 2008>
            Site     site = BoundedPocketStandHarvester.pCoresites[pt.y, pt.x];
            Landunit l;

            l = BoundedPocketStandHarvester.pCoresites.locateLanduPt(pt.y, pt.x);
            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 = (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.TimeStep_Harvest; age <= 320; age += BoundedPocketStandHarvester.pCoresites.TimeStep_Harvest)
                {
                    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.TimeStep, l.ltID))) * (BoundedPocketStandHarvester.pCoresites[pt.y, pt.x].SpecieIndex(i).getTreeNum(age / BoundedPocketStandHarvester.pCoresites.TimeStep, 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.TimeStep, l.ltID))) * BoundedPocketStandHarvester.pCoresites[pt.y, pt.x].SpecieIndex(i).getTreeNum(age / BoundedPocketStandHarvester.pCoresites.TimeStep, i);
                        BoundedPocketStandHarvester.pCoresites.Harvest70outputIncreaseCarbonvalue(pt.y, pt.x, tmpCarbon * site.specAtt(i).CarbonCoEfficient);
                    }
                }

                //</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.TimeStep_Harvest))
                {
                    a.set(BoundedPocketStandHarvester.pCoresites.TimeStep_Harvest);
                    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);
        }
Esempio n. 2
0
 public bool isValidStartPoint(Ldpoint pt)
 {
     return(GlobalFunctions.canBeHarvested(pt) && (BoundedPocketStandHarvester.visitationMap[(uint)pt.y, (uint)pt.x] != BoundedPocketStandHarvester.currentHarvestEventId));
 }
        public int harvest_EVENT_GROUP_SELECTION_REGIME_70(Ldpoint pt)
        {
            //int i, k;
            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 = EVENT_GROUP_SELECTION_REGIME_70_clear_cut(pt.y, pt.x);
                    sumCut += siteCut;

                    if (siteCut > 0)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            r[i] = i;
                        }
                        for (int i = 4; i > 0; i--)
                        {
                            k = (int)(i * 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;
                            }
                            //</Add By Qia on Nov 1 2012>
                            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);
        }