Assignment 10

Due Oct 29, on line

Part of the homework for CS:2820, Fall 2020
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Simple multiple choice questions, 1 point each:

  1. Here is a bit of Java code from class MyRandom in the reference solution to MP7 (minus comments):
    public double nextLogNormal( double median, double scatter ) {
        double sigma = Math.log( (scatter + median) / median );
        return Math.exp( sigma * this.nextGaussian() ) * median;
    }
    

    Which of the following sets x to a pseudo-random value with a log-normal distribution with mean 12 and scatter 4?
    a) x = MyRandom.nextLogNormal( 12, 4 );
    b) x = MyRandom.stream( nextLogNormal( 12, 4 ) );
    c) x = nextLogNormal( 12, 0 );
    d) x = MyRandom.stream().nextLogNormal( 12, 4 );
    e) x = nextLogNormal( MyRandom.stream( 12 ), 4 );

  2. Here is a bit of Java code from class Place in the reference solution to MP7 (minus comments):
    public void depart( Person p, double time ) {
        boolean wasPresent = occupants.remove( p ); // x
        assert wasPresent;                          // y
        assert !occupants.contains( p );            // z
    }
    

    Had we used an implementation of Set instead of List, which of the above lines would be superfluous?
    a) y
    b) z
    c) x and y
    d) y and z
    e) none are superfluous

  3. In the reference solution to MP7, Workplace.close sends all employees home. An alternative would be to have each worker schedule their own trip home in Employee.goToWork by adding a call to schedule Person.goHome at time
    a) time + 8*Simulator.hour + 25*Simulator.minute
    b) time + 8*Simulator.hour - 25*Simulator.minute
    c) time + 8*Simulator.hour
    d) 8*Simulator.hour + 25*Simulator.minute
    e) 8*Simulator.hour - 25*Simulator.minute

  4. Recall that people begin uninfected, become latent, become infectious, then may become bedridden (some recover without this), and then recover, while some of the bedridden may die.

    If a person is at work when the infectious to bedridden state change occurs, they go home immediately. How should Person.goToWork interact with the the infection state?
    a) do not depart home but schedule the other events as usual
    b) there is no interaction
    c) do not depart home or schedule arrival at work if beridden
    d) do not schedule the tomorrow's goToWork event
    e) do not depart home, do not schedule any new events

  5. In real life, a person could change state from infectious to bedridden on the way to work. When this happens in real life, the person will typically turn around and immediately head home without ever getting to work. We can't do this in our simulation because we can't:
    a) compute the travel time for a partial trip.
    b) determine the time at which the state change occurs.
    c) have more than one future event scheduled per person.
    d) un-schedule the already scheduled arrival at work event.
    e) change a person's infection state between arrival and departure events.

Machine Problem 8 -- due Monday, Nov 2

a) When Person.infect is called, launch a process that:

Assume a log-normal distribution for all of the above. These numbers are based on COVID-19, but ignore the availability of effective treatment with ventilators or other things we've discovered since the epidemic began, so the mortality is high.

b) People do not work while bedridden, they go home or stay home.

c) People no longer exist when dead.

d) At every place, keep a running count of the number of infectious people at that place. People are infectious when bedridden. This count goes up when an infectious person arrives or becomes newly infectious, and it goes down when an infectious person leaves, recovers or dies.

e) Every place has a transmissivity t, giving the likelihood that people in that place will catch the infection from another person there. Meatpacking plants have high transmissivity compared to lawyer's offices. Given that a place holds n infected people for h hours, the probability that any one person in that place for that interval will become infected is approximately tnh. (Of course, the probability never exceeds one.)

I have no good data on transmissivity other than that we call an hour-long event with about 100 people a superspreader event if 5 people end up infected. That's a transmissivity of 0.05/hour. Transmissivities are probably higher for those who work in really close contact, but much lower in high-class jobs where each employee has their own office.

So, let's tag each home with an average transmissivity of 0.03/hour and a scatter of 0.02, and let's tag each workplace with a transmissivity of o.02/hour and a scatter of 0.25 (transmissivities never go to zero, but low transmissivities are possible with this distribution).

f) Infect people according to the above rules. Of course, infecting someone who is already infected or recovered has no effect, it only matters for those who are uninfected.

g) Keep a global record of the number of people who are in each infection state and output that record daily at midnight.

A student asked: Is it an error above when you refer to the mean of a log-normal distribution?

Yes. I should have said median. Actually, all of the parameters for the disease progress should have been read from the input file and not hard coded into the simulation, but now that the assignment is written up the way it is, we'll leave it the way it is. Do not modify the input file format.

A student asked: Should the midnight reports include the cumulative number of deaths?

Yes. That makes good sense, people care about that.

A student asked: Should the percentage add up to 100%? 20% plus 70% doesn't add in the outcomes of the infectious state.

Oops. That was a stupid typo on my part. I've changed 20% to 30% above!

A student asked: My logic for Person.infect() always sets the state to infected and then changes it to recovered or bedridden or dead. Is this right?

Probably not. When a person is infected, only if they are currently uninfected should they become latent. There should be no other state change, but a future event should be scheduled at the time that this person becomes infectious. That event can schedule the person becoming recovered or bedridden. It may be possible to do all this with multiple events involving Person.infect() but it is much easier to do this with multiple small and simple evennt-service methods, one for each transition.

A student asked: Looking back through old notes, I find that you sometimes referred to the states of a person as uninfected, latent, asymptomatic, bedridden, and dead, but at other times, you referred to them as uninfected, latent, infectious, bedridden, and dead. Which is right?

Oops. In the problem statement for this assignment, I used the latter, so you might as well adopt that convention. Note, however, that the count of infectious people in a place — that is, the count of the number of people who can spread the infection to others — includes both asymptomatic and beridden people, or, to use the terminology here, the number of people in state infectious plus the number of people in state bedridden.

A student asked: I tried to do

  schedule( t1, (double t)-> infectionState = States.recovered )
but the compiler got mad at me. What am I doing wrong.

Recall that any variable referenced from within a Java lambda expression must be final or effectively final; infectionState is being changed, so it can't be final. You will have to schedule a call to a simulation method to make this state change. In any case, you need this because the same method must also decrement the count of the number of people in the current place place who are currently infectious (see above).

A student asked: Is there a time limit on how long a person stays uninfected? Also, do recovered people ever get infected?

No. Contact with infected people has a probability of causing infection. Lacking such contact, or if lucky, even when they do have contact, they may stay uninfected forever. For our purposes, we can assume that recovere people are immune. In real life, immunity generally wears off, but we'll ignore that.

A student asked: I tried modifying goHome to keep sick people at home, and it didn't work.

No, that can't work because goHome is only called when the person decides to (or is prompted to) go home. The modifications you need are in three places: First, the daily trip to work has to be prevented. So, in the code for the process that checks every morning to see if the person should go to work, the trip should not happen if the person is bedridden. Second, when a person gets sick as part of the disease process, if while they're at work, they should go home. Third, when a person arrives at work (or at any other place other than home), if on arrival, they find that they're sick, they should turn around and go home.

A student asked: Should I leave in any debug output in my final submission?

It's hard enough to look at a month's worth of epidemic output without having to wade through a trace off low level activity. One line per day allows you to see the big picture!