CS 310

Programming Assignment 4

Due April 27, 2014 5:00 P.M.

About 15 years in the future...
The Martian Adventure Recreational Society, or MARS (no affiliation to M&M
Mars Candy company) has a problem. Ever since it opened up Mars for space
tourism, the number of visitors to Mars has been overwhelming and has been the
company's biggest moneymaker. However, a small percentage of tourists have died
after returning to Earth, and this has threatened to cut into MARS' profits.

It seems that while visiting the red
planet, approx. 5% of visitors encounter a microbe which attaches to their
systems immediately upon contact. Although it appears to remain dormant so long
as the contractants remain on Mars, upon contact with Earth's polluted
atmosphere, this microbe reacts violently, causing death within 10 to 15
minutes of penetrating the atmosphere. Fortunately, the crack biochemists at
MARS have developed a cure which will render the microbe harmless. The cure is
100% effective if administered in time to take full effect. However, the cure
requires two separate doses: the first dose is standard, but the second dose
varies depending upon the individual's reaction to the first dose. Therefore,
in order for the cure to be effective, each individual must be monitored carefully
for the two minutes following the first dose, in order for the administering
physician to determine the correct amount of the second dose. Once the correct
second dose is received, it takes approximately one minute to circulate
completely through the bloodstream to disable the microbe. The result of these
requirements is that although the cure can be 100% effective, an infected
individual must receive the first dose at
least 3 minutes prior
to his/her pending death (time to wait two minutes
after receiving the first dose, plus one minute after receiving the second
dose) in order for the treatment to cure the microbe.

The current procedure for attending to
the tourists who return from Mars is to place each returning tourist in a
standard queue to receive the cure as s/he arrives back on Earth. All tourists
receive the cure as a precaution, since it has been shown by the MARS
scientists that receiving the treatment causes no ill effects, even when the
microbe is not present. However, there is only one doctor available at any
given time to administer and observe the person receiving the cure. Also, the
doctor observes the person for both phases of the cure. Thus the doctor is
unable to administer the cure to the next person
in line until this time period for the current person's second dose has passed.
Unfortunately, some tourists have died from microbe exposure while waiting in
line to receive the cure.

In order to avoid this problem, the MARS
scientists have developed a test that can harmlessly detect the presence of the
microbe. However the test, which takes 2 minutes to administer and provide
results, does not detect the presence of the microbe with 100% accuracy.
Instead, it gives the result as a percentage (from 0% to 100%) that an
individual has the microbe. The MARS scientists have determined that if a
person has the microbe present, the test result is in the range of 40%-100%.
Also, if a person does not have the microbe present, the test result is in the
range of 0%-80%. (In other words, any result less than 40% means that the
individual is not infected, and any result greater than 80% means that the
individual is definitely infected, although this result is unrelated with how
many minutes the individual will survive without the cure.)

MARS wishes to see how well the test for
the microbe can avoid tourist fatalities and has come up with the following
alternative to handle tourist arrivals which uses two queues: 1) a standard
"Testing" queue, and 2) a priority "Treatment" queue. When
a tourist arrives, MARS employees check to see whether the doctor administering
the cure is available, and whether both queues are empty, in which case the
tourist immediately is given the first treatment dose. Otherwise, the tourist
enters the Testing queue (thereby delaying his/her entrance to the Treatment
queue for at least two minutes). Once the test result is obtained, unless the
tourist tests negative for the microbe (a result of less than 40%), s/he enters
the Treatment queue in a position that is determined by the result of the test:
the higher the percentage obtained on the test, the closer s/he is placed
towards the head of the queue. (In case of ties, tourists should be placed in
the queue in order of their arrival.)

Having concluded all testing of both the
test and cure and having received FDA approval to administer them to any
potentially infected individuals, MARS now wishes to determine which scenario
will best minimize the number of tourist fatalities. They are thus approaching
your company (since we are all hopeful that 15 years from now you will have
graduated from GMU and have a job) to implement both scenarios and help MARS
decide which one will be the most effective.

Trips
to Mars

The method that MARS uses to transport passengers to and from the red planet is
a closely held secret. However, MARS has given you the following specifications
to model how tourists return:

Tourists return one at a time.

The probability that a tourist returns in
any time step is 20%.

Once a tourist returns, the "microbe
clock" starts ticking.

If a tourist has encountered the microbe,
s/he will die within 10-15 minutes of his/her arrival time if the cure has not
been administered and completed before that time. (Your model should randomly
compute the precise amount of time remaining for each returning tourist.)

Once a tourist arrives on Earth, s/he
enters queues in accordance to the scenario that is being tested (Scenario 1
contains only one queue - Treatment, while Scenario 2 contains two queues – Testing and Treatment).

Each tourist in line is dequeued
according to the appropriate scenario. If a tourist is found to be DOA when
s/he arrives at the head of either queue, the death is recorded and the
individual is removed from the queue. You may assume this requires no
additional time (since in real life, this presumably would have been noticed
prior to arrival at the front of the line).

If a person occupying either the Testing
or Treatment queue dies, the death is recorded and the individual is removed.
Because this occurs while being attended to, you may assume that no additional
time is necessary for removing the deceased individual.

Scenario
1
In this scenario, each
tourist enters one queue to receive treatment. The Treatment queue is a
standard (non-prioritized) queue. The next person in line exits the queue as
soon as the doctor administering the treatment becomes available, but must wait
with the doctor until the treatment is complete (or until s/he runs out of time
and dies). Thus, the cure is not administered while the tourist is in the
queue, and the tourist cannot leave until the procedure for the cure is
complete.

Scenario
2
In this scenario, each
tourist that returns checks to see if the doctor administering the cure is
available. If the doctor is idle, AND there are no other tourists around
(either at the testing station, or in either queue) the tourist immediately
goes to the doctor for treatment. Otherwise, the tourist enters the Testing
queue to be tested for the microbe. The Testing queue is a standard queue. As
soon as the tester is available, the tourist at the head of the queue exits the
queue and receives the test. S/he then waits in the testing station to receive
his/her test results. As soon as the test results are obtained, the tourist
enters the Treatment queue in the appropriate position, based upon the results
received from the test. The Treatment queue is a Priority queue. All tourists
then wait in the Treatment queue until they receive treatment or are removed.
Note that tourists whose test results are below the threshold are free to leave
and do not enter the Treatment queue.

Implementation
In order to implement this project, you will need to create several classes.
The first class is a generic Queue class. You must implement this class using a
linked list.

The Queue class must contain the
following member functions:

Constructor

Enqueue

Dequeue

Insert
into queue by priority

Is_Empty

The second class is the Tourist class.
This class contains information about the tourist such as time of arrival,
whether s/he is infected with the microbe, time remaining before death
(assuming s/he is infected and receives no treatment), the result of the test
if/when administered, etc. Use appropriate member functions and member
variables to represent this information.

The third class is the Scenario_1 class.
This class contains a member variable of type Queue to hold the arriving
tourists, as well as member variables to keep track of the current simulation
time, the number of tourists that have arrived, the number of tourists that
have encountered the microbe, the number of tourists that have died, occupancy
of the cure station, etc. It also contains member functions to handle the
tourists that arrive, such as putting them into the queue or sending them to
the doctor for treatment, etc.

The fourth class is the Scenario_2 class.
This class is similar to the Scenario_1 class, except that it contains two
queues (the standard queue used for the line to receive the test, and the
priority queue used for the line to receive treatment). This class also
contains information about the testing station.

You may wish to add additional classes
depending upon the overall design of your program.

Running
the simulation

Tourists are only able to arrive from Mars within a time span of 12 hours per
day (when there is a direct line of sight from the MARS facility to the planet
Mars). Therefore, you will run the simulation for 12 hours, using 30 second
time increments (for a total of 1440 time steps). At the end of the simulation,
you will need to empty all the queues before ending the program. (In other
words, treat the poor tourists who are still in line. :-)

Your program should allow the user to
choose which scenario to run, prompt the user for specific information as
necessary (see below), then run the simulation and print the results.

User
Input

Because MARS intends to expand its choice of destinations to other celestial
bodies, it wishes to be prepared in case its customers should become infected
by different microbes at these other locations. Therefore, MARS has requested
that you make your program reusable for these other potential scenarios by
allowing the user to input data that may change given other situations.
Accordingly, you must prompt the user for the following information for use in running
your simulation:

A
random number seed (integer)

Which
scenario to run (integer – 0 or
1)

Verbose
or Normal output (see below for output) (integer – 0 for Normal, 1 for Verbose)

Number
of time steps in simulation (integer)

Probability
that a tourist arrives in any given time step (0.0 < floating point <
1.0)

Percentage
of tourists infected by the microbe (0.0 < floating point < 1.0)

Minimum
survival time of an infected tourist in time steps (integer)

Maximum
survival time of an infected tourist (integer)

Time
for first stage of cure, once administered (integer)

Time
for second stage of cure, once administered (integer)

Additional input needed for Scenario 2:

Time
needed to test for the microbe (integer)

Lower
bound result for possibly infected individuals (Below this value, the tourist
does not have the microbe) (0.0 < floating point < 1.0)

Upper
bound result for those not infected (Above this value, the tourist definitely
has the microbe) (0.0 < floating point < 1.0)

So, for the Mars tourists, pertinent
inputs would be:

Random
number seed: make one up

Scenario
Choice: (1 or 2)

Normal
or Verbose output: (0 or 1)

Number
of time steps in simulation:1440 (12 hours at 30 second time steps)

Probability
that a tourist arrives in any given time step: 0.2

Percentage
of tourists infected by the microbe: 0.05

Minimum
survival time of an infected tourist: 20 (10 minutes for 30 second time steps)

Maximum
survival time of an infected tourist: 30 (15 minutes for 30 second time steps)

Time
steps for first stage of cure: 4

Time
steps for second stage of cure: 2

When running simulation 2, the following
inputs are also needed:

Time
steps to test for microbe: 4

Lower
Bound of test accuracy: 0.4

Upper
Bound of test accuracy: 0.8

Additional
Requirements:

Since it may be tedious to enter all of these values during the debugging stage
of the development, you should allow for a filename to be entered as a command
line argument. If a filename is contained on the command line, that file will
be used as input instead of prompting the user for input. The format and order
of input for this file must follow the above input specification.

In order to use the same information
regarding tourist arrivals between the two simulations, before starting the
clock for the simulation, you should generate all tourist arrivals (including
time of arrival, whether they have the microbe, the result of the test and the
time of death if they do have the microbe) and put them in a separate “arrival”
queue. Then for each time step, check to see if the next tourist arrives during
that time step, and if so, dequeue them and place them in the testing or
treatment queue as appropriate. If tourists are generated in this manner, the
same seed value for the random number generator should result in the same tourist
data between the two simulations.

Output
Allow for your simulation to be run in either verbose mode (which is useful for
debugging) or normal mode. Verbose mode will print information at each time
step, such as whether a tourist has just arrived, the number of tourists in the
queue(s), the current state of the test/treatment stations, the number of
infected tourists saved, the number of infected tourists that have died, and
any other information you deem appropriate.

At the end of the simulation, your program
will print out the following simulation results:

For both Scenarios:

Total
number of time steps for the simulation

Total
number of tourists returning from Mars

Total
number of returning tourists who were infected

Total
number of cures administered

Total
number of infected tourists saved

Total
number of infected tourists who died before receiving treatment

Total
number of infected tourists who died after beginning treatment

Additional output for Scenario 2:

The average of the test results returned
for the tourists

If you find that any other information or
statistics seem appropriate or necessary for a proper evaluation and comparison
of the two scenarios, you should print those out as well.

An
Implementation Suggestion

Since Scenario_2 class will be similar to
the Scenario_1 class, you may wish to have it inherit from Scenario_1. Or you
might decide to create a Scenario class from which both Scenario_1 and
Scenario_2 inherit.

Project
Report Information & Discussion

Run both scenarios many times using different random seeds (at least 10) and
plot the results on a graph (plot Deaths per Number of Returning Tourists
and/or some other metrics). Based upon the results, draw a conclusion on which
scenario is better (assuming one is) and explain why it is likely the case.
Also, exercise the scenarios using different input values and show how the data
supports your answers the following questions:

How
significantly does the percentage of tourists infected affect the results
(assuming no other input values are changed)?

How
does an increase in the probability of tourist arrival affect each scenario?

How
does adjusting the lower and upper bounds of the test affect the results?

What
if MARS develops a cheaper test, but it takes several time steps longer to get
the result?

At
what point does the death rate for the tourists rise significantly? (You may
want to graph the results using several random seed values)

If the
MARS scientists can create a cure that works just a bit faster (one or two time
steps, for example) will it make the test portion of Scenario 2 unnecessary?

Finally, discuss at least one other
method to handling returning tourists that you believe may be useful for MARS
to investigate based upon your findings and why this method may be worth coding
(This is called “Trying
to get additional money from the customer”).

Submitting
your assignment

Submit in Blackboard:

Source
code for all classes

Output
generated by executing the main() methods of classes

The
project report discussed above

A page
stating which parts of the assignment (if any) are incomplete or known to be
incorrect.

Create
a zip file of your files and submit it to the course Blackboard page.

On
Blackboard:

Click
on the Assignments section

Click
on the Programming Assignment 4link

Scroll
down to "Attach a File"

Click
"Browse My Computer"

Select
your Zip file

You
can resubmit to Blackboard as many times as you like up to the deadline

程序-代写(qq:928900200)的更多相关文章

  1. c++程序代写(qq:928900200)

     1. Both main memory and secondary storage are types of memory. Describe the difference between the  ...

  2. C语言程序代写(QQ:928900200)

    1.学生成绩统计 要求描述: 用结构数组实现学生信息的统计功能. struct student { long no; /*学号*/ char name[10]; /*姓名*/ char sex; /* ...

  3. SmileyCount.java笑脸加法程序代写(QQ:928900200)

    SmileyCount.java 1/4Java Programming 2014Course Code: EBU4201Mini ProjectTask 1 [30 marks]SmileyCoun ...

  4. java程序开发代写(QQ:928900200)

    条件:手机1.2都是安卓智能机,手机1开热点,手机2链接手机1,功能:A手机2通过刷手机网页,登陆手机1设定的页面并下载其手机的指定文件,B手机1控制手机2的流量,当通过的流量多的时候,停止流量的供应

  5. C++程序代写实现HashSet class

    C++程序代写实现HashSet class 专业程序代写(QQ:928900200) Implement a HashSet class for elements of type string.It ...

  6. 基于JAVA WEB技术旅游服务网站系统设计与实现网上程序代写

    基于JAVA WEB技术旅游服务网站系统设计与实现网上程序代写 专业程序代写服务(QQ:928900200) 随着社会的进步.服务行业的服务水平不断发展与提高,宾馆.酒店.旅游等服务行业的信息量和工作 ...

  7. 如何鉴别程序抄袭c语言程序代写

    如何鉴别程序抄袭:如何鉴别一份程序代码是抄袭另一份程序.输入:两个C语言源程序文件 输出:抄袭了多少?给出最相似的片段,判断是谁抄袭了谁? 提示:首先进行统一规范化排版,去掉无谓的空格.空行,然后比对 ...

  8. c编写程序完成m名旅客和n辆汽车的同步程序代写

    jurassic公园有一个恐龙博物馆和一个公园,有m名旅客和n辆汽车,每辆汽车仅能允许承载一名旅客.旅客在博物馆参观一阵,然后排队乘坐旅行车.当一辆车可用时,他载入一名旅客,再绕花园行驶任意长的时间. ...

  9. 实验教学管理系统 c语言程序代写源码下载

    问题描述:实验室基本业务活动包括:实验室.班级信息录入.查询与删除:实验室预定等.试设计一个实验教学管理系统,将上述业务活动借助计算机系统完成. 基本要求: 1.必须存储的信息 (1)实验室信息:编号 ...

  10. 模拟游客一天的生活与旅游java程序代写源码

    在某个城市的商业区里,有一家首饰店,一家饭店,一家面馆,一家火锅店,一家银行,一家当铺 现在有一群来自四川的游客,一群陕西的游客,一群上海的游客,和以上各店家的工作人员在此区域里,请模拟他们一天的生活 ...

随机推荐

  1. C# OpenFileDialog打开文件对话框(详解)

    一.打开文件对话框(OpenFileDialog) 1. OpenFileDialog控件的基本属性 InitialDirectory:对话框的初始目录 Filter: 获取或设置当前文件名筛选器字符 ...

  2. C++ 随机数rand()和srand()

    标准函数库中函数rand()可以生成0~RAND_MAX之间的一个随机数,其中RAND_MAX 是stdlib.h中定义的一个整数,它与系统有关. 例如在我的机器上,RAND_MAX=32767.可以 ...

  3. thinkphp5 学习笔记

    一.开发规范: 二.API: 1.数据输出:新版的控制器输出采用 Response 类统一处理,而不是直接在控制器中进行输出,通过设置 default_return_type 就可以自动进行数据转换处 ...

  4. wampServer 安装 Redis 扩展

    REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统. Redis是一个开源的使用ANSI C语言编写.遵守B ...

  5. vs2010中关于HTML控件与服务器控件分别和js函数混合使用的问题

    此文档解决以下问题: 1.在.cs文件中如何访问html控件? 在html控件中添加属性runat="server"即可 2.在html控件中,如何调用js函数? 在html控件中 ...

  6. 在Win7 64位旗舰版下,利用Vs2008编译64位的Qt 4.8.2

    1.下载qt-everywhere-opensource-src-4.8.2.zip. 2.VS2008需要安装x64编译器. 3.将qt-everywhere-opensource-src-4.8. ...

  7. JDBC(5)—DatabaseMetaData

    1.简介: 使用元数据已实现通用的查询方法.元数据介绍:使用jdbc获得连接之后,得到一个Connection对象,可以通过这个对象获得DataBaseMetaData对象,该对象可以获得有关数据库管 ...

  8. python接口自动化28-requests-html爬虫框架

    前言 requests库的好,只有用过的人才知道,最近这个库的作者又出了一个好用的爬虫框架requests-html.之前解析html页面用过了lxml和bs4, requests-html集成了一些 ...

  9. RxJava2 源码解析(二)

    概述 承接上一篇RxJava2 源码解析(一),本系列我们的目的: 知道源头(Observable)是如何将数据发送出去的.    知道终点(Observer)是如何接收到数据的.    何时将源头和 ...

  10. .Net AppDomain详解(二)

    AppDomain 类 表示应用程序域,它是一个应用程序在其中执行的独立环境. 此类不能被继承. 命名空间:   System程序集:  mscorlib(位于 mscorlib.dll) 继承层次结 ...