1、数学建模渡口问题 建模问题(渡口问题)摘要 本文建立了一个关于如何安排过河车辆位置问题的模型本文首先对各种车辆达到情况作统计,并对车辆之间得特性进行分析,得出以下安排车辆位置方案:摩托车少而且站位小,以插空的方式进入车队列,这样安排明显减少了空间浪费。本文重概率论角度,引进均匀分部函数已经随机数,对来的车辆先后进行描述,随后通过若干组数据统计,最后得出一般规律并解决安排车辆问题。问题重述与分析:一个渡口的渡船营运者拥有一只甲板长 32 米,可以并排停放两列车辆的渡船。他正在考虑怎样在甲板上安排过河车辆的位置,才能安全地运过最多数量的车辆,并关心一次可以运多少辆车,其中有多少小汽车,多少卡车,多
2、少摩托车,他观察了数日,发现每次情况不尽相同,但他得到下列数据和情况:(1)车辆随机到达,形成一个等待上船的车列。(2)来到渡口的车辆中,轿车占 40 ,卡车占 55 ,摩托车占 5 (3)轿车车身长为 3.5 5.5 米,卡车车身长为 8 10 米。请考虑以下问题:(1)应该怎样安排摩托车?(2)怎样描述一辆车的车身长度?(3)到达的车要加入甲板上两列车队的哪一列中去?(4)如何考虑“安全”问题?请就以上问题建立数学模型,最终保证安全,并运用计算机进行模拟车辆到达、安排停车过程。 模型假设与建立:(1) 营运者需要在安全情况下运过最多数量的车,摩托车如果横着放的话会节省很多空间,所以我们假定
3、把摩托车横着放置在两辆车的中间,这时就要考虑摩托车的宽度而不是长度了。我们假定摩托车的宽度是0.6 0.8米(为方便起见,后文中摩托车的“宽度”都说成“长度”)。 (2) 一共有三种车:轿车、卡车和摩托车。三种车的出现概率不同,每辆车的车身长度也不相同,我们想到可以用随机数来确定每一辆车的类型和长度。 0 0.55 0.95 1.0 卡车 轿车 摩托车 图1如图1所示,用一个0到1之间的随机数的分布来确定车的所属类型。当random=00.55时,为卡车;当random=0.550.95时,为轿车;当random=0.951.0时,为摩托车。车身的长度问题也应用这个思路。题中给出轿车的长度为3
4、.55.5,重新定义一个01之间的随机数random。3.5和5.5之间的差值是2,即:random*2,所以轿车的车身长度为:Length=(3.5 + random * 2)。同理得出:卡车的车身长度为:length=8 + random * 2,摩托车的车身长度为:length=0.6 + random * 2。(图2) 3.5 2轿车 8 2卡车 0.6 0.2摩托车 图2(3)由于甲板上一共可以停放两列车,所以车上甲板的顺序就不确定。通过我们的研究发现,如果将这一问题考虑的过于复杂会导致算法过于复杂,问题复杂化。所以我们设定先来的车先都上同一个甲板,当第一个甲板排满之后再排第二个甲板
5、。(4)船在海上行驶的时候会有摇晃,为了保证安全,车辆之间应该留有一定的空间,我们假定为0.4米。首辆车距离甲板头我们定为0.5米。最后一辆车通常情况下一定会和船尾有一定距离,所以不需再空出距离了。具体解决问题:经过讨论决定使用java语言来编译一个模拟环境,模拟出两个甲板和每个甲板上停车的数量、类型。首先我们编写了3个车的类:Car、Truck和Motorcycle。接着是假定每个相同车类组成的队列类:CarDateBase、TruckDateBase、MotorcycleDateBase。最后是模拟类:Demo。(详见附录)最后用这几个类组成一个完整的模拟程序。测试出来的结果如下。测试结果
6、:(1)随机出来的车的长度:车的类型 长度1轿车4.2952轿车4.7233轿车4.5984轿车5.1915轿车3.7426轿车4.8527摩托车0.7448摩托车0.6559摩托车0.6810摩托车0.78511摩托车0.74212摩托车0.7513卡车8.23414卡车8.56415卡车8.4516卡车9.19517卡车8.00818卡车9.433 轿车数量卡车数量摩托车数量总长度测试1 1 3 0 31.5 测试2 0 3 0 31 测试3 0 3 2 31.4 测试4 0 3 1 31.2 测试5 6 0 0 31.1(3) 测试出来的每个板上的车的种类和数量:总结: 以上只是一部分测
7、试数据,总体上来看,我们完成了题目中的要求。由于是第一次参赛而且时间比较紧,我们的这个建模做得还不是很完美,有几个细节的地方只能是假定一种情况,而不能将所有的情况都写出来。 希望下次能将我们所想的全部都表达出来。 最重要的是我们通过这次活动学到很多,为我们的专业学习也带来了很大的帮助,以后一定会继续努力,争取在建模和编程上有所成就!附录模拟停车的java程序:(1)Car类:public class Car private double length; public Car(double d) this.length=d; public double getLength() return le
8、ngth; (2)Truck类:class Truck private double length; public Truck(double l) this.length=l; public double getLength() return length; (3)Motorcycle类:class Motorcycle private double length; public Motorcycle(double l) this.length=l; public double getLength() return length; (4)CarDataBase类:import java.uti
9、l.*;class CarDataBase private Vector cars; public CarDataBase() cars=new Vector(); public void addCar(Car initialcar) this.cars.add(initialcar); public Iterator getCarIterator() return cars.iterator(); public Car getCar(float length) for (Iterator i = cars.iterator(); i.hasNext();) Car temp =(Car) i
10、.next(); if (temp.getLength() = length) return temp; return null; public int getNumberOfCars() return this.cars.size(); (5)TruckDataBase类:import java.util.*;class TruckDataBase private Vector trucks; public TruckDataBase() trucks=new Vector(); public void addTruck(Truck initialcar) this.trucks.add(i
11、nitialcar); public Iterator getTruckIterator() return trucks.iterator(); public Truck getTruck(float length) for (Iterator i = trucks.iterator(); i.hasNext();) Truck temp =(Truck) i.next(); if (temp.getLength() = length) return temp; return null; public int getNumberOfTrucks() return this.trucks.siz
12、e(); (6)MotorcycleDataBase类:import java.util.*;class MotorcycleDataBase private Vector motorcycles; public MotorcycleDataBase() motorcycles=new Vector(); public void addMotorcycle(Motorcycle initialmotorcycle) this.motorcycles.add(initialmotorcycle); public Iterator getMotorcycleIterator() return mo
13、torcycles.iterator(); public Motorcycle getMotorcycle(float length) for (Iterator i = motorcycles.iterator(); i.hasNext();) Motorcycle temp =(Motorcycle)i.next(); if (temp.getLength() = length) return temp; return null; public int getNumberOfMotorcycle() return this.motorcycles.size(); (7)Dome类: imp
14、ort java.util.*;public class Dome private CarDataBase cardatabase; private TruckDataBase truckdatabase; private MotorcycleDataBase motorcycledatabase; private int NUMBEROFCARS=0; private int NUMBEROFTRUCKS=0; private int NUMBEROFMOTORCYCLES=0; private double TOTLELENGTH=0; private static int RAN; pu
15、blic Dome() cardatabase=loadCar(); truckdatabase=loadTruck(); motorcycledatabase=loadMotorcycle(); public static void main(String args) Dome a=new Dome(); Dome b=new Dome(); for(int i=0;i10;i+) RAN=(int)(Math.random()*1000); a.run(); System.out.println(NUMBEROFCARS are+a.NUMBEROFCARS); System.out.pr
16、intln(NUMBEROFTRUCKS are+a.NUMBEROFTRUCKS); System.out.println(NUMBEROFMOTORCYCLES are+a.NUMBEROFMOTORCYCLES); System.out.println(TOTLELENGTH is+(double)(int)(a.TOTLELENGTH*100)/100); for(int j=0;j10;j+) RAN=(int)(Math.random()*1000); b.run(); System.out.println(NUMBEROFCARS are+b.NUMBEROFCARS); Sys
17、tem.out.println(NUMBEROFTRUCKS are+b.NUMBEROFTRUCKS); System.out.println(NUMBEROFMOTORCYCLES are+b.NUMBEROFMOTORCYCLES); System.out.println(TOTLELENGTH is+(double)(int)(a.TOTLELENGTH*100)/100); private CarDataBase loadCar() / System.out.println(loadCar!); CarDataBase cardatabase=new CarDataBase(); f
18、or(int i=0;i10;i+) double ran=(double)(Math.random()*2); cardatabase.addCar(new Car(3.5+ran); return cardatabase; private TruckDataBase loadTruck() TruckDataBase truckdatabase=new TruckDataBase(); for(int i=0;i4;i+) double ran=(double)(Math.random()*2); truckdatabase.addTruck(new Truck(8.0+ran); ret
19、urn truckdatabase; private MotorcycleDataBase loadMotorcycle() MotorcycleDataBase motorcycledatabase=new MotorcycleDataBase(); for(int i=0;i100;i+) double ran=(double)(Math.random()*0.2); motorcycledatabase.addMotorcycle(new Motorcycle(0.6+ran); return motorcycledatabase; private boolean Judge() if(
20、TOTLELENGTH=0&RAN450) for(Iterator i=cardatabase.getCarIterator();i.hasNext();) Car cars=(Car)i.next(); if(TOTLELENGTH=0) TOTLELENGTH+=0.5; else if(TOTLELENGTH=450&RAN=950) for(Iterator i=truckdatabase.getTruckIterator();i.hasNext();) Truck trucks=(Truck)i.next(); if(TOTLELENGTH=0) TOTLELENGTH+=0.5;
21、 else if(TOTLELENGTH950&RAN=1000) for(Iterator i=motorcycledatabase.getMotorcycleIterator();i.hasNext();) Motorcycle motorcycles=(Motorcycle)i.next(); if(TOTLELENGTH=0) TOTLELENGTH+=0.5; else if(TOTLELENGTH=32-0.4) TOTLELENGTH+=0.4; TOTLELENGTH+=motorcycles.getLength(); if(Judge() System.out.println(This motorcyclelength is +(double)(int)(motorcycles.getLength()*1000)/1000); NUMBEROFMOTORCYCLES+; else TOTLELENGTH-=motorcycles.getLength();
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1