Due Sep 24 on line
java RoadNetwork test 2> tests/out2
if java RoadNetwork test 2> tests/out2 ; then echo "SUCCESS" >> tests/out2 else echo "FAILURE" >> tests/out2 fi
Write version 3 of the epidemic model. This should accept input from a text file named by the first command line parameter, where the file format is as in machine-problem 2, with additional fields:
pop 25 ; house 3.2 , 1 ; // median and scatter of houshold sizes infected 12 ; employed 0.5 ; // probability of employment workplace 10.5, 12 ; // median and scatter of workplace size (syntax error?)
The employed line gives the probability that an individual is employed. 1.0 would indicate a 100% probability of employment, 0.0 would indicate that nobody is employed.
The house and workplace lines give the median number of residents or employees at each such place, and the scatter of the number, where a log-normal distribution is used for the populations of the places. The definitions of median and scatter are on the Wikipedia page for log-normal distributions.
Some math: If r is a random value drawn from a normal distribution with mean 0.0 and standard deviation 1.0 (that is the distribution that nextGaussian() in class Random delivers), then σr+μ comes from a distribution with mean μ and standard deviation σ, and eσr+μ (which is the same as eσreμ) comes from a distribution with median eμ and scatter eσ.
Directly selecting a scatter is not at all intuitive. It would be nice if we could describe a distribution with a pair [m, s] where m is the median and s is something like the scatter, but s=0 creates a distribution with a sharp peak, and larger values of s widen the distribution so that when s=m the distribution spreads wide enough that 1 is just included, and as s grows greater than m the distribution spreads wider and wider. A bit of experminting shows that we get this when:
In the simulation input file, house 3.2 , 1 ; sets [m, s] to [3.2, 1.0].
Of course, you will need to convert the log-normally distributed random values you get to integer values for the number of employees and household size, since no real workplace or household can have fractional members. Values from 0.0 to 1.0 should be converted to 1, values from 1.0 to 2.0 should be converted to 2, etc., noting that all values returned by the log-normal distribution are strictly positive. That is, the probability of the value 0.0 is exactly 0.0, while nonzero positive values are possible.
To do this assignment, you will need to add a subclass of Person called Employee, and subclasses of place called Home and Workplace.
A student asked: What is the output?
Now, some people are just people and some are employees. All people have a home, but employees also have employers. So, the list of people now needs to mark, for each person, are they an employee or just a person, and for each place is it a home or a workplace. Homes have lists of residents, workplaces have lists of employees.
This problem is not about creating the right output format! If we continue usig the default class@number format suggested in previous assignments, it would be perfectly OK to produce output like this:
PEOPLE Employee@15116 Home@14321 Workplace@05100 Person@31700 Home@14321 PLACES Home14321 Person@31700 Employee@15116 Workplace@05100 Employee@15116
The above is merely a suggestion. The collection of people and places can be printed jumbled, or you can print all the employees first and all the unemployed second. The collection of places can be jumbled, or you can list them separately. What matters is that each person, of any kind, has a home, employees have a workplace, homes have residents who are any kind of person, and workplaces have residents who are only employees.
A student asked: What are we to do with the solution to MP2 you distributed?
If the blending of code gets more complex, for example, if just one class comes from me, give me credit in the Javadoc comment for that class and give me secondary credit in the overal program heading comments. Any class that's 100% your code should have just your @author tag, while classes of mine that you modified can have both tags, and classes you didn't change just have my tag.
A student asked: Do we have to use some sort of random mechanism to assign employed/unemployed status of each person?
A student asked: How do we use the mean and scatter values to decide how many people are in a household.
The command line arguments on the LogNormal.java example are in the same order have the same meaning as the arguments to the household size and workplace size distributions.
Your program should work with juat about any numbers that make sense. Median household size x, spread 0.0 would make all your households the same size. A realistic one would be Median size 2, spread 1.2, but you could model some very fertile communities with Median size = 4 spread = 5. Your program should not break for median size 10, spread 10, but that would predict some mothers having really impossible numbers of children (perhaps there are lots of merged households there?). If you use the 10-10 rule for employers, you'd get a community with lots of small businesses.
A student asked: What about spaces before commas and semicolons, are these still required?