2021亚太数学建模C生态保护的建设及其对环境影响的评价

328 篇文章 53 订阅
176 篇文章 14 订阅

生态保护的建设及其对环境影响的评价

建模人,不用说别的一是模型的实现及程序,二是图像

The picture is mosaic and hard-working. I don’t want others to whore for nothing
在这里插入图片描述
在这里插入图片描述

问题重述

坚持清澈、青山是宝贵资产的理念,坚持尊重、和谐保护自然,优先节约资源,保护环境、让自然恢复,实施可持续发展战略,完善生态文明领域整体协调机制,建设生态文明体系,促进经济社会发展向全面绿色增长转型,建设美丽国家。在帮助下,塞罕坝林场已从沙漠中恢复过来,现已成为具有防沙功能稳定的环保、绿色农场。
自1962年以来,有369名平均年龄在24岁以下的年轻人来到这片布满沙土的荒地。从那时起,他们在这里献出了自己的生命,一波又一波,在沙子里种植种子,在石头的缝隙里种植绿色,就像钉子钉着荒地上数百万英亩的森林。他们植树来固定沙子和保护水源,建造一个绿色屏障来阻挡风和沙子。目前,塞罕坝地区的森林覆盖率已达到80%。它每年向北京和天津提供1.37亿立方米的清洁水,封存74.7万吨碳,释放54.5万吨氧气。
经过半个多世纪的斗争,世界上最大的人工林建在塞罕坝的地球上。建设者们扩大造林112万亩,树木超过4亿棵,在北京以北400公里的高原荒地上形成了一片绿地。
一方面,“文明发展,动物学繁荣”是历史使命。另一方面,在绿色发展的道路上也遇到了一些新的问题。因此,塞罕坝人现在有了一个更高的目标,即恢复生态。自中共十八届全国代表大会以来,先后启动了植树造林、人工林自然改良、自然林近归化栽培三大重大项目。他们试图使人工森林更接近自然森林。
请由您的团队建立数学模型,并回答以下问题:

  1. 塞罕坝在抗风抗沙、保护环境、维持生态平衡和稳定等方面起着重要作用。请选择合适的指标,收集相关数据,建立塞罕坝对生态环境影响的评价模型,定量评价塞罕坝恢复后对环境的影响,即对塞罕坝恢复前后的环境条件进行比较分析。
  2. 塞罕坝林场的恢复对北京抗沙尘暴发挥了重要作用。请选择合适的指标,收集相关数据,建立评价塞罕坝对北京抗沙尘暴能力影响的数学模型,并定量评价塞罕坝在北京抵御沙尘暴中的作用。
  3. 假设我们计划将塞罕坝的生态保护模型扩展到全国,请建立数学模型并收集相关数据,以确定中国哪些地理位置需要建立生态区域。生态保护区),并确定待建设的生态区域的数量或规模,并评价其对实现中国碳中和目标的影响。
  4. 中国的塞罕坝生态保护模式为亚太地区树立了榜样。请从亚太地区选择另一个国家建立数学模型,收集相关数据,然后讨论该国需要建设哪个地理位置。生态保护区),以及确定要建设的生态区域的数量或规模;此外,评估其对吸收温室气体和减轻碳排放的影响。
  5. 请向亚太地区数学竞赛建模组委会(APMCM)撰写一份非技术性报告,描述您的模型,并提出建立生态保护区的可行计划和建议。
    提示:在建立模型的过程中,可以考虑中国等亚太地区现有生态森林的条件;不同树木的生长环境要求(即特定树木的特定区域);如何平衡生态林地、经济发展用地和工业用地的布局;目标地理区域是否有足够的土地来开发生态保护区。
import numpy as np
import simpy
import itertools
import collections as col

class FuelPump(object):

    def __init__(self, env, count):
        '''
            The main constructor of the class

            @param env   -- environment object
            @param count -- how many pumps for a certain
                            fuel type to instantiate
        '''
        # create the pump resource in the environment
        self.resource = simpy.Resource(env, count)

    def request(self):
        '''
            Wrapper method to create a request for an 
            available pump
        '''
        return self.resource.request()

class GasStation(object):
    '''
        Gas station class. 
    '''
    def __init__(self, env):
        '''
            The main constructor of the class

            @param env -- environment object
        '''
        # keep a pointer to the environment in the class
        self.env = env

        # fuel capacity (gallons) and reservoirs 
        # to track level
        self.CAPACITY = {'PETROL': 8000, 'DIESEL': 3000}
        self.RESERVOIRS = {}
        self.generateReservoirs(self.env, self.CAPACITY)

        # number of pumps for each fuel type
        self.PUMPS_COUNT = {'PETROL': 3, 'DIESEL': 1}
        self.PUMPS = {}
        self.generatePumps(self.env, self.CAPACITY, 
            self.PUMPS_COUNT)

        # how quickly they pump the fuel
        self.SPEED_REFUEL = 0.3 # 0.3 gal/s

        # set the minimum amount of fuel left before 
        # replenishing
        self.MINIMUM_FUEL = {'PETROL': 300, 'DIESEL': 100}

        # how long does it take for the track to get 
        # to the station after placing the call        
        self.TRUCK_TIME = 200
        self.SPEED_REPLENISH = 5

        # cash registry
        self.sellPrice = {'PETROL': 2.45, 'DIESEL': 2.23}
        self.buyPrice  = {'PETROL': 1.95, 'DIESEL': 1.67}
        self.cashIn = 0
        self.cashOut = np.sum(
            [ self.CAPACITY[ft] \
            * self.buyPrice[ft] 
            for ft in self.CAPACITY])
        self.cashLost = 0

        # add the process to control the levels of fuel
        # available for sale
        self.control = self.env.process(self.controlLevels())

        print('Gas station generated...')

    def generatePumps(self, env, fuelTypes, noOfPumps):
        '''
            Helper method to generate pumps
        '''
        for fuelType in fuelTypes:
                self.PUMPS[fuelType] = FuelPump(
                    env, noOfPumps[fuelType])

    def generateReservoirs(self, env, levels):
        '''
            Helper method to generate reservoirs
        '''
        for fuel in levels:
            self.RESERVOIRS[fuel] = simpy.Container(
                env, levels[fuel], init=levels[fuel])

    def replenish(self, fuelType):
        '''
            A method to replenish the fuel
        '''
        # print nicely so we can distinguish when the truck
        # was called
        print('-' * 70)
        print('CALLING TRUCK AT {0:4.0f}s.' \
            .format(self.env.now))
        print('-' * 70)

        # waiting for the truck to come (lead time)
        yield self.env.timeout(self.TRUCK_TIME)

        # let us know when the truck arrived
        print('-' * 70)
        print('TRUCK ARRIVING AT {0:4.0f}s' \
            .format(self.env.now))

        # how much we need to replenish
        toReplenish = self.RESERVOIRS[fuelType].capacity - \
            self.RESERVOIRS[fuelType].level

        print('TO REPLENISH {0:4.0f} GALLONS OF {1}' \
            .format(toReplenish, fuelType))
        print('-' * 70)

        # wait for the truck to dump the fuel into 
        # the reservoirs
        yield self.env.timeout(toReplenish \
            / self.SPEED_REPLENISH)

        # and then add the fuel to the available one
        yield self.RESERVOIRS[fuelType].put(toReplenish)

        # and pay for the delivery
        self.pay(toReplenish * self.buyPrice[fuelType])

        print('-' * 70)
        print('FINISHED REPLENISHING AT {0:4.0f}s.' \
            .format(self.env.now))
        print('-' * 70)

    def controlLevels(self):
        '''
            A method to check the levels of fuel (every 5s)
            and replenish when necessary
        '''
        while True:
            # loop through all the reservoirs
            for fuelType in self.RESERVOIRS:

                # and if the level is below the minimum
                if self.RESERVOIRS[fuelType].level \
                    < self.MINIMUM_FUEL[fuelType]:

                    # replenishs
                    yield env.process(
                        self.replenish(fuelType))
                # wait 5s before checking again
                yield env.timeout(5)

    def getPump(self, fuelType):
        '''
            Return a pump object
        '''
        return self.PUMPS[fuelType]

    def getReservoir(self, fuelType):
        '''
            Return a reservoir object
        '''
        return self.RESERVOIRS[fuelType]

    def getRefuelSpeed(self):
        '''
            Get how quickly the pumps work
        '''
        return self.SPEED_REFUEL

    def getFuelPrice(self, fuelType):
        return self.sellPrice[fuelType]

    def sell(self, amount):
        self.cashIn += amount

    def pay(self, amount):
        self.cashOut += amount

    def lost(self, amount):
        self.cashLost += amount

    def printCashRegister(self):
        print('\nTotal cash in:   ${0:8.2f}'\
            .format(self.cashIn))
        print('Total cash out:  ${0:8.2f}'\
            .format(self.cashOut))
        print('Total cash lost: ${0:8.2f}'\
            .format(self.cashLost))
        print('\nProfit: ${0:8.2f}'\
            .format(self.cashIn - self.cashOut))
        print('Profit (if no loss of customers): ${0:8.2f}'\
            .format(self.cashIn - self.cashOut \
                + self.cashLost))


class Car(object):
    '''
        Car class.
    '''
    def __init__(self, i, env, gasStation):
        '''
            The main constructor of the class

            @param i          -- consecutive car id
            @param env        -- environment object
            @param gasStation -- gasStation object
        '''
        # pointers to the environment and gasStation objects
        self.env = env
        self.gasStation = gasStation

        # details about the car
        self.TANK_CAPACITY = np.random.randint(12, 23) # gal
        
        # how much fuel left
        self.FUEL_LEFT = self.TANK_CAPACITY \
            * np.random.randint(10, 40) / 100

        # fuel type required by the car
        self.FUEL_TYPE = np.random.choice(
            ['PETROL', 'DIESEL'], p=[0.7, 0.3])

        # car id
        self.CAR_ID = i

        # start the refueling process
        self.action = env.process(self.refuel())

    def refuel(self):
        '''
            Refueling method
        '''
        # what's the fuel type so we request the right pump
        fuelType = self.FUEL_TYPE

        # let's get the pumps object
        pump = gasStation.getPump(fuelType) 

        # and request a free pump
        with pump.request() as req:
            # time of arrival at the gas station
            arrive = self.env.now

            # wait for the pump
            yield req

            # how much fuel does the car need
            required = self.TANK_CAPACITY - self.FUEL_LEFT

            # how long have been waiting for
            waitedTooLong = self.env.now - arrive > 5 * 60

            if waitedTooLong:
                # leave
                print('-' * 70)
                print('CAR {0} IS LEAVING -- WAIT TOO LONG'\
                    .format(self.CAR_ID)
                )
                print('-' * 70)
                gasStation.lost(required * self.gasStation\
                    .getFuelPrice(fuelType))
            else:
                # time of starting refueling
                start = self.env.now
                yield self.gasStation.getReservoir(fuelType)\
                    .get(required)

                # record the fuel levels
                petrolLevel = self.gasStation\
                            .getReservoir('PETROL').level
                dieselLevel = self.gasStation\
                            .getReservoir('DIESEL').level

                # and wait for it to finish
                yield env.timeout(required / gasStation \
                    .getRefuelSpeed())

                # time finished refueling
                fin = self.env.now

                # pay
                toPay = required * self.gasStation\
                    .getFuelPrice(fuelType)
                self.gasStation.sell(toPay)

                yield env.timeout(np.random.randint(15, 90))

                # finally, print the details to the screen
                refuellingDetails  = '{car}\t{tm}\t{start}'
                refuellingDetails += '\t{fin}'
                refuellingDetails += '\t{gal:2.2f}\t{fuel}'
                refuellingDetails += '\t{petrol}\t{diesel}'
                refuellingDetails += '\t${pay:3.2f}'

                print(refuellingDetails \
                    .format(car=self.CAR_ID, tm=arrive, 
                        start=int(start), 
                        fin=int(self.env.now), 
                        gal=required, fuel=fuelType, 
                        petrol=int(petrolLevel), 
                        diesel=int(dieselLevel),
                        pay=toPay
                    )
                )

    @staticmethod
    def generate(env, gasStation):
        '''
            A static method to generate cars
        '''
        # generate as many cars as possible during the 
        # simulation run
        for i in itertools.count():
            # simulate that a new car arrives between 5s 
            # and 45s
            yield env.timeout(np.random.randint(5, 45))
            
            # create a new car
            Car(i, env, gasStation)

if __name__ == '__main__':
    # what is the simulation horizon (in seconds)
    SIM_TIME = 20 * 60 * 60 # 10 hours

    # create the environment
    env = simpy.Environment()

    # create the gas station
    gasStation = GasStation(env)

    # print the header
    print('\t\t\t\t\t\t     Left')
    print('CarID\tArrive\tStart\tFinish\tGal\tType\tPetrol\tDiesel\tPaid')
    print('-' * 70)

    # create the process of generating cars
    env.process(Car.generate(env, gasStation))

    # and run the simulation
    env.run(until = SIM_TIME)

    gasStation.printCashRegister()

数据及程序
在这里插入图片描述

  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值