uk.ac.leeds.ccg.andyt.projects.genesis.society.demography
Class GENESIS_Population

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType
      extended by uk.ac.leeds.ccg.andyt.projects.genesis.society.demography.GENESIS_Population
All Implemented Interfaces:
java.io.Serializable

public class GENESIS_Population
extends uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType
implements java.io.Serializable

A class for storing population count statistics. The statistics are stored in two ways. They are stored as a TreeMaps, one for female counts, another for male counts where the keys are GENESIS_AgeBound instances and values are BigDecimal instances. It is designed that they are also read into and exported from the super.genderedAgeBoundPopulation which contains Lists of the data. In general the data is manipulated and altered via the TreeMaps. Instantiated objects can be serialised for swapping, but in general, before exporting data to a XML file, the super.genderedAgeBoundPopulation are updated from the TreeMaps.

See Also:
Serialized Form

Field Summary
 java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> _FemaleAgeBoundPopulationCount_TreeMap
          Female GENESIS_Population Key Integer are Age in Years Value Long are counts, this could be the number of people of an ageBound at a given time or an aggregate over a period (e.g.
 GENESIS_Environment _GENESIS_Environment
           
 java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> _MaleAgeBoundPopulationCount_TreeMap
          Male GENESIS_Population Key Integer are Age in Years Value Long are counts, this could be the number of people of an ageBound at a given time or an aggregate over a period (e.g.
 
Fields inherited from class uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType
genderedAgeBoundPopulation
 
Constructor Summary
GENESIS_Population()
           
GENESIS_Population(GENESIS_Environment a_GENESIS_Environment)
           
GENESIS_Population(GENESIS_Environment a_GENESIS_Environment, java.io.File population_File)
          By default the population multiplicand is equal to one.
GENESIS_Population(GENESIS_Environment a_GENESIS_Environment, java.io.File population_File, java.math.BigDecimal multiplicand)
          By default assume that the data is supplied in single years of ageBound.
GENESIS_Population(GENESIS_Environment a_GENESIS_Environment, java.io.File population_File, java.math.BigDecimal multiplicand, boolean singleYearsOfAge)
          By default an even spread of population within ageBound ranges is assumed.
GENESIS_Population(GENESIS_Environment a_GENESIS_Environment, uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType a_PopulationType)
           
GENESIS_Population(GENESIS_Population a_Population)
           
 
Method Summary
 void add(java.math.BigDecimal valueToAdd)
          Adds valueToAdd to all age gender counts in this
 void addPopulation(GENESIS_Population populationToAdd)
          Adds population from populationToAdd
static java.util.TreeMap<java.lang.String,GENESIS_Population> aggregateSubregion(java.util.TreeMap<java.lang.String,GENESIS_Population> theOAPops, java.util.TreeMap<java.lang.String,java.lang.String> subregionToAggregateRegionLookup, GENESIS_Environment aGENESIS_Environment)
           
 void divide(java.math.BigDecimal value, int decimalPlaces, java.math.RoundingMode roundingMode)
          Divide all age gender counts by value value expected to be non-zero
 GENESIS_Population divideByPopulation(GENESIS_Population populationToDivideBy, int decimalPlaces, java.math.RoundingMode roundingMode)
          divideByPopulation assumes same population structure.
static java.lang.Object[] getAggregateGENESIS_Population(GENESIS_Population pop, java.lang.Long minAgeInYears, java.lang.Long maxAgeInYears)
          Aggregates and returns a new GENESIS_Population using GENESIS_AgeBound.getAgeMin() for aggregation.
static java.lang.Object[] getAggregateGENESIS_Population(GENESIS_Population pop, java.lang.Long minAgeInYears, java.lang.Long maxAgeInYears, java.lang.Long ageIncrement, GENESIS_Environment a_GENESIS_Environment)
          Warning! This is not a general implementation that examines the ageMax of AgeBounds.
 java.lang.Object[] getAggregateGENESIS_Population(java.lang.Long minAge, java.lang.Long maxAge)
          Aggregates and returns a new GENESIS_Population using GENESIS_AgeBound.getAgeMin() for aggregation.
 java.math.BigDecimal getFemalePopulation(GENESIS_AgeBound ageBound)
           
 java.math.BigDecimal getFemalePopulationNullAllowed(GENESIS_AgeBound ageBound)
           
 java.math.BigDecimal getFemalePopulationSum(long startAgeInYears, long endAgeInYears)
          Returns the sum of female population from ages start Age up to endAge inclusive.
 java.math.BigDecimal getFemalePopulationTotal()
          Returns the sum of female population from getMinAgeYearsFemale() to getMaxAgeYearsFemale() inclusive.
 uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.common.GenderedAgeBoundPopulation getGenderedAgeBoundPopulation()
          Initialises genderedAgeBoundPopulation if it is null using CommonFactory.newGenderedAgeBoundPopulation() and returns a reference to it.
 java.util.logging.Logger getLogger()
           
 java.math.BigDecimal getMalePopulation(GENESIS_AgeBound ageBound)
           
 java.math.BigDecimal getMalePopulationNullAllowed(GENESIS_AgeBound ageBound)
           
 java.math.BigDecimal getMalePopulationSum(long startAgeInYears, long endAgeInYears)
          Returns the sum of male population from ages start Age up to endAge inclusive.
 java.math.BigDecimal getMalePopulationTotal()
          Returns the sum of male population from getMinAgeYearsMale() to getMaxAgeYearsMale() inclusive.
 java.lang.Long getMaxAgeInYearsWithPositivePopulation()
           
 java.lang.Long getMaxAgeInYearsWithPositivePopulation(java.util.List<uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.common.AgeBoundPopulation> l)
           
 java.lang.Long getMaxAgeInYearsWithPositivePopulationFemale()
           
 java.lang.Long getMaxAgeInYearsWithPositivePopulationMale()
           
 java.lang.Long getMaxAgeYears()
           
 java.lang.Long getMaxAgeYearsFemale()
           
 java.lang.Long getMaxAgeYearsMale()
           
 java.math.BigDecimal getMaxPopulationInAnyAgeBound()
           
 java.math.BigDecimal getMaxPopulationInAnyAgeBound(java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> pop)
           
 java.math.BigDecimal getMaxPopulationInAnyAgeBoundFemale()
           
 java.math.BigDecimal getMaxPopulationInAnyAgeBoundMale()
           
 java.lang.Long getMinAgeInYearsWithPositivePopulation()
           
 java.lang.Long getMinAgeInYearsWithPositivePopulation(java.util.List<uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.common.AgeBoundPopulation> l)
           
 java.lang.Long getMinAgeInYearsWithPositivePopulationFemale()
           
 java.lang.Long getMinAgeInYearsWithPositivePopulationMale()
           
 java.lang.Long getMinAgeYears()
           
 java.lang.Long getMinAgeYearsFemale()
           
 java.lang.Long getMinAgeYearsMale()
           
static java.math.BigDecimal getPopulationSum(java.lang.Long startAgeInYears, java.lang.Long endAgeInYears, java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> pop)
          Returns the sum of population values from pop.
 java.math.BigDecimal getPopulationTotal()
          Returns the sum total population.
 void init()
           
static void initPop(int gender, long minimumAgeInYears, long maximumAgeInYears, GENESIS_Population pop, uk.ac.leeds.ccg.andyt.projects.moses.io.CAS001DataRecord aCAS001DataRecord)
           
static java.util.TreeMap<java.lang.String,GENESIS_Population> loadOAPopulations(java.io.File theMOSESWorkspace, java.io.File theGENESISWorkspace, java.lang.String areaCode)
           
static void main(java.lang.String[] args)
           
 void multiply(java.math.BigDecimal value)
          Multiplies all age gender counts by value
static void run(java.lang.String[] args, java.io.File directory)
           
 void runCensusData(java.lang.String[] args)
           
 void runCensusDataTest(java.lang.String[] args)
           
 void runCSVToXML(java.lang.String[] args)
           
 void subtractPopulation(GENESIS_Population populationToSubtract)
          Adds population from populationToAdd
 java.lang.String toString()
           
 void updateGenderedAgePopulation()
          updates genderAgePopulation using _FemaleAgeBoundPopulationCount_TreeMap and _MaleAgeBoundPopulationCount_TreeMap
static void updateGenderedAgePopulation(java.util.TreeMap<java.lang.String,GENESIS_Population> pops)
          updates genderAgePopulation using _FemaleAgeBoundPopulationCount_TreeMap and _MaleAgeBoundPopulationCount_TreeMap
static void writeLUTsForOAToMSOAHashMap()
           
static void writeLUTsForOAToMSOATreeMap()
           
 void writeToCSV(java.io.File a_File)
           
 void writeToImage(java.util.concurrent.ExecutorService executorService, java.io.File outfile, java.lang.String format, java.lang.String title, int dataWidth, int dataHeight, java.lang.String xAxisLabel, java.lang.String yAxisLabel, boolean drawOriginLinesOnPlot, int decimalPlacePrecisionForCalculations, int significantDigits, java.math.RoundingMode roundingMode, int startAgeOfEndYearInterval)
           
 void writeToXML(java.io.File a_File)
           
 
Methods inherited from class uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType
setGenderedAgeBoundPopulation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_GENESIS_Environment

public transient GENESIS_Environment _GENESIS_Environment

_FemaleAgeBoundPopulationCount_TreeMap

public java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> _FemaleAgeBoundPopulationCount_TreeMap
Female GENESIS_Population Key Integer are Age in Years Value Long are counts, this could be the number of people of an ageBound at a given time or an aggregate over a period (e.g. number of person years or number of person days)


_MaleAgeBoundPopulationCount_TreeMap

public java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> _MaleAgeBoundPopulationCount_TreeMap
Male GENESIS_Population Key Integer are Age in Years Value Long are counts, this could be the number of people of an ageBound at a given time or an aggregate over a period (e.g. number of person years or number of person days)

Constructor Detail

GENESIS_Population

public GENESIS_Population()

GENESIS_Population

public GENESIS_Population(GENESIS_Population a_Population)

GENESIS_Population

public GENESIS_Population(GENESIS_Environment a_GENESIS_Environment,
                          uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType a_PopulationType)

GENESIS_Population

public GENESIS_Population(GENESIS_Environment a_GENESIS_Environment,
                          java.io.File population_File)
By default the population multiplicand is equal to one.


GENESIS_Population

public GENESIS_Population(GENESIS_Environment a_GENESIS_Environment,
                          java.io.File population_File,
                          java.math.BigDecimal multiplicand)
By default assume that the data is supplied in single years of ageBound.

Parameters:
a_GENESIS_Environment -
population_File -
multiplicand - A number greater than zero used to scale up or down the population as read from population_File

GENESIS_Population

public GENESIS_Population(GENESIS_Environment a_GENESIS_Environment,
                          java.io.File population_File,
                          java.math.BigDecimal multiplicand,
                          boolean singleYearsOfAge)
By default an even spread of population within ageBound ranges is assumed. An even spread of population within any ageBound ranges is assumed.

Parameters:
a_GENESIS_Environment -
population_File -
multiplicand - A number greater than zero used to scale up or down the population as read from population_File

GENESIS_Population

public GENESIS_Population(GENESIS_Environment a_GENESIS_Environment)
Method Detail

init

public final void init()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)

runCSVToXML

public void runCSVToXML(java.lang.String[] args)

writeLUTsForOAToMSOAHashMap

public static void writeLUTsForOAToMSOAHashMap()

writeLUTsForOAToMSOATreeMap

public static void writeLUTsForOAToMSOATreeMap()

runCensusData

public void runCensusData(java.lang.String[] args)

runCensusDataTest

public void runCensusDataTest(java.lang.String[] args)

writeToImage

public void writeToImage(java.util.concurrent.ExecutorService executorService,
                         java.io.File outfile,
                         java.lang.String format,
                         java.lang.String title,
                         int dataWidth,
                         int dataHeight,
                         java.lang.String xAxisLabel,
                         java.lang.String yAxisLabel,
                         boolean drawOriginLinesOnPlot,
                         int decimalPlacePrecisionForCalculations,
                         int significantDigits,
                         java.math.RoundingMode roundingMode,
                         int startAgeOfEndYearInterval)

loadOAPopulations

public static java.util.TreeMap<java.lang.String,GENESIS_Population> loadOAPopulations(java.io.File theMOSESWorkspace,
                                                                                       java.io.File theGENESISWorkspace,
                                                                                       java.lang.String areaCode)

initPop

public static void initPop(int gender,
                           long minimumAgeInYears,
                           long maximumAgeInYears,
                           GENESIS_Population pop,
                           uk.ac.leeds.ccg.andyt.projects.moses.io.CAS001DataRecord aCAS001DataRecord)

run

public static void run(java.lang.String[] args,
                       java.io.File directory)

aggregateSubregion

public static java.util.TreeMap<java.lang.String,GENESIS_Population> aggregateSubregion(java.util.TreeMap<java.lang.String,GENESIS_Population> theOAPops,
                                                                                        java.util.TreeMap<java.lang.String,java.lang.String> subregionToAggregateRegionLookup,
                                                                                        GENESIS_Environment aGENESIS_Environment)

addPopulation

public void addPopulation(GENESIS_Population populationToAdd)
Adds population from populationToAdd


subtractPopulation

public void subtractPopulation(GENESIS_Population populationToSubtract)
Adds population from populationToAdd


add

public void add(java.math.BigDecimal valueToAdd)
Adds valueToAdd to all age gender counts in this


multiply

public void multiply(java.math.BigDecimal value)
Multiplies all age gender counts by value


divide

public void divide(java.math.BigDecimal value,
                   int decimalPlaces,
                   java.math.RoundingMode roundingMode)
Divide all age gender counts by value value expected to be non-zero


divideByPopulation

public GENESIS_Population divideByPopulation(GENESIS_Population populationToDivideBy,
                                             int decimalPlaces,
                                             java.math.RoundingMode roundingMode)
divideByPopulation assumes same population structure.


getGenderedAgeBoundPopulation

public final uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.common.GenderedAgeBoundPopulation getGenderedAgeBoundPopulation()
Initialises genderedAgeBoundPopulation if it is null using CommonFactory.newGenderedAgeBoundPopulation() and returns a reference to it.

Overrides:
getGenderedAgeBoundPopulation in class uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.population.PopulationType
Returns:
genderedAgeBoundPopulation or

updateGenderedAgePopulation

public final void updateGenderedAgePopulation()
updates genderAgePopulation using _FemaleAgeBoundPopulationCount_TreeMap and _MaleAgeBoundPopulationCount_TreeMap


updateGenderedAgePopulation

public static void updateGenderedAgePopulation(java.util.TreeMap<java.lang.String,GENESIS_Population> pops)
updates genderAgePopulation using _FemaleAgeBoundPopulationCount_TreeMap and _MaleAgeBoundPopulationCount_TreeMap


getFemalePopulationSum

public java.math.BigDecimal getFemalePopulationSum(long startAgeInYears,
                                                   long endAgeInYears)
Returns the sum of female population from ages start Age up to endAge inclusive.

Parameters:
startAge -
endAge -
Returns:
BigDecimal

getFemalePopulationTotal

public java.math.BigDecimal getFemalePopulationTotal()
Returns the sum of female population from getMinAgeYearsFemale() to getMaxAgeYearsFemale() inclusive.

Returns:
BigDecimal

getMalePopulationSum

public java.math.BigDecimal getMalePopulationSum(long startAgeInYears,
                                                 long endAgeInYears)
Returns the sum of male population from ages start Age up to endAge inclusive.

Parameters:
startAge -
endAge -
Returns:
BigDecimal

getMalePopulationTotal

public java.math.BigDecimal getMalePopulationTotal()
Returns the sum of male population from getMinAgeYearsMale() to getMaxAgeYearsMale() inclusive.

Returns:
BigDecimal

getPopulationTotal

public java.math.BigDecimal getPopulationTotal()
Returns the sum total population.

Returns:
BigDecimal

getPopulationSum

public static java.math.BigDecimal getPopulationSum(java.lang.Long startAgeInYears,
                                                    java.lang.Long endAgeInYears,
                                                    java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> pop)
Returns the sum of population values from pop.


getFemalePopulation

public java.math.BigDecimal getFemalePopulation(GENESIS_AgeBound ageBound)

getFemalePopulationNullAllowed

public java.math.BigDecimal getFemalePopulationNullAllowed(GENESIS_AgeBound ageBound)

getMalePopulation

public java.math.BigDecimal getMalePopulation(GENESIS_AgeBound ageBound)

getMalePopulationNullAllowed

public java.math.BigDecimal getMalePopulationNullAllowed(GENESIS_AgeBound ageBound)

getMaxPopulationInAnyAgeBound

public java.math.BigDecimal getMaxPopulationInAnyAgeBound()
Parameters:
pop -
Returns:
Either the MaxPopulation (value) in _FemaleAgeBoundPopulationCount_TreeMap and _MaleAgeBoundPopulationCount_TreeMap or BigDecimal.ZERO.

getMaxPopulationInAnyAgeBoundFemale

public java.math.BigDecimal getMaxPopulationInAnyAgeBoundFemale()
Parameters:
pop -
Returns:
Either the MaxPopulation (value) in _FemaleAgeBoundPopulationCount_TreeMap or BigDecimal.ZERO.

getMaxPopulationInAnyAgeBoundMale

public java.math.BigDecimal getMaxPopulationInAnyAgeBoundMale()
Parameters:
pop -
Returns:
Either the MaxPopulation (value) in _MaleAgeBoundPopulationCount_TreeMap or BigDecimal.ZERO.

getMaxPopulationInAnyAgeBound

public java.math.BigDecimal getMaxPopulationInAnyAgeBound(java.util.TreeMap<GENESIS_AgeBound,java.math.BigDecimal> pop)
Parameters:
pop -
Returns:
Either the MaxPopulation (value) in pop or BigDecimal.ZERO.

getMinAgeYearsFemale

public java.lang.Long getMinAgeYearsFemale()

getMaxAgeYearsFemale

public java.lang.Long getMaxAgeYearsFemale()

getMinAgeYearsMale

public java.lang.Long getMinAgeYearsMale()

getMaxAgeYearsMale

public java.lang.Long getMaxAgeYearsMale()

getMinAgeYears

public java.lang.Long getMinAgeYears()

getMaxAgeYears

public java.lang.Long getMaxAgeYears()

getMinAgeInYearsWithPositivePopulation

public java.lang.Long getMinAgeInYearsWithPositivePopulation()

getMaxAgeInYearsWithPositivePopulation

public java.lang.Long getMaxAgeInYearsWithPositivePopulation()

getMinAgeInYearsWithPositivePopulationFemale

public java.lang.Long getMinAgeInYearsWithPositivePopulationFemale()

getMinAgeInYearsWithPositivePopulationMale

public java.lang.Long getMinAgeInYearsWithPositivePopulationMale()

getMinAgeInYearsWithPositivePopulation

public java.lang.Long getMinAgeInYearsWithPositivePopulation(java.util.List<uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.common.AgeBoundPopulation> l)

getMaxAgeInYearsWithPositivePopulationFemale

public java.lang.Long getMaxAgeInYearsWithPositivePopulationFemale()

getMaxAgeInYearsWithPositivePopulationMale

public java.lang.Long getMaxAgeInYearsWithPositivePopulationMale()

getMaxAgeInYearsWithPositivePopulation

public java.lang.Long getMaxAgeInYearsWithPositivePopulation(java.util.List<uk.ac.leeds.ccg.andyt.projects.genesis.io.schema.common.AgeBoundPopulation> l)

writeToXML

public void writeToXML(java.io.File a_File)

writeToCSV

public void writeToCSV(java.io.File a_File)

getAggregateGENESIS_Population

public java.lang.Object[] getAggregateGENESIS_Population(java.lang.Long minAge,
                                                         java.lang.Long maxAge)
Aggregates and returns a new GENESIS_Population using GENESIS_AgeBound.getAgeMin() for aggregation.

Parameters:
minAge - The value for which any GENESIS_AgeBound.getAgeMin() in the population TreeMaps are aggregated to if they are less than or equal to.
maxAge - The value for which any GENESIS_AgeBound.getAgeMin() in the population TreeMaps are aggregated to if they are greater than or equal to.
Returns:
An Object[] result where: result[0] is the aggregated GENESIS_Population; result[1] is the maximum population in any GENESIS_AgeBound group.

getAggregateGENESIS_Population

public static java.lang.Object[] getAggregateGENESIS_Population(GENESIS_Population pop,
                                                                java.lang.Long minAgeInYears,
                                                                java.lang.Long maxAgeInYears)
Aggregates and returns a new GENESIS_Population using GENESIS_AgeBound.getAgeMin() for aggregation.

Parameters:
minAgeInYears - The value for which any GENESIS_AgeBound.getAgeMin() in the population TreeMaps are aggregated to if they are less than or equal to.
maxAgeInYears - The value for which any GENESIS_AgeBound.getAgeMin() in the population TreeMaps are aggregated to if they are greater than or equal to.
Returns:
An Object[] result where: result[0] is the aggregated GENESIS_Population; result[1] is the maximum population in any GENESIS_AgeBound group.

getAggregateGENESIS_Population

public static java.lang.Object[] getAggregateGENESIS_Population(GENESIS_Population pop,
                                                                java.lang.Long minAgeInYears,
                                                                java.lang.Long maxAgeInYears,
                                                                java.lang.Long ageIncrement,
                                                                GENESIS_Environment a_GENESIS_Environment)
Warning! This is not a general implementation that examines the ageMax of AgeBounds. It assumes nesting AgeBounds for aggregation. For instance it will work as expected for aggregating some two year age bounds into other four year age bounds so long as the starting age bounds match. Aggregates and returns a new GENESIS_Population using GENESIS_AgeBound.getAgeMin() for aggregation.

Parameters:
minAge - The value below which any GENESIS_AgeBound.getAgeMin() in pop TreeMaps are aggregated to if less than or equal to.
maxAge - The value above which any GENESIS_AgeBound.getAgeMin() in pop TreeMaps are aggregated to if greater than or equal to.
Returns:
An Object[] result where: result[0] is the aggregated GENESIS_Population; result[1] is the maximum population in any GENESIS_AgeBound group.

getLogger

public java.util.logging.Logger getLogger()