sir.sim
Class SimSellke

java.lang.Object
  extended bysir.sim.SimSellke

public class SimSellke
extends java.lang.Object

New sampler to handle Sellke constructions. Currently, only the single homogenous setup is handled. Intention is to go to a spatial setup at some point. Added seroconversion. Added so vaccine effects etc. can calculate predictive posterior distributions.

Author:
Michael Höhle, 17 October 2002. Last modified on 14 October 2003.

Nested Class Summary
 class SimSellke.Event
          A class to handle events
 class SimSellke.Individual
          Class to handle each individual in the population.
 
Field Summary
static int beta_
           
static int betaN_
           
static Data data
          Data object storing the information read form the .data file
static int deltaD_
           
static int deltaE_
           
static int deltaI_
           
protected static java.text.NumberFormat form
          For formatting of doubles to an output stream.
static int gammaD_
           
static int gammaE_
           
static int gammaI_
           
 
Constructor Summary
SimSellke(Distributions prob, java.lang.String baseName, java.io.PrintStream out, java.lang.String origoEvent, boolean writeResult, boolean header, double vac, boolean vaccBetween)
          Constructor - setup the model parameters and initializes the necessary arrays.
 
Method Summary
 boolean areNeighbours(int x1, int y1, int x2, int y2)
          Determine whether two units are neighbours or not in N_4
 java.lang.String finalSize(long[][] N, java.util.TreeSet[][] S)
          Show N* for each unit, i.e. number of initial susceptibles affected by the epidemic.
 int gridXY2Index(int x, int y)
          Function to convert (x,y) coordinate to an index Labelling is (1,1)=1, (2,1)=2
 int index2GridX(int index)
          Function to convert index to a position in the grid.
 int index2GridY(int index)
          Function to convert index to a position in the grid.
static void main(java.lang.String[] argv)
          A sir sampler for command line calling.
static Distributions newSampler()
          Method to initialize the sampler.
 long noOfAffected(long[][] N, java.util.TreeSet[][] S)
          Calculate, Z(t), the number of initial susceptibles affected by the epidemic (calced from current state).
static Data readDataFile(java.lang.String fileName)
          Read the specification from the data file.
 void state(java.util.TreeSet[][] S, java.util.TreeSet[][] E, java.util.TreeSet[][] I, java.util.TreeSet[][] R)
          Show current X(t) and Y(t) for all units
 void writeDataHeader(java.io.PrintStream data)
          Function writes the header of the .data file based on the current parameter values.
 void writeLogFiles(java.lang.String baseName)
          Write the corresponding events into the logfiles
 void writeResultHeader()
          Stupid function to write header of final size results
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beta_

public static int beta_

betaN_

public static int betaN_

gammaE_

public static int gammaE_

deltaE_

public static int deltaE_

gammaI_

public static int gammaI_

deltaI_

public static int deltaI_

gammaD_

public static int gammaD_

deltaD_

public static int deltaD_

data

public static Data data
Data object storing the information read form the .data file


form

protected static java.text.NumberFormat form
For formatting of doubles to an output stream.

Constructor Detail

SimSellke

public SimSellke(Distributions prob,
                 java.lang.String baseName,
                 java.io.PrintStream out,
                 java.lang.String origoEvent,
                 boolean writeResult,
                 boolean header,
                 double vac,
                 boolean vaccBetween)
Constructor - setup the model parameters and initializes the necessary arrays.

Parameters:
prob - A distributions object for sampling etc.
baseName - The basename giving where to store the basename.rec and basename.inf files
writeResult - Should we write all results to log files?
header - A header to std out in case of final sizes?
vac - Vaccine effect.
vaccBetween - Vaccine effect only on the between spread, i.e. on kappa.
Method Detail

writeResultHeader

public void writeResultHeader()
Stupid function to write header of final size results


writeDataHeader

public void writeDataHeader(java.io.PrintStream data)
Function writes the header of the .data file based on the current parameter values. This can then be fed into the LadyBug program for estimation.

Parameters:
data - The stream containing the data file.

index2GridX

public int index2GridX(int index)
Function to convert index to a position in the grid. Labelling is (1,1)=1, (2,1)=2

Parameters:
index - The index in the rid
Returns:
The x coordinate

index2GridY

public int index2GridY(int index)
Function to convert index to a position in the grid. Labelling is (1,1)=1, (2,1)=2

Parameters:
index - The index in the rid
Returns:
The y coordinate

gridXY2Index

public int gridXY2Index(int x,
                        int y)
Function to convert (x,y) coordinate to an index Labelling is (1,1)=1, (2,1)=2

Parameters:
x - The x coordinate
y - The y coordinate
Returns:
The index

areNeighbours

public boolean areNeighbours(int x1,
                             int y1,
                             int x2,
                             int y2)
Determine whether two units are neighbours or not in N_4

Parameters:
x1 - x coordinate of first unit
y1 - y coordinate of first unit
x2 - x coordinate of second unit
y2 - y coordinate of second unit
Returns:
boolean

finalSize

public java.lang.String finalSize(long[][] N,
                                  java.util.TreeSet[][] S)
Show N* for each unit, i.e. number of initial susceptibles affected by the epidemic.

Parameters:
N - Number of initial Susceptibles
S - Number of susceptibles at end (or at least currently).
Returns:
Final size in each unit as well as their sum (as a string)

noOfAffected

public long noOfAffected(long[][] N,
                         java.util.TreeSet[][] S)
Calculate, Z(t), the number of initial susceptibles affected by the epidemic (calced from current state).

Parameters:
N - Number of initial Susceptibles
S - Number of susceptibles at end (or at least currently).
Returns:
Final size in each unit as well as their sum (as a string)

state

public void state(java.util.TreeSet[][] S,
                  java.util.TreeSet[][] E,
                  java.util.TreeSet[][] I,
                  java.util.TreeSet[][] R)
Show current X(t) and Y(t) for all units


writeLogFiles

public void writeLogFiles(java.lang.String baseName)
Write the corresponding events into the logfiles

Parameters:
baseName - baseName.rec and baseName.inf are made Deprecated version with rec and inf file. Now just one .data file

readDataFile

public static Data readDataFile(java.lang.String fileName)
Read the specification from the data file. We share the .data specification with the LadyBug program. This works coz the parser sets the necessary variables?

Parameters:
fileName - Name of the .data file...

newSampler

public static Distributions newSampler()
Method to initialize the sampler. Move out of the instance class, coz that might mess things up and create non randomness calling that too many times once for each epidemic.


main

public static void main(java.lang.String[] argv)
A sir sampler for command line calling.