params

package
v0.0.0-...-8ef749c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SteerCode  = "S"
	HeiferCode = "F"
	CowCode    = "C"
)

SexMap maps symbols to animal types

Variables

View Source
var (
	DefaultMasterPath = "./defaultMaster.hjson"

	DefaultWeaningPath    = "./defaultEcoWeaning.hjson"
	DefaultBackgroundPath = "./defaultEcoBackground.hjson"
	DefaultFatPath        = "./defaultEcoFatcattle.hjson"
	DefaultSlaughterPath  = "./defaultEcoSlaughtercattle.hjson"

	DefaultWeaningTerminalPath    = "./defaultEcoWeaningTerm.hjson"
	DefaultBackgroundTerminalPath = "./defaultEcoBackgroundTerm.hjson"
	DefaultFatTerminalPath        = "./defaultEcoFatcattleTerm.hjson"
	DefaultSlaughterTerminalPath  = "./defaultEcoSlaughtercattleTerm.hjson"
)

Default filepaths the the files to treat as default

View Source
var (
	Weaning    = Endpoint{Internal: "weaning", Display: "weaning"}
	Background = Endpoint{Internal: "background", Display: "background"}
	Fat        = Endpoint{Internal: "fatcattle", Display: "fed cattle (live)"}
	Slaughter  = Endpoint{Internal: "slaughtercattle", Display: "fed cattle (carcass)"}

	EndpointMap   = map[string]Endpoint{Weaning.Internal: Weaning, Background.Internal: Background, Fat.Internal: Fat, Slaughter.Internal: Slaughter}
	EndpointSlice = []Endpoint{Weaning, Background, Fat, Slaughter}
)

Possible endpoints

View Source
var (
	OwnReplacements = IndexType("Creates own replacements")
	Terminal        = IndexType("Terminal")

	IndexTypes = []IndexType{OwnReplacements, Terminal}
)

Possible IndexTypes

View Source
var SexMap = map[string]string{
	SteerCode:  "Steer",
	HeiferCode: "Heifer",
	CowCode:    "Cow",
}
View Source
var TraitMap = []Component{
	{"USREA,D", "USREA,D", "Ultrasounded rib-eye area", false},
	{"USIMF,D", "USIMF,D", "Ultrasounded intramuscular fat", false},
	{"USFAT,D", "USFAT,D", "Ultrasounded backfat thickness", false},
	{"HCW,D", "HCW,D", "Hot carcass weight", false},
	{"REA,D", "REA,D", "Carcass rib-eye area", false},
	{"FAT,D", "FAT,D", "Carcass backfat thickness", false},
	{"MS,D", "MS,D", "Carcass marbling score", false},
	{"BW,D", "BW,D", "Birth weight", false},
	{"WW,D", "WW,D", "Weaning weight - Direct", false},
	{"WW,M", "WW,M", "Weaning weight - Maternal", false},
	{"YW,D", "YW,D", "Yearling weight", false},
	{"FI,D", "FI,D", "Daily dry matter intake", false},
	{"MW,D", "MW,D", "Mature cow weight", false},
	{"STAY,D", "STAY,D", "Probability of a cow staying in the herd to age six given that she calved as a 2-year-old", false},
	{"HP,D", "HP,D", "Probability of conceiving as a 2-year-old heifer", false},
	{"CE,D", "CD,D", "Calving ease - Direct", false},
	{"CE,M", "CD,M", "Calving ease - Maternal", false},
}

TraitMap maps trait symbols to descriptions

Functions

func TraitKeys

func TraitKeys() []string

TraitKeys returns all traits in a sorted slice

Types

type AgeRange

type AgeRange struct {
	Age     int
	Percent float64
}

AgeRange collects values for age distribution field

type BreedComposition

type BreedComposition struct {
	Name       string
	Encoded    string
	BreedProps []BreedProp `json:"-"`
}

BreedComposition holds a breed composition for the breeds page

type BreedProp

type BreedProp struct {
	Breed, Prop string
	Breeds      []string
}

BreedProp is a single breed-percent pair

type Component

type Component struct {
	Display     string
	Short, Long string
	Selected    bool
}

Component contains a code, description, and boolean value for whether or not this field is selected Used for the index components

type EcoParams

type EcoParams struct {
	SaleEndpoint        string      `json:"saleEndpoint"`
	IndexTerminal       bool        `json:"indexTerminal"`
	IndexComponents     []string    `json:"indexComponents"`
	TraitSexPricePerCwt []string    `json:"traitSexPricePerCwt"`
	DiscountRate        string      `json:"discountRate"`
	AumCost             [12]float64 `json:"aumCost"`
	BackgroundAumCost   [12]float64 `json:"backgroundAumCost"`
	BackgroundDays      int         `json:"backgroundDays"`
	DaysOnFeed          float64     `json:"daysOnFeed"`
	FeedlotFeedCost     string      `json:"feedlotFeedCost"`
	GridPremiums        []string    `json:"gridPremiums"`
	ProportionInProgram string      `json:"proportionInProgram"`
}

EcoParams should mock the economical optional input file for iGenDec

func DefaultEcoParams

func DefaultEcoParams(endpoint Endpoint, indextype IndexType) (*EcoParams, error)

DefaultEcoParams returns the default eco params as seen in ecoIndex.hjson Every user will be initilised with this struct

func EcoParamsFromFile

func EcoParamsFromFile(filename string) (*EcoParams, error)

EcoParamsFromFile reads in an eco parameter file

func (*EcoParams) Bytes

func (params *EcoParams) Bytes() ([]byte, error)

Bytes returns the marshalled index params If need to change the way we process the params, can easily do here

func (*EcoParams) ToMap

func (params *EcoParams) ToMap(m map[string]interface{}) map[string]interface{}

ToMap returns the values we need from the struct in a fiber compatible map

type Endpoint

type Endpoint struct {
	Internal string
	Display  string
}

Endpoint is a possible endpoint a file can have

type HerdComposition

type HerdComposition struct {
	Count, BreedComp interface{}
}

HerdComposition holds a breed compostion

type HerdCompositionType

type HerdCompositionType struct {
	ID     string
	Values []HerdComposition
}

HerdCompositionType holds a slice of BreedCompositions and an identifier for templating reasons

type IndexType

type IndexType string

IndexType is the type of index they want to run

type MasterParams

type MasterParams struct {
	Comment        string `json:"comment"`
	TargetDatabase string `json:"target-database,omitempty"`

	Burnin                        int                `json:"burnin"`
	PlanningHorizon               int                `json:"planningHorizon"`
	Traits                        []string           `json:"Traits"`
	Components                    []string           `json:"Components"`
	Genetic                       [324]float64       `json:"genetic"`
	Residual                      [225]float64       `json:"residual"`
	BreedEffects                  []string           `json:"BreedEffects"`
	HeterosisCodes                []string           `json:"HeterosisCodes"`
	HeterosisValues               []string           `json:"HeterosisValues"`
	BreedTraitSexAod              []string           `json:"BreedTraitSexAod"`
	TraitAgeEffects               []string           `json:"TraitAgeEffects"`
	AgeDist                       []string           `json:"ageDist"`
	NFoundationBulls              int                `json:"nFoundationBulls"`
	MeritFoundationBulls          []float64          `json:"meritFoundationBulls"`
	Herds                         []string           `json:"herds"`
	CalfAum                       float64            `json:"calfAum"`
	CowAum                        float64            `json:"cowAum"`
	CowHerdBreedComposition       []interface{}      `json:"CowHerdBreedComposition"`
	BullBatteryBreedComposition   []interface{}      `json:"BullBatteryBreedComposition"`
	CurrentCalvesBreedComposition []interface{}      `json:"CurrentCalvesBreedComposition"`
	BreedCompositions             []BreedComposition `json:"BreedCompositions"` // Custom field - will be ignored by iGenDec
}

MasterParams should mock main file for iGenDec

func DefaultMasterParams

func DefaultMasterParams() (*MasterParams, error)

DefaultMasterParams returns the default master parameter file for users

func MasterParamsFromFile

func MasterParamsFromFile(filename string) (*MasterParams, error)

MasterParamsFromFile parses a master parameter file and validifies the fields

func (*MasterParams) Bytes

func (params *MasterParams) Bytes() ([]byte, error)

Bytes returns the marshalled index params If need to change the way we process the params, can easily do here

func (*MasterParams) ToMap

func (params *MasterParams) ToMap(m map[string]interface{}) map[string]interface{}

ToMap returns the values we need from the struct in a fiber compatible map Has to set up some fields to work with the front end

type NameVal

type NameVal struct {
	Name    string
	Val     float64
	Display bool
}

NameVal is a name string to numeric value pair

type TraitSexPriceField

type TraitSexPriceField struct {
	Trait                 string
	Sex                   string
	WeightLow, WeightHigh int
	Cost                  float64
}

TraitSexPriceField is a single field in TraitSexPricePerCWT element

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL