pop.data
Class MigrationSpreader

java.lang.Object
  |
  +--pop.data.MigrationSpreader

public class MigrationSpreader
extends java.lang.Object
implements MigrationFactory

Creates Migration objects from partial input data. Spreads a single value for a particular year over the entire category-, sex-, and age-range of a migration object. This spread is proportional to an input array of shares that is held constant for all years. Services are provided to input either or both of the totals or/and shares from a file that is appropriately structured.

See Also:
MigrationFactory, Serialized Form

Constructor Summary
MigrationSpreader(int[] total, double[][][] shares)
          Basic constructor takes an array of total migration values and a 3-dimensional array of shares.
MigrationSpreader(int[] total, java.lang.String filename)
          Constructs a MigrationSpreader using migration totals from an array and default shares from a file.
MigrationSpreader(java.lang.String filename)
          Constructs a MigrationSpreader using both migration data and default shares from the same file.
MigrationSpreader(java.lang.String filename, double[][][] shares)
          Constructs a MigrationSpreader using migration data from a file, and default shares from an array.
 
Method Summary
 PopulationCharacteristics get_characteristics(int category)
          Returns a new Migration object for the indicated population category and the current year of the model.
 PopulationCharacteristics get_characteristics(java.lang.String category)
          Returns a new Migration object for the indicated population category and the current year of the model.
 Migration get_migration(int category, int year)
          Returns a new Migration object for the indicated population category and year.
 Migration get_migration(java.lang.String category, int year)
          Returns a new Migration object for the indicated population category and year.
 boolean ready()
          Simply returns true; any fully-created MigrationSpreader is ready.
 void reset_proportion(int year, double[][][] shares)
          Resets the proportioning used to spread migrations for a particular year only.
 double[][][] shares_of(PopulationSizes[] sizes)
          Returns an appropriately arranged double array of shares that reflect the distribution of population in the input array of population sizes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MigrationSpreader

public MigrationSpreader(int[] total,
                         double[][][] shares)
Basic constructor takes an array of total migration values and a 3-dimensional array of shares.
Parameters:
total - array of total migration, must be [Statics.years()].
shares - array of shares, must be [Statics.categories()][2][Statics.maximum_age+1].

MigrationSpreader

public MigrationSpreader(java.lang.String filename)
Constructs a MigrationSpreader using both migration data and default shares from the same file. preconditions: file exists, and data in the file are organized with migration data first (all years on one line), followed by Statics.maximum_age()+1 rows of (Statics.categories()*2) double values.
Parameters:
filename - - the name of the file.

MigrationSpreader

public MigrationSpreader(int[] total,
                         java.lang.String filename)
Constructs a MigrationSpreader using migration totals from an array and default shares from a file. preconditions: file exists, and data in the file are organized with Statics.maximum_age()+1 rows of (Statics.categories()*2) double values.
Parameters:
total - array of total migration, must be [Statics.years()]
filename - - the name of the file.

MigrationSpreader

public MigrationSpreader(java.lang.String filename,
                         double[][][] shares)
Constructs a MigrationSpreader using migration data from a file, and default shares from an array. preconditions: file exists, and data in the file are organized with total migration for all years on one line.
Parameters:
filename - - the name of the file.
shares - array of shares, must be [Statics.categories()][2][Statics.maximum_age+1].
Method Detail

get_migration

public Migration get_migration(int category,
                               int year)
Returns a new Migration object for the indicated population category and year. preconditions: category and year are valid for the current model, and the Migration object is not null.
Specified by:
get_migration in interface MigrationFactory

get_migration

public Migration get_migration(java.lang.String category,
                               int year)
Returns a new Migration object for the indicated population category and year. preconditions: category and year are valid for the current model.
Specified by:
get_migration in interface MigrationFactory

get_characteristics

public PopulationCharacteristics get_characteristics(int category)
Returns a new Migration object for the indicated population category and the current year of the model. Note: you must use the get_migration() version to specify a year other than the current model year. preconditions: category and year are valid for the current model.

get_characteristics

public PopulationCharacteristics get_characteristics(java.lang.String category)
Returns a new Migration object for the indicated population category and the current year of the model. Note: you must use the get_migration() version to specify a year other than the current model year. preconditions: category and year are valid for the current model.

reset_proportion

public void reset_proportion(int year,
                             double[][][] shares)
Resets the proportioning used to spread migrations for a particular year only.
Parameters:
year - must be in the valid range.
shares - in the appropriate dimensions (see basic constructor).

shares_of

public double[][][] shares_of(PopulationSizes[] sizes)
Returns an appropriately arranged double array of shares that reflect the distribution of population in the input array of population sizes.

ready

public boolean ready()
Simply returns true; any fully-created MigrationSpreader is ready.