首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导MAT00027I编程、讲解program程序设计、辅导Java编程 讲解数据库SQL|解析C/C++编程
项目预算:
开发周期:
发布时间:
要求地区:
Mathematical Skills II (MAT00027I) 2020/21
Project 2 – An infectious disease
The model
The infectious disease MS2V-2020 is spreading across the world.∗ The disease is highly contagious:
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 reflected 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, fictitious, 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.
1
Mathematical 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 fixed 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 floating 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 specified in
the relevant question.
For full marks, make sure that you re-use work from previous question parts (via function/procedure
calls) as appropriate.
1) Individual agents
(a) Create a composite data type† Agent which contains the following fields, 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 field 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).
2
Mathematical Skills II (MAT00027I) 2020/21
function name aspect/field to be updated
move The agent moves one step on the board.
timeStep “Time after infection” reflects 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 first 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 file name (as String), which is used as the name of the output
file 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 file 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 specified (and documented).
‡Please use the file name as given in the parameter and do not, e.g., add an extra file extension.
3
Mathematical Skills II (MAT00027I) 2020/21
4) Documentation
Within the source code, add Javadoc comments to every class, every function and procedure
and every field (of composite data types). In these, describe the purpose of the function, class
or field, and document all parameters and return values. Also, document any assumption about
the parameter ranges, and any exceptions thrown.
4
Mathematical Skills II (MAT00027I) 2020/21
How to prepare your submission
Start by downloading the template files from Moodle. Most of the Java classes that you will
work with are already defined there.
Read the assignment sheet carefully. Be sure to implement all functions and procedures
with exactly the names, parameters and return types that are specified, and with parameters
in the order as given.
While preparing your code, please follow these style and formatting guidelines. (This forms
part of the assessment.)
• Place all code block delimiters – { and } – on separate lines.
• Within code blocks, indent the code by 4 spaces with respect to the surrounding code.
• Choose all names for variables, parameters, functions, and fields to start with a lowercase
character.
Make sure that your code compiles correctly. If the source code files that you submit do not
compile (for whatever reason), you will receive zero marks for the affected parts of the project.
The code template also includes a unit test. This test does not check the output of your
code – it only verifies whether you have declared your functions with the correct names and
with the correct parameter/return types. You are advised to use the unit test to check your
function declarations for any typos.
Test every piece of your code with meaningful test data (including any special or exceptional
values). Verify that the output of your functions is plausible.
Once you are satisfied with the code, create a JAR file in BlueJ as follows:
• Select “Project → Create Jar file” in the menu.
• Leave “Main class” set to “none”.
• Be sure to tick “Include source” and “Include BlueJ project files”.
• Click “Continue” and save the file in a convenient location.
This JAR file is the one that you need to submit.
Please do not mention your name or student number in the code, the documentation, or in
file names, as your submission will be graded anonymously.
Hand-in, late submissions
Please submit your work by uploading it on Moodle before
Wednesday, 20 January (week 2 Spring term), 14:00:00h.
Your submission should consist of the JAR file (see above) and of nothing else. Please be sure
to press the “Submit assignment” button on Moodle before the deadline. You will receive an
e-mail notification from Moodle when your assignment is submitted; if you have not received
this, please assume that your submission is not yet complete.
Late submissions will incur a penalty according to the University’s standard rules: “Work
which is up to one hour late will have five percent of marks deducted. After one hour, ten
percent of the available marks will be deducted for each day (or part of day) that the work is
late, up to a total of five days, including weekends and bank holidays, e.g., if work is awarded a
mark of 30 out of 50, and the work is up to one day late, the final mark is 25. After five days,
5
Mathematical Skills II (MAT00027I) 2020/21
the work is marked zero. Note, however, that the penalty cannot result in a mark less than
zero.”
If your submission is affected by Exceptional Circumstances (such as, being ill), you must
hand in an Exceptional Circumstances claim, accompanied by evidence. This should be done at
least two days before the deadline if feasible, and 7 days after the deadline at the very latest. For
questions in this respect, contact the Assessment Administrators at maths-exams@york.ac.uk.
Marking
Your submission will be marked as follows. Partial solutions are acceptable, and will be awarded
partial marks.
Code correctness (33 marks) Your code will be tested by an automated process (a collection
of unit tests) to check whether it works correctly for various values of the input parameters.
For each of these test cases that you pass, one mark will be awarded. Marks are awarded entirely
on the criterion whether the output values of your code match the conditions specified
on this assignment sheet.
Coding style (10 marks) Your source code will be read by the examiner. Marks will be
awarded to reflect whether your code is readable, is appropriately structured, and follows the
coding style conventions mentioned above. Marks may be subtracted for code that is functional
but is implemented in a non-transparent or overly complicated way.
Source code documentation (5 marks) These marks are awarded for appropriate Javadoc
comments in the code (see part 4).
In total, 48 marks are available. Your raw mark out of 48 will be moderated and scaled to
the University scale 0–100. This scaled mark will contribute 25% towards your final mark for
the module.
Academic integrity
To this project, the established Academic Integrity rules apply, as set out by the University.
In particular, you must not copy program code or the text of the documentation from fellow
students, or from other public or non-public sources. You must also not make your solution
available to fellow students before the deadline.
You are allowed to re-use example code from the lectures or practicals (though, where you
use it, you should include a comment to that effect in your source).
6
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!