-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The goal is to calculate the efficiency of converting feed input into weight gain, often expressed as a feed conversion ratio (FCR):
FCR = Feed Intake (kg)/Weight Gain (kg)
Lower FCR values indicate better feed efficiency.
Inputs:
• Feed intake (kg/day).
• Time period (days).
• Weight gain (kg/day).
Outputs:
• FCR value.
• Insights (e.g., efficiency rating).
Proof of Concept
/// Represents feed conversion data for livestock.
pub struct FeedConversion {
pub feed_intake_kg: f64, // Feed intake in kg
pub weight_gain_kg: f64, // Weight gain in kg
}
impl FeedConversion {
/// Calculates the feed conversion ratio (FCR).
pub fn calculate_fcr(&self) -> f64 {
self.feed_intake_kg / self.weight_gain_kg
}
/// Provides an efficiency rating based on the FCR value.
pub fn efficiency_rating(&self) -> &'static str {
let fcr = self.calculate_fcr();
match fcr {
f if f < 2.0 => "Excellent",
f if f < 3.0 => "Good",
f if f < 4.0 => "Average",
_ => "Poor",
}
}
}Different animals (e.g., cattle, goats, chickens) have unique feed requirements and efficiencies. We can add per-species logic:
pub struct Livestock {
pub species: String, // E.g., "Cattle", "Goat", "Chicken"
pub conversion_data: FeedConversion,
}
impl Livestock {
/// Creates a new Livestock instance.
pub fn new(species: &str, feed_intake: f64, weight_gain: f64) -> Self {
Self {
species: species.to_string(),
conversion_data: FeedConversion {
feed_intake_kg: feed_intake,
weight_gain_kg: weight_gain,
},
}
}
/// Calculates FCR for the livestock.
pub fn feed_conversion_ratio(&self) -> f64 {
self.conversion_data.calculate_fcr()
}
/// Gets efficiency rating for the livestock.
pub fn efficiency(&self) -> &'static str {
self.conversion_data.efficiency_rating()
}
}Optimal FCR values vary by species and production goals:
• Broiler Chickens: ~1.5–2.0 (very efficient animals).
• Pigs: ~2.5–3.5.
• Beef Cattle: ~5–6 (depends on production systems and feed quality).
• Sheep and Goats: Generally higher FCRs due to slower growth rates and smaller size.
• Fish (e.g., tilapia): ~1.2–1.5 (very efficient in aquaculture).
We need to find a source and more precise values for this information ^
We need to ensure we add tests:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feed_conversion() {
let cattle = Livestock::new("Cattle", 10.0, 5.0);
assert_eq!(cattle.feed_conversion_ratio(), 2.0);
assert_eq!(cattle.efficiency(), "Good");
let inefficient_goat = Livestock::new("Goat", 12.0, 2.0);
assert_eq!(inefficient_goat.feed_conversion_ratio(), 6.0);
assert_eq!(inefficient_goat.efficiency(), "Poor");
}
}Example Usage
use livestock_rs::{FeedConversion, Livestock};
fn main() {
let cattle = Livestock::new("Cattle", 15.0, 7.5);
println!("FCR for {}: {:.2}", cattle.species, cattle.feed_conversion_ratio());
println!("Efficiency: {}", cattle.efficiency());
}Potential Next-steps
- Feed Recommendation Calculator: Extend this feature by suggesting feed types and quantities based on animal species, weight, and growth goals.
- Time-Based Growth Prediction: Incorporate expected growth rates over time.
- Integration with Real Data: Allow users to input data for breed-specific FCR averages.