代寫C C++ Java Python 視頻講解客服在線客服在線

代做國外C C++ Java程序 Python QQ 2365427650 Email 2365427650@qq.com 免費咨詢編程問題

« Intermediate Programmingoverloading Buffer »

An infectious disease

The infectious disease MS2V-2020 is spreading across the world.The disease is highly conta
gious: Any person that catches MS2V-2020 will, after an incubation time of 5 days, become
infectious and transmit the disease to anyone they come into close contact with. After 7 more
days, the disease subsides and the person is no longer infectious, but they remain immune
until 60 days after the original infection. After that, they can catch the illness again. While
MS2V-2020 does not lead to death, it can cause considerable discomfort for infected persons.
It is therefore imperative to understand how the disease spreads in the community.
The aim of this project is to produce a computer simulation for the spreading of MS2V-
2020. We model this disease as follows: Persons are simulated by “agents” that are located on
a “chess board” of 50 × 50 squares. A day in the real word is modelled by one “round” of the
simulation, and each of these rounds proceeds as follows (in this order):
Step 1 – Agents become infected: If any square of the board contains an infectious agent, then
all other agents in the same square become infected in this round (unless they are
already infected with the disease, or they are currently immune).
Step 2 – Agents move: Each agent moves by one square on the board, in a direction that will
be described below.
Step 3 – Counters updated: At this point, the time step is reflflected in the agent’s data, e.g.,
for an immune agent, the remaining time of immunity is decreased by 1 round.
Figure 1: A sketch of the “chessboard” that agents move on. Coordinates given as (x, y); agents
marked as black dots, arrows indicating direction of movement.
Health warning: This disease is, of course, fifictitious, and any similarity with past, present or future real-life
diseases is entirely accidental. We will be programming a “cartoon version” of a so-called agent-based model for
disease spreading, but none of the predictions here should be taken as realistic for any purpose.
1Mathematical Skills II (MAT00027I) 2020/21
To illustrate the counting of rounds: Suppose that an agent becomes infected in round 10
of the simulation. Then this agent will be infectious from round 15 to round 22 inclusive, but
will no longer be infected (no longer carry the disease) after round 22 (i.e., in round 23). The
agent will be immune against further infection until round 70 but not in round 71.
The movement of agents on the board is as follows. Positions on the board are labelled with
integer coordinates (x, y), as indicated in Fig. 1. Each agent has a fifixed direction of movement
– left, right, up, or down – that is assigned at the beginning of the simulation; and each round
they move by 1 square in that direction. However, when they have reached the boundary of
the board, then rather than moving one step “outside” the board, they reverse direction and
take one step in the new direction. They persist with the new direction of movement until they
reach the next boundary.
Tasks
Throughout this project, all flfloating point numbers are of double type and all integers of int
type. All parameters and array entries can be assumed to be non-null without further mention.
Any other assumptions on input parameters should be documented in the Javadoc comments.
Your code does not need to handle exceptional input values unless this is explicitly specifified in
the relevant question.
For full marks, make sure that you re-use work from previous question parts (via func
tion/procedure calls) as appropriate.
1) Individual agents
(a) Create a composite data typeAgent which contains the following fifields, all of integer type:
x and y, to contain the agent’s current position on the board,
direction, the agent’s current direction of movement, where the values 0, 1, 2, 3
stand for left, right, down, up respectively,
timeAfterInfection, which contains: the number of rounds after the agent has been
infected; 0 if the agent has become infected in the current round; -1 if the agent has
never been infected, or is no longer immune after an infection.
(b) In the class AgentActions, implement the following functions, all of which take an Agent
record as their only parameter, and return a true/false value. These functions should not
modify the contents of the input record.
function name
output
isInfected
whether the agent is currently infected with the disease
isInfectable
whether the agent can catch an infection during the current round
(rather than being immune)
isInfectious
whether the agent can infect others in the current round
(c) In the same class AgentActions, implement the following procedures that take an Agent
record as their only parameter, and update it as described below.
Note for those with some previous knowledge: Please do not add any constructors to the class Agent, or
indeed any other methods; do not declare the visibility of any fifield to be private. While these techniques may
be valid and useful for the model at hand, we will learn about them only in the Spring term, and they will
create problems in marking the current project (and may hence result in loss of marks).
2Mathematical Skills II (MAT00027I) 2020/21
function name
aspect/fifield to be updated
move
The agent moves one step on the board.
timeStep
“Time after infection” reflflects that one round has passed.
infect
The agent becomes infected with the disease in the current round.
2) Several agents
The functions/procedures described below should be implemented in the class Simulator; they
work with an array of agent records (i.e., of type Agent[]) as their parameters and/or return
values.
(a) Write a function countInfected that takes an array of agent records as input, and returns
the number of infected agents in the array.
(b) Write a function randomAgents that takes an integer n (assumed positive) and a real
number 0 p 1 as its input, and returns n agents with randomly chosen parameters as
follows:
The position of agents is independent and uniformly distributed across the squares.
Their direction of movement is also chosen independently and with equal probability
from the 4 available directions (left, right, down, up).
Each agent becomes infected (independently) with probability p, and infected agents
are at the very beginning of the disease period (“infected in the current round”).
Hint: A random integer j, uniformly distributed over 0 j < n, can be obtained with
(int) floor(n*random()), supposing that functions of the class java.lang.Math have been
imported in the usual way. Alternatively, the class java.util.Random can be used (cf. its
documentation).
3) The simulation
For the core of the simulation, add the following to the class Simulator.
(a) Write a procedure oneRound, acting on an array of agent records as its only parameter,
that processes one round of the simulation. That is, it performs step (1)–(3) as described
on the fifirst page of the assignment sheet, updating the agent records accordingly.
(b) Write a procedure runSimulation which takes four parameters: an integer n, a number
0 p 1, an integer r, and a fifile name (as String), which is used as the name of the output
fifile described below.
It should run the simulation with n agents, initially distributed at
random and with probability p of initial infection (see part 2(b) above), lasting r rounds.
The procedure should write the results of the simulation to a text fifile as follows. For each
round, one line should written with the following integer values, separated by commas:
Number of the round (starting from 0),
number of infected agents after the round,
number of infectious agents after the round.
number of agents after the round that are immune, but no longer infected.
I/O related exceptions should not be caught, but rather specifified (and documented).
Please use the fifile name as given in the parameter and do not, e.g., add an extra fifile extension.
3Mathematical Skills II (MAT00027I) 2020/21
4) Documentation
Within the source code, add Javadoc comments to every class, every function and procedure
and every fifield (of composite data types). In these, describe the purpose of the function, class
or fifield, and document all parameters and return values. Also, document any assumption about
the parameter ranges, and any exceptions thrown.
4

 

  • 相關文章:

發表評論:

◎歡迎參與討論,請在這里發表您的看法、交流您的觀點。

最新評論及回復

最近發表

Powered By Z-Blog 1.8 Walle Build 100427

Copyright 代寫C.

在線客服

售前咨詢
售后咨詢
微信號
Essay_Cheery
微信
悉尼代写,商科assignment代写,网课代修,论文加急-OnlyEssay 澳洲作业代写,essay代写,网课代修,exam代考-ESSAYSHIFU 代写essay,代写assignment|DRS英国论文代写留学推荐网站 Assignment代写,【essay代写】美国作业代写-留学代写ESSAY网 Dueduedue论文服务-【美国论文代写】加拿大论文ESSAY代写服务 ESSAYCASE |essay代写|assignment代写|paper代写,全球在线写作中心 EasyDue™-北美地区论文作业ESSAY代写服务机构,作业代写-覆盖100+全学科 EssayBerry:美国论文ESSAY代写服务,代写essay,统计代写,代写文章 EssayWill-论文代写网|经济代写,数学,CS代写,Assignment代写 Essaymint:专注软文代写和代写作业等服务|作业代写-100%原创高分