We have learned: • Types, Strings, Variables • Conditions • Functions, methods & sequences • Iteration(loops), lists & sequences • List, mutability • Function debugging • Dictionaries and sets •...

first year project (An example project has been attached)- Simple python language
-No lamdas- (#)With comments
Thanks a lot.


We have learned: • Types, Strings, Variables • Conditions • Functions, methods & sequences • Iteration(loops), lists & sequences • List, mutability • Function debugging • Dictionaries and sets • Namespaces • Modules, file access • Recursion • Iterators • Character encoding Question 1 Question 2 Question 3 Infectious diseases In this project we will look at four different problems related to infectious diseases • How to build a population network (Question 1) • How to model an infectious disease outbreak on this network (Question 2) • How to identify the central person in a population network (Question 3) • How to measure the impact of vaccinating this central person (Question 4) Building our population network We will treat a population as a network in which: • each node represents a person; and • each link between two nodes indicates that those two people spend time together, and may transmit infection. Each person i in our population has a level of protection (immunity) pi against being infected. This level of protection is represented as a floating point number between 0.0 and 1.0, where 0.0 indicates no protection against getting infected and 1.0 indicates full protection against getting infected. Each link in our network between person i and person j is associated with a weight, wij also represented as a floating point number between 0.0 and 1.0. This number indicates how much contact those two people have and hence the risk that they will transmit infection. A value of 0.0 refers to no contact between those two people, and increasing wij indicates more contact, and hence more opportunity for infection. In network terms, we refer to the set of people who are linked to person i as person 's neighbourhood N(i). A person that is connected to another person, is referred to as a direct neighbour. Format of input data The data describing a population is contained in an input text file with the following structure: n p_i ... i, j, w_{ij} ... The first line contains a single integer indicating the number of people/nodes in the population/network. The next lines each consist of a single floating point number corresponding to the level of protection pi of person i (one line per person). The remaining lines each contain three values i, j , and wij specifying the beginning, end and weight of each link in the network. Note: • all links are symmetrical; that is, wij = wji . If is connected to with weight w, then j is also connected to with weight w (implicitly, the input file only needs to specify the link once); • links cannot connect a node to itself; that is wij = 0.0; and • only one link can exist between the same pair of nodes. Input files that violate the last two constraints are invalid. Example For example, the file net.dat: 3 0.4 0.8 0.6 0,1,0.3 0,2,0.25 defines a network containing three people 0, 1 and 2 with level of protection 0.4, 0.8 and 0.6 respectively. Person 0 is connected to both 1 and 2, with weights 0.3 and 0.25 respectively, as shown in the following diagram: Question 1 Build Network Write a function parse_network(input_file) that parses a file with the structure described above, and returns a tuple containing: 1. a list of length n, where the ith element of the list contains person i's level of protection pi; and 2. a matrix (that is, a two-dimensional array, or a list of lists) in which the ij’th element contains the weight of the link between person i and person j. For example (using the network described above and stored in the text file net.dat): You may assume that the input file is well structured (as described above); however, if the input file describes a network that is invalid, the function should return None. Answer: Modelling an infectious disease outbreak Modelling an infectious disease outbreak The next step is to simulate an infectious disease spreading through our population. We will simulate this as an iterative process, where each iteration corresponds to a single day. Each person in the population can be either: • not yet infected, but susceptible to being infected by others; or • infected and capable of infecting others. Once a person becomes infected, they remain infected forever. At the beginning of the simulation (day ), everyone is susceptible, except for one person who is infected. During each day, every person in the population has contact with each of their neighbours, and people who are susceptible may contract disease as a result of contact with neighbours who are infected. Susceptible individuals who become infected during a day, will not be infectious to others until the following day. The rules of disease spread On each day, each susceptible person may become infected depending on the amount of contact they have (ie, the weight of their links) with neighbours who are infected, and their level of protection. Specifically, a susceptible person will become infected if the value 1 – e-fi > pi, where fi is sum of the weights on the links between i and the subset of their neighbours N(i) who are infected. Remember: you can calculate exponentials using the exp function from the Python math library: Example For example, consider the network below, in which people 0, 2 and 3 are susceptible (blue), and person 1 is infected (red) at the beginning of day 0: There are three susceptible people in the population, so we consider each of them in turn to determine whether they become infected during day 0. Question 2 Modelling an infectious disease outbreak Write a function outbreak(nodes, links, index) that takes as arguments a description of a population (a list of protection values and an array of link weights, as described in Question 1), and the index of the single initially infected person. The function should return a set containing the indices of all of the people who are infected at the end of the outbreak. Please note, this includes the initially infected person. For example (based on the population and outbreak)] illustrated above): Answer: Finding the most central person Getting vaccinated can reduce the risk that a person exposed to infection becomes infected. In this scenario, a vaccinated person is completely protected against infection— they cannot be infected (i.e., pi = 1.0). However, we have only a single dose of vaccine available before the outbreak begins, so we can only choose one person to protect. Here we will explore the effect of a particular approach to allocating this vaccine. Network centrality We would like to use our vaccine dose to achieve the greatest possible reduction in the number of people who get infected in the outbreak. Intuitively, this will be a person who is very strongly connected to the rest of the network. To help identify who we should choose to vaccinate, we will look at each person's position in the network to try and identify who is in the most central position. Several different measures of network centrality have been proposed. One of the simplest is degree centrality, defined as the number of links each person has: As the links between people in our population are weighted, we can also consider a measure of centrality that takes account of these weights, defined as the sum of link weights: We will combine these two measures (based on link count and link weight) to give a measure of weighted centrality as follows: where is a tuning parameter used to adjust the relative importance of number of links a person has and their combined weight. Example For example, consider the network from Question 2: For each node, the number of links (Di), sum of link weights (W i), and weighted centrality (Ci; here with =0.5) can be calculated as follows: Thus, from the table we can see that person 2 has the highest weighted centrality. Vaccinations Write a function find_central(links, alpha) determines the identity of the most central person in the network described by the array of weights links for the given value of the tuning parameter alpha; and For example: Answer: Measuring the effect of vaccination Test vaccinations For this question we have provided a reference solution for the question 2 and 3 before. If you wish to use the reference implementation from Question 2 and 3 please do so as follows: Answer:
Oct 08, 2020
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here