Class LivestockFunctions
java.lang.Object
net.simplace.sim.components.experimental.livestock.LivestockFunctions
Functions to calculate Livestock population
See:
M. Lesnoff, 2008, DynMod: A tool for demographic projections of tropical
Livestock population under Microsoft Excel, User Manual, Version 1.
CIRAD, ILRI
- Author:
- Gunther Krauss
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
static final record
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncalculatePopulationRates
(Double[] state, Double[] pdeath, Double[] pofftake, Double[] duration, Double[] intake, Double productionNutritionIndex, Double maintenanceNutritionIndex, Double MaintenanceNutritionMortalityFactor, Double[] aMax, Double prol, Double parturition, Double femaleproportion, int n) Rate function for livestockcalculatePopulationRatesExcelCompatible
(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.static double
gamma
(double surv, double d) Calculates the transition probability from one age class to the next onestatic double
HfromP
(double p, double p2) Calculate hazard rate from probabilitiesstatic 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.static double
PfromH
(double h, double h2) Calculate probability from hazard ratesstatic double
PRescaled
(double p, double p2, double n) Rescales probability to different time unitstatic double
surv
(double pd, double po) Calculates survive probability
-
Constructor Details
-
LivestockFunctions
public LivestockFunctions()
-
-
Method Details
-
HfromP
public static double HfromP(double p, double p2) Calculate hazard rate from probabilities- Parameters:
p
- probabilityp2
- concurrent probability- Returns:
- hazard rate
-
PfromH
public static double PfromH(double h, double h2) Calculate probability from hazard rates- Parameters:
h
- hazard rateh2
- concurrent hazard rate- Returns:
- probability
-
HfromPOld
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.- Parameters:
po
- offtake probabilitypd
- death probability- Returns:
- offtake hazard rate
-
PRescaled
public static double PRescaled(double p, double p2, double n) Rescales probability to different time unit- Parameters:
p
- probabilityp2
- concurrent probabilityn
- steps- Returns:
- rescaled probability
-
surv
public static double surv(double pd, double po) Calculates survive probability- Parameters:
pd
- death probabilitypo
- offtake probability- Returns:
- survive probability
-
gamma
public static double gamma(double surv, double d) Calculates the transition probability from one age class to the next one- Parameters:
surv
- survive probabilityd
- duration of ageclass in timeunits- Returns:
- transition probability
-
calculatePopulationRates
public static LivestockFunctions.PopulationRates calculatePopulationRates(Double[] state, Double[] pdeath, Double[] pofftake, Double[] duration, Double[] intake, Double productionNutritionIndex, Double maintenanceNutritionIndex, Double MaintenanceNutritionMortalityFactor, Double[] aMax, Double prol, Double parturition, Double femaleproportion, int n) Rate function for livestock- Parameters:
state
- array of actual states [animal]pdeath
- array of death probabilities on yearly base [-]pofftake
- array of death probabilities on yearly base [-] //TODO: change calculation: fraction daywise!duration
- array of age class durations [year] //TODO: day?intake
- array of yearly intake [animal day-1]productionNutritionIndex
- limit population growth [0-1]maintenanceNutritionIndex
- rises population death rate [0-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:
- record 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
-
calculatePopulationRatesExcelCompatible
public static LivestockFunctions.PopulationRatesExtra 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)- Parameters:
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:
- record 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
-