” 辅导MAT00027I编程、 写作program程序设计Mathematical Skills II (MAT00027I) 2020/21Project 2 An infectious diseaseThe modelThe 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, becomeinfectious and transmit the disease to anyone they come into close contact with. After 7 moredays, the disease subsides and the person is no longer infectious, but they remain immuneuntil 60 days after the original infection. After that, they can catch the illness again. WhileMS2V-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 ona chess board of 50 50 squares. A day in the real word is modelled by one round of thesimulation, 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, thenall other agents in the same square become infected in this round (unless they arealready 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 willbe described below.Step 3 Counters updated: At this point, the time step is reflected in the agents 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); agentsmarked 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-lifediseases is entirely accidental. We will be programming a cartoon version of a so-called agent-based model fordisease spreading, but none of the predictions here should be taken as realistic for any purpose.1Mathematical Skills II (MAT00027I) 2020/21To illustrate the counting of rounds: Suppose that an agent becomes infected in round 10of the simulation. Then this agent will be infectious from round 15 to round 22 inclusive, butwill no longer be infected (no longer carry the disease) after round 22 (i.e., in round 23). Theagent 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 withinteger 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 roundthey move by 1 square in that direction. However, when they have reached the boundary ofthe board, then rather than moving one step outside the board, they reverse direction andtake one step in the new direction. They persist with the new direction of movement until theyreach the next boundary.TasksThroughout this project, all floating point numbers are of double type and all integers of inttype. 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 inthe relevant question.For full marks, make sure that you re-use work from previous question parts (via function/procedurecalls) 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 agents current position on the board, direction, the agents current direction of movement, where the values 0, 1, 2, 3stand for left, right, down, up respectively, timeAfterInfection, which contains: the number of rounds after the agent has beeninfected; 0 if the agent has become infected in the current round; -1 if the agent hasnever been infected, or is no longer immune after an infection.(b) In the class AgentActions, implement the following functions, all of which take an Agentrecord as their only parameter, and Return a true/false value. These functions should notmodify the contents of the input record.function name outputisInfected whether the agent is currently infected with the diseaseisInfectable 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 Agentrecord 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, orindeed any other methods; do not declare the visibility of any field to be private. While these techniques maybe valid and useful for the model at hand, we will learn about them only in the Spring term, and they willcreate problems in marking the current project (and may hence result in loss of marks).2Mathematical Skills II (MAT00027I) 2020/21function name aspect/field to be updatedmove 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 agentsThe functions/procedures described below should be implemented in the class Simulator; theywork with an array of agent records (i.e., of type Agent[]) as their parameters and/or returnvalues.(a) Write a function countInfected that takes an array of agent records as input, and returnsthe number of infected agents in the array.(b) Write a function randomAgents that takes an integer n (assumed positive) and a realnumber 0 p 1 as its input, And returns n agents with randomly chosen parameters asfollows: The position of agents is independent and uniformly distributed across the squares. Their direction of movement is also chosen independently and with equal probabilityfrom the 4 available directions (left, right, down, up). Each agent becomes infected (independently) with probability p, and infected agentsare 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 beenimported in the usual way. Alternatively, the class java.util.Random can be used (cf. itsdocumentation).3) The simulationFor 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 describedon 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 number0 p 1, an integer r, and a file name (as String), which is used as the name of the outputfile described below.It should run the simulation with n agents, initially distributed atrandom 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 eachround, 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.3Mathematical Skills II (MAT00027I) 2020/214) DocumentationWithin the source code, add Javadoc comments to every class, every function and procedureand every field (of composite data types). In these, describe the purpose of the function, classor field, and document all parameters and return values. Also, document any assumption aboutthe parameter ranges, and any exceptions thrown.4Mathematical Skills II (MAT00027I) 2020/21How to prepare your submissionStart by downloading the template files from Moodle. Most of the Java classes that you willwork with are already defined there.Read the assignment sheet carefully. Be sure to implement all functions and procedureswith exactly the names, parameters and return types that are specified, and with parametersin the order as given.While preparing your code, please follow these style and formatting guidelines. (This formspart 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 lowercasecharacter.Make sure that your code compiles correctly. If the source code files that you submit do notcompile (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 yourcode it only verifies whether you have declared your functions with the correct names andwith the correct parameter/return types. You are advised to use the unit test to check yourfunction declarations for any typos.Test every piece of your code with meaningful test data (including any special or exceptionalvalues). 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 infile names, as your submission will be graded anonymously.Hand-in, late submissionsPlease submit your work by uploading it on Moodle beforeWednesday, 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 sureto press the Submit assignment button on Moodle before the deadline. You will receive ane-mail notification from Moodle when your assignment is submitted; if you have not receivedthis, please assume that your submission is not yet complete.Late submissions will incur a penalty according to the Universitys standard rules: Workwhich is up to one hour late will have five percent of marks deducted. After one hour, tenpercent of the available marks will be deducted for each day (or part of day) that the work islate, up to a total of five days, including weekends and bank holidays, e.g., if work is awarded amark of 30 out of 50, and the work is up to one day late, the final mark is 25. After five days,5Mathematical Skills II (MAT00027I) 2020/21the work is marked zero. Note, however, that the penalty cannot result in a mark less thanzero.If your submission is affected by Exceptional Circumstances (such as, being ill), you musthand in an Exceptional Circumstances claim, accompanied by evidence. This should be done atleast two days before the deadline if feasible, and 7 days after the deadline at the very latest. Forquestions in this respect, contact the Assessment Administrators at maths-exams@york.ac.uk.MarkingYour submission will be marked as follows. Partial solutions are acceptable, and will be awardedpartial marks.Code correctness (33 marks) Your code will be tested by an automated process (a collectionof 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 entirelyon the criterion whether the output values of your code match the conditions specifiedon this assignment sheet.Coding style (10 marks) Your source code will be read by the examiner. Marks will beawarded to reflect whether your code is Readable, is appropriately structured, and follows thecoding style conventions mentioned above. Marks may be subtracted for code that is functionalbut is implemented in a non-transparent or overly complicated way.Source code documentation (5 marks) These marks are awarded for appropriate Javadoccomments in the code (see part 4).In total, 48 marks are available. Your raw mark out of 48 will be moderated and scaled tothe University scale 0100. This scaled mark will contribute 25% towards your final mark forthe module.Academic integrityTo 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 fellowstudents, or from other public or non-public sources. You must also not make your solutionavailable to fellow students before the deadline.You are allowed to re-use example code from the lectures or practicals (though, where youuse it, you should include a comment to that effect in your source).如有需要,请加QQ:99515681 或WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。