net.simplace.sim.components.experimental.lifestock.LifeStockFunctions
Functions to calculate lifestock population
See:
M. Lesnoff, 2008, DynMod: A tool for demographic projections of tropical
lifestock population under Microsoft Excel, User Manual, Version 1.
CIRAD, ILRI
public class LifeStockFunctions {
// Public Constructors
public LifeStockFunctions();
// Class Methods public static double
HfromP(double p, double p2);
Calculate hazard rate from probabilities
- p probability
- p2 concurrent probability
returns hazard rate
public static double
PfromH(double h, double h2);
Calculate probability from hazard rates
- h hazard rate
- h2 concurrent hazard rate
returns probability
public static double
HfromPOld(double po, double pd);
Estimates offtake hazard rate approximately from offtake and death probability
ho and hd are dependent on po and ph, and therefore an equation
system has to be solved. This method estimates hd by ignoring po and
uses it to calculate ho by a root finding algorithm.
- po offtake probability
- pd death probability
returns offtake hazard rate
public static double
PRescaled(double p, double p2, double n);
Rescales probability to different time unit
- p probability
- p2 concurrent probability
- n steps
returns rescaled probability
public static double
surv(double pd, double po);
Calculates survive probability
- pd death probability
- po offtake probability
returns survive probability
public static double
gamma(double surv, double d);
Calculates the transition probability from one age class to the next one
- surv survive probability
- d duration of ageclass in timeunits
returns transition probability
public static HashMap
calculatePopulationRates(Double[] state, Double[]
pdeath, Double[] pofftake, Double[] duration, Double[] intake, Double[]
aMax, Double prol, Double parturition, Double femaleproportion, int n);
Rate function for livestock
- state array of actual states [animal]
- pdeath array of death probabilities on yearly base [-]
- pofftake array of death probabilities on yearly base [-]
- duration array of age class durations [year]
- intake array of yearly intake [animal day-1]
- aMax array of maximal animal number [animal]
- prol prolification rate [-]
- parturition parturition rate [year-1]
- femaleproportion proportion of females at birth [-]
- n number of time steps per year [-]
returns hashmap containing the arrays with overall change rate dRate, dBirth, dDeath, dIntake, dOfftake [animal day-1], as well as Balance array with total, female and male balance
public static HashMap
calculatePopulationRatesExcelCompatible(Double[] state,
Double[] pdeath, Double[] pofftake, Double[] duration, Double[] intake,
Double[] aMax, Double prol, Double parturition, Double femaleproportion,
int n);
Rate function for livestock (compatibility mode)
Perform same calculation as in the Excel version. Differences are
- sligthtly inaccurate rescaling of probabilities
- calculating birth rates from next step's rate
- estimate next step's rate to limit to maximal values
The effect of using premature states for some rate calculations
becomes negligible when calculating with higher timesteps (e.g. daily)
- state array of actual states [animal]
- pdeath array of death probabilities on yearly base [-]
- pofftake array of death probabilities on yearly base [-]
- duration array of age class durations [year]
- intake array of yearly intake [animal day-1]
- aMax array of maximal animal number [animal]
- prol prolification rate [-]
- parturition parturition rate [year-1]
- femaleproportion proportion of females at birth [-]
- n number of time steps per year [-]
returns hashmap containing the arrays with overall change rate dRate, dBirth, dDeath, dIntake, dOfftake, dDeathNewBorn, dOfftakeNewBorn [animal day-1], as well as Balance array with total, female and male balance
}