the simbatch simulation model
play

The SimBatch simulation model Anders Ringgaard Kristensen - PowerPoint PPT Presentation

Department of Large Animal Sciences The SimBatch simulation model Anders Ringgaard Kristensen Department of Large Animal Sciences System description A batch of slaughter pigs is simulated from insertion of the batch until slaughter.


  1. Department of Large Animal Sciences The SimBatch simulation model Anders Ringgaard Kristensen

  2. Department of Large Animal Sciences System description • A batch of slaughter pigs is simulated from insertion of the batch until slaughter. • The pigs are fed ad libitum. • Sent to a Danish slaughter house. • The highest price per kg is obtained in the “optimal” interval from 70 to 84 kg slaughter weight . • Delivery is decided on the basis of observed live weight. • The slaughter policy is decided by the farmer Advanced Quantitative Methods in Herd Management Slide 2

  3. Department of Large Animal Sciences Model type SimBatch is a • Dynamic (i.e. not static) time stepping model with daily updating of the states of the pigs and the batch. • Mechanistic (i.e. not empirical) model since it models a batch by modeling each individual pig. • Initially it is a deterministic model, but in the exercise it is step by step transformed into a stochastic model. • Monte Carlo simulation model, because the simulation mechanism is based on drawing random numbers from relevant distributions. Advanced Quantitative Methods in Herd Management Slide 3

  4. Department of Large Animal Sciences State of nature, Φ 0 # State of nature information stateOfNature = list(initialAverage = 30, # Average weight at insertion initialStdDev = 2, # Std. deviation of weight at insertion averageDG = 0.900, # Average daily gain stdDevDG = 0.100, # Std. dev. of daily gain between pigs autocorrelationDG = 0.99, # Autocor. for individual daily gain diseaseRisk = 0.01, # Risk of disease any day diseaseEffectAve = 0.250, # Average effect of disease diseaseEffectStd = 0.030, # Standard deviation of disease effect diseaseDurationAv = 5, # Average duration of disease liveToSlaughterAv = 0.76, # Live w. to slaughter w. conversion liveToSlaughterStd = 1.4, # Standard deviation of conversion lowerOptimal = 70, # Lower bound of opt. slaughter weight upperOptimal = 84, # Upper bound of opt. slaughter weight deliverEvery = 7) # Days btw. del.(7 = weekly, 1 = daily) Advanced Quantitative Methods in Herd Management Slide 4

  5. Department of Large Animal Sciences Decision strategy, Θ # Decision strategy information decisionStrategy = list(thresholdWeight = 100, # Intended live weight at slaughter minimumDelivery = 10, # Minimum number of pigs to send to maximumUnderWeight = 2, # Acc this number of pigs bel. Thresh. minimumStock = 50, # Minimum acc. stock: Send all if below maximumAge = 90) # Maximum age before slaughter # Strategy with completely individual delivery individualStrategy = list(thresholdWeight = 100, # Intended live weight at slaughter minimumDelivery = 1, # Minimum number of pigs to send to maximumUnderWeight = 0, # Acc this number of pigs bel. thres minimumStock = 0, # Minimum acc. stock: Send all if bel maximumAge = 9999) # Maximum age before slaughter # Strategy with slaughter at a given age ageStrategy = list(thresholdWeight = 9999, # Intended live weight at slaughter minimumDelivery = 9999, # Minimum number of pigs to send to maximumUnderWeight = 0, # Acc this number of pigs bel. thres minimumStock = 0, # Minimum acc. stock: Send all if bel maximumAge = 90) # Maximum age before slaughter Advanced Quantitative Methods in Herd Management Slide 5

  6. Department of Large Animal Sciences Modeling a pig A pig is defined by 4 state variables • Live weight in kg • The gain today in kg (if healthy) • An integer, i , defining the status of the pig: • i = -2: The pig has already been slaughtered • i = -1: The pig is healthy and still present • i ≥ 0: The pig is diseased and will stay diseased i days yet • The effect of disease (if any) on daily gain In SimBatch, a pig is represented on a given day by a vector with 4 elements. The state of the pig is updated every day. Advanced Quantitative Methods in Herd Management Slide 6

  7. Department of Large Animal Sciences Creating and printing a pig A valid pig object: > pig = c(45.0, 0.956, 3, 0.123) > pig [1] 45.000 0.956 3.000 0.123 A pig with a live weight of 45 kg, a gain until tomorrow of 956 g (if healthy). It is, however diseased and will stay diseased for 3 days. The effect of disease is a reduction in daily gain of 123 g Advanced Quantitative Methods in Herd Management Slide 7

  8. Department of Large Animal Sciences Simple functions used with a pig object getStartWeight(stateOfNature) : A start weight (in kg) is returned. Initially, it only returns the initial average from the state of nature. getInitialDG(stateOfNature) : An initial daily gain (in kg) for a pig is returned. Initially, it only returns the average daily gain from the state of nature. isPigDiseased(stateOfNature) : Returns a logical value. If the pig gets diseased it returns TRUE, otherwise FALSE. Initially, it always returns FALSE. getDiseaseEffect(stateOfNature) : Returns the reduction (in kg) of daily gain during a disease period. Initially it only returns the average disease effect from the state of nature. getDiseaseDuration(stateOfNature) : Returns the duration (in days) of a new disease. Initially, it only returns the average duration from the state of nature. getSlaughterWeight(liveWeight, stateOfNature) : Transforms the specified input parameter liveWeight to slaughter weight (in kg). Initially it just multiplies the live weight with the conversion ratio from the state of nature. getObservedWeight(liveWeight) : Returns the observed live weight of a pig with the specified true live weight. Initially, it just returns the true live weight (ignoring the observation error). updateDG(oldDG, stateOfNature) : Returns a new daily gain for the next 24 hours from the specified “old” daily gain (from the previous 24 hours). Initially, it just returns the old value (without any transform). Advanced Quantitative Methods in Herd Management Slide 8

  9. Department of Large Animal Sciences Function creating a piglet (don’t change) # Create a "30 kg" piglet at random createPiglet = function(son) { piglet = rep(NA, 4) piglet[1] = getStartWeight(son) # Draw initial live weight piglet[2] = getInitialDG(son) # Draw initial daily gain piglet[3] = -1 # Number of days remaining if diseased # If "-1": Healthy. If "-2": Slaughtered piglet[4] = 0 # Disease effect on daily gain return(piglet) } Advanced Quantitative Methods in Herd Management Slide 9

  10. Department of Large Animal Sciences Function updating a pig (don’t change) # Updates the state of a pig updatePig = function(pig, son) { pigNew = rep(NA, 4) If (pig[3] > -2) { # Is the pig still present? pigNew[1] = pig[1] + pig[2] - pig[4] # Yes, calculate new weight pigNew[2] = updateDG(pig[2], son) # Update daily gain if (pig[3] == -1) { # Is the pig healthy now? if (isPigDiseased(son)) { # Yes it was. Should it change state? pigNew[3] = getDiseaseDuration(son) # Yes it should. Draw duration of disease pigNew[4] = getDiseaseEffect(son) # Draw effect of disease } else { # No, the pig remains healthy pigNew[3] = -1 # Define it as healthy pigNew[4] = 0 # No effect of disease } } else { # No, the pig is already diseased if (pig[3] > 0) { # Has it still at least one day left of disease? pigNew[3] = pig[3] - 1; # Yes, reduce the number of days left by one pigNew[4] = pig[4] # Keep the disease effect on daily gain } else { # No, it is the last day of the disease pigNew[3] = -1; # Change state to healthy pigNew[4] = 0 # No disease effect next time } } } else { # The pig is already slaughtered pigNew = pig # Leave it as it is } return(pigNew) } Advanced Quantitative Methods in Herd Management Slide 10

  11. Department of Large Animal Sciences Representation of a batch on a given day Just an array of pigs. Example of a batch with 5 piglets: > pig1 = createPiglet(stateOfNature) > pig2 = createPiglet(stateOfNature) > pig3 = createPiglet(stateOfNature) > pig4 = createPiglet(stateOfNature) > pig5 = createPiglet(stateOfNature) > batchDay = array(NA, dim =c(5, length(pig1))) > batchDay[1,] = pig1 > batchDay[2,] = pig2 > batchDay[3,] = pig3 > batchDay[4,] = pig4 > batchDay[5,] = pig5 > batchDay [,1] [,2] [,3] [,4] [1,] 29.77745 0.8219607 -1 0 [2,] 27.78206 0.9373041 -1 0 [3,] 27.52593 0.8217774 -1 0 [4,] 31.96445 0.9472012 -1 0 [5,] 30.67659 0.8425552 -1 0 Advanced Quantitative Methods in Herd Management Slide 11

  12. Department of Large Animal Sciences Function updating a batch (don’t change) # Updates the state of a batch updateBatch = function(batchDay, son) { newBatchDay = array(NA, dim = c(length(batchDay[,1]), length(batchDay[1,]))) for (i in 1:length(batchDay[,1])) { # Iterate over pigs pigDay = batchDay[i,] # Take the i’th pig pigDay = updatePig(pigDay, son) # Update it newBatchDay[i,] = pigDay # Insert it in the updated batch } return(newBatchDay) # Return the updated batch } Function counting pigs left in a batch (don’t change) # Counts the number of pigs still present in the batch (not slaughtered) pigsLeft = function(batchDay) { left = 0 for (i in 1:length(batchDay[,1])) { if (batchDay[i,3] > -2) { left = left + 1 } } return(left) } Slide 12

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend