Documentation
¶
Overview ¶
GenBV
Copyright 2021 Bruce Golden and Matt Spangler ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
herd project herd.go
Defines an animal and its characteristics ¶
Copyright 2021 Bruce Golden and Matt Spangler ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
breed
Copyright 2021 Bruce Golden and Matt Spangler ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
herd document
genAnimal
Copyright 2021 Bruce Golden and Matt Spangler ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
herd project herd.go Defines the herd characteristics and members There can be more than 1 herd - e.g., spring and fall
Copyright 2021 Bruce Golden and Matt Spangler ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
phenotype
Copyright 2021 Bruce Golden and Matt Spangler ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func AgeEffect(trait string, thisAnimal Animal) (effect float64)
- func BackgroundingWtPhenotype(calf Animal) float64
- func Breed(herd *Herd, year int)
- func BreedEffect(trait string, thisAnimal Animal) (effect float64)
- func Calve(herd *Herd, year int, gvCholesky mat.Cholesky, rvCholesky mat.Cholesky)
- func CalvingDifficultyPhenotype(thisAnimal Animal, thisBreeding BreedingRec) (pheno float64)
- func CullAum(thisCow *Animal, year int, loc int)
- func CullOld(herd *Herd, year int)
- func CullOpen(herd *Herd, year int)
- func DetermineAumThruBackgrounding(newCalf *Animal)
- func DetermineAumToWeaning(newCalf *Animal)
- func DetermineCowAum(h *Herd, year int)
- func DetermineFeedlotFeedIntake(newCalf *Animal)
- func DumpBreedingRecords()
- func DumpRecords()
- func GenBullBatteryBreedComposition(a *Animal)
- func GenFoundation(a *Animal, gvCholesky mat.Cholesky, rvCholesky mat.Cholesky)
- func GenFoundationBreedComposition(a *Animal)
- func GenFromMating(a *Animal, year int, gvCholesky mat.Cholesky, rvCholesky mat.Cholesky)
- func GeneticEffect(indx int, animal Animal) (u float64)
- func GeneticIndex(traitName string, comp string) (index int)
- func GestationLengthError() int
- func HeiferPregnancyPhenotype(thisAnimal Animal, today Date) (pheno float64)
- func HeterosisEffect(trait string, thisAnimal Animal) (effect float64, l bool)
- func MakeFoundationBulls(gvCholesky mat.Cholesky, rvCholesky mat.Cholesky, param map[string]interface{})
- func MakeFoundationCowHerd(gvCholesky mat.Cholesky, rvCholesky mat.Cholesky, param map[string]interface{}) (cowHerdSize int)
- func MakeFoundationHeifers(gvCholesky mat.Cholesky, rvCholesky mat.Cholesky, param map[string]interface{}) (cowHerdSize int)
- func MatureWeightAtAgePhenotype(thisAnimal Animal, today Date) (pheno float64)
- func Phenotype(thisAnimal Animal, thisTrait string) (pheno float64, l bool)
- func PhenotypeAtMeanAge(thisAnimal Animal, thisTrait string) (pheno float64, l bool)
- func Puberty(herd *Herd, i int, bredDate Date) bool
- func Replace(herd *Herd, year int)
- func ResidualIndex(traitName string) (index int)
- func SetBreedComposition(a *Animal)
- func SexAgeOfDamEffect(trait string, thisAnimal Animal) (effect float64)
- func SimulateBase(Param map[string]interface{}, gvCholesky mat.Cholesky, rvCholesky mat.Cholesky)
- func Stay2Concept21days(s float64) float64
- func StayAtAgePhenotype(thisAnimal Animal, today Date) (pheno float64)
- func WeaningWtPhenotype(thisAnimal Animal) (float64, bool)
- func WhatAod(thisAnimal Animal) (aod int)
- func WhatSex(i int) (code string)
- func WriteCowAgeDistribution(herds map[string]Herd, thisYear int, param map[string]interface{})
- func Year(birthDate Date) int
- type Animal
- type AnimalId
- type Aum_t
- type BTS_t
- type Bred
- type BreedComposition_t
- type BreedEffects_t
- type BreedingRec
- type BreedingRecordsTable_t
- type BumpComponent_t
- type Bv
- type Component_t
- type Date
- type FedType
- type Herd
- type HerdYear_t
- type HeterosisValues_t
- type InterceptSlope_t
- type Sales_t
- type Trait
Constants ¶
const ( Bull string = "M" // Breeding male or calf Heifer string = "F" // Young female not yet selected Cow string = "C" // A breeding female Steer string = "S" // Going to be fed )
Variables ¶
var BackgroundDays float64
var BreedTraitSexAod map[BTS_t]float64 // mapped by Breed then trait
var BreedingRecordsDumpFile = "" // name of file in breedingrecordsdump:
var BreedingRecordsYearTable map[HerdYear_t]BreedingRecordsTable_t
var Breeds map[Component_t]BreedEffects_t // See animal.go and technical documentation for this struct type
var BreedsList []string // A list of the breeds in the master.hjson. It is the 1st line of the BreedsEffects: key
var BullBatteryBreedCompositionTable []BreedComposition_t
var BullMerit []float64 // Genetic merit of the foundation bulls fro meritFoundationBulls key
var BumpComponent *string // Name,Name of the component to bump the bulls 1 unit after burnin
var Burnin int // Number of years to simulate before calculating the MEV
var CDPhenotypeFilePointer *os.File
var CDVar float64 // phenotypic variance for CDF
var CalfAumAt500 float64 // Amount of Aum at 500 lbs calf
var CarcassPhenotypeFile *os.File // For optional write of slaughter cattle phenotypes QG,YQ, etc.
var ComponentList []Component_t
var Components []string
var CowAgeFile *os.File // For cowagefilename: in master.hjson if exists
var CowAumAt1000 float64 // Amount of AUM at 1000 lbs animal
var CowResetList []Animal // List of Records[] to reset to active cows when bumping index components
var HeiferResetList []int // List of heifer locates in Records that need to be reset to heifer when bumping index components
var CowsExposedPerYear map[int]int // Counts of the number of cows exposed each year
var CurrentCalvesBreedCompositionTable []BreedComposition_t
var DaysOnFeed float64
var FoundationCowHerdBreedCompositionTable []BreedComposition_t
var HPPhenotypeFilePointer *os.File
var Herds map[string]Herd // can be more than 1 such as spring v fall
var HeterosisCodes map[string]string // The breed to breed classification categories in the HeterosisCodes: key in master.hjson
var HeterosisCrossClasses []string // The cross class designations from the HeterosisValues talbe 1st line in the master.hjson
var HeterosisValues map[Component_t]HeterosisValues_t // These are mapped according to their Component_t
var IndexTerminal bool
var IndexType string
var MaxCowAge int
For the culling policy it is the length of ageDist in master.hjson
var NHeifersBred map[int]int
var PhenotypeFile string // File name to write output
Optional file to write out a phenotype components for debugging
var PhenotypeFilePointer *os.File
var PhenotypeOutputTrait string // A valid trait name in the master.hjson
var Records []Animal
var RecordsDumpFile = "" // name of file in recordsdump:
var ResidualHpStdDev float64
var ResidualStayStdDev float64
var Rng *rand.Rand
var SexCodes []string
var StayPhenotypeFilePointer *os.File // For debugging cow conception routines
var TraitAgeEffects map[string]InterceptSlope_t
var TraitList = []Trait{}
var TraitMean = make(map[string]float64) // Means of traits mapped to trait name. Coms from the Traits: key in master.hjson
var Traits []string
var WtCullCows map[int]Sales_t
var YearsPlanningHorizon int // Total Number of years to run the simulation after the burnin for MEV calculation
Functions ¶
func BackgroundingWtPhenotype ¶
Return the phenotype of the animal at the end of the background period.
func BreedEffect ¶
Return the breed effect on
func CalvingDifficultyPhenotype ¶
func CalvingDifficultyPhenotype(thisAnimal Animal, thisBreeding BreedingRec) (pheno float64)
Calculate the calving difficulty phenotype for of the initial heifer population This is used to parameterize the distribution
func DetermineAumThruBackgrounding ¶
func DetermineAumThruBackgrounding(newCalf *Animal)
Calculate monthly AUM consumption of new animal to yearling age This also determines the weight at the end of the background period
func DetermineAumToWeaning ¶
func DetermineAumToWeaning(newCalf *Animal)
Calculate monthly AUM consumption of new animal to yearling age
func DetermineCowAum ¶
Determine the AUM consumption for active cows at end of year Considering that some may be heifers that entered
func DetermineFeedlotFeedIntake ¶
func DetermineFeedlotFeedIntake(newCalf *Animal)
Calculate this animal's total feedlot feed intake And slaughter weight
func DumpBreedingRecords ¶
func DumpBreedingRecords()
func DumpRecords ¶
func DumpRecords()
func GenBullBatteryBreedComposition ¶
func GenBullBatteryBreedComposition(a *Animal)
Generate the breed composition of the initial bull battery animal from the BullBatteryBreedComposition: key
func GenFoundation ¶
Generate a foundation animal - sire and dam unknown
func GenFoundationBreedComposition ¶
func GenFoundationBreedComposition(a *Animal)
Generate the breed composition of a foundation animal from the CowHerdBreedComposition: key
func GenFromMating ¶
Generate an animal from a mating Determine if the heifer or calf died in calving
func GeneticEffect ¶
Return the additive genetic effect
func GeneticIndex ¶
Return the index of this genetic component in the genetic variance matrix
func GestationLengthError ¶
func GestationLengthError() int
func HeiferPregnancyPhenotype ¶
Calculate the heifer pregnancy phenotype at a particular day - e.g. at breeding
func HeterosisEffect ¶
Return the heterosis effect
func MakeFoundationBulls ¶
func MakeFoundationBulls( gvCholesky mat.Cholesky, rvCholesky mat.Cholesky, param map[string]interface{})
Foundation bulls
func MakeFoundationCowHerd ¶
func MakeFoundationCowHerd( gvCholesky mat.Cholesky, rvCholesky mat.Cholesky, param map[string]interface{}) (cowHerdSize int)
Make a herd of foundation cows
func MakeFoundationHeifers ¶
func MakeFoundationHeifers( gvCholesky mat.Cholesky, rvCholesky mat.Cholesky, param map[string]interface{}) (cowHerdSize int)
Make the foundation heifers
func MatureWeightAtAgePhenotype ¶
Calculate the mature weight phenotype at a particular day - e.g. at weaning
func PhenotypeAtMeanAge ¶
Calculate phenotype without adjusting for age
func ResidualIndex ¶
Return the trait index in the traits array list
func SetBreedComposition ¶
func SetBreedComposition(a *Animal)
Determine an animal's breed composition from sire and dam
func SexAgeOfDamEffect ¶
Return the net AOD effect of even crossbreeds
func SimulateBase ¶
Simulate a base set of records to calculate where the MEV deviate from
func Stay2Concept21days ¶
Convert a stayability value to a conception rate in 21 days value Assumes the stayability is for a 60 d breeding season - really 63 but who's counting
func StayAtAgePhenotype ¶
Calculate the stayability phenotype at a particular day - e.g. at breeding This is 6 yoa conception rate adjusted to a conception rate at a particular age.
func WeaningWtPhenotype ¶
phenotype of weaning wt
func WhatAod ¶
Return the BIF aod catagory where 0=2yoa, 1=3yoa, 2=4yoa, 3=5 thru9yoa, and 10 = >=10 yoa
func WriteCowAgeDistribution ¶
func PrintCowAgeDistribution(herds []Herd, thisYear int, param map[string]interface{}) {
for h := range herds { herds[h].Cows = ActiveCows(&herds[h]) thisHerd := &herds[h] //array := param["ageDist"].([]interface{}) var ageCounts = make([]int, MaxCowAge+1) fmt.Println("Herd name:", thisHerd.HerdName) fmt.Println("Total number of cows in this herd (after culling opens): ", len(thisHerd.Cows)) fmt.Println("Number cows calved by age for Year: ", thisYear+1) for i := 0; i < len(thisHerd.Cows); i++ { thisAge := int(math.Round((float64( thisHerd.Cows[i].BreedingRecords[len(thisHerd.Cows[i].BreedingRecords)-1].CalvingDate- thisHerd.Cows[i].BirthDate) / 365.))) //fmt.Println("LOC 3", thisAge) ageCounts[thisAge]++ } for i := 2; i < len(ageCounts); i++ { fmt.Printf("% 5d % 5d\n", i, ageCounts[i]) } }
}
Types ¶
type Animal ¶
type Animal struct { Id AnimalId // This animal's simulation ID Sire AnimalId // This animal's sire simulation ID Dam AnimalId // This animal's dam simulation ID Sex string // Sex of this animal BirthDate Date // To calculate age YearBorn int // Year of simulation born Dead Date // Animal died - e.g. calving difficulty Active bool // Is this an active member of the herd - Cow or Bull DateCowEntered int // Date a heifer became an active cow DateCowCulled int // If this is a cow, what year was she culled HerdName string // Name of the Herd last active in BreedingValue *mat.VecDense // Breeding Values Residual *mat.VecDense // Residual values BreedComposition map[string]float64 // BreedingRecords []BreedingRec // Day of simulation bred if Cow AumToWeaning []Aum_t // By month and year AumWeanThruBackgrounding []Aum_t // By month CowAum []Aum_t FeedlotTotalFeedIntake float64 // This animal's feedlot total feed consumption HarvestWeight float64 // Weight as a fat animal at slaughter CarcassWeight float64 // actual carcass weight MarblingScore float64 // actual marbling score when slaughtered BackFatThickness float64 // actual backfat thickness when slaughtered RibEyArea float64 // actual ribeye area when slaughtered }
This is the animal class
func ActiveBulls ¶
Refresh the list of active cows in the herd
type AnimalId ¶
type AnimalId uint32 // Animal identification numbers sequentially generated starting at 1
type BreedComposition_t ¶
type BreedEffects_t ¶
type BreedEffects_t struct { TraitName string Component string // "D" for Direct, "M" for Maternal CowOrCalf string // Trait of a cow or trait of a calf - e.g., stay or bw direct Effects map[string]float64 // Array of breed effects in order of the breeds in the 1st row of the BreedEffects: key in master.hjson }
type BreedingRec ¶
type BreedingRecordsTable_t ¶
type BumpComponent_t ¶
type Component_t ¶
type Herd ¶
type Herd struct { // These are the parameters read from herds: in the hjson HerdName string // For example "Spring" or "Fall" NumberCows int // Target number of cows in this herd StartBreeding Date // Date starting to breed BreedingSeasonLen Date // Length of breeding season in days CowConceptionRate float64 // Average Conception rate per 21 d cycle Mean3CycleRate float64 // stay is based on 3 cycles of exposure CalvingDifficultyDistribution distuv.Normal // Unadjusted phenotype probability threshold for breeding set in MakeFoundationHeifers() InitialCalvingDeathLessRate float64 // Initial calving difficulty death loss rate // These are periodically reset Cows []*Animal // List of cows active in the herd Calves []*Animal // List of pre-weaning calves active in the herd Bulls []*Animal // Herd bulls - can be cleanup SumBirthDates []float64 // Sum of the birth dates within a year NBorn []float64 // number of calves born in a birth year }
type HerdYear_t ¶
type HeterosisValues_t ¶
type InterceptSlope_t ¶
Age effects in days