Running a profitable dairy farm means making hundreds of interconnected decisions every day — how many cows to milk, when to replace aging animals, how much feed to buy, how to handle manure, and how heat waves will affect production. Prof. Victor Cabrera's lab at UW–Madison has built free web-based tools that let farmers and agricultural advisors model these decisions mathematically and see the financial consequences before committing real money.
This project has two tracks. The first is making those tools more accessible: scripting and producing tutorial videos so dairy producers across the country can actually use them. The second is engineering: a powerful whole-farm simulation has been sitting broken on modern computers since 2016, and this project is diagnosing and rebuilding it.
Should a dairy farm switch to robotic milking?
Milking robots cost roughly $200,000 each — one of the biggest capital decisions a dairy farm can make. The AMS Transition Budgeter helps farmers think through whether that investment makes financial sense for their specific operation. Enter your herd size, current milk price, labor costs, and loan terms, and the tool projects your cash flow over 15 years — showing not just whether the robots pay off, but exactly when.
Key Inputs and Outputs
Web tool · LiveHow many cows, how much milk each produces, the price you receive, how many hours milking takes, and what you pay your labor. Pre-loaded with industry averages you can overwrite.
How many robots, what they cost, barn modification costs, loan terms, and ongoing labor per robot. Defaults reflect typical industry figures.
Robots typically increase yield ~5% because cows can be milked more frequently. They also require a special feed pellet and annual maintenance — all adjustable with sliders.
Annual profit after debt service, hours of labor eliminated, the wage rate at which robots break even, a 15-year cash flow curve, and a chart showing which assumptions matter most.
This tells you the minimum hourly wage at which robots become worth it. If you're already paying more than that, the investment pays off. The tool also shows which inputs — milk price, labor rate, robot cost — swing the outcome most, so you know where your assumptions matter.
Sanjay wrote the full walkthrough script, recorded the live tool, generated AI voiceover, and edited the final video. It's published on YouTube and linked on the lab's tools page at dairymgt.cals.wisc.edu.
Does cooling equipment pay for itself?
Dairy cows start losing milk production when it gets hot and humid — and in much of the U.S., that happens for weeks or months every summer. The Heat Abatement Investment Scouter uses 10 years of climate data for any U.S. location to estimate how much milk a farm is losing to heat stress each year, then calculates whether installing cooling equipment (fans and soakers) would pay for itself.
Methodology and Key Outputs
Web tool · LivePulls 10-year average temperature and humidity for your location and calculates how many hours per year fall into mild, moderate, and severe heat stress zones.
Translates heat stress hours into lost milk production using established research, applied to your herd size and average yield.
Enter cooling system cost, loan terms, and electricity/water operating expenses. The tool computes payback period and 5-year return on investment.
Shows projected heat stress hours in 2030 so producers can factor a warming climate into their long-term investment decision.
Sanjay wrote the script, recorded the video, then reshot it after the tool was updated to match a revised methodology. The final version is published on YouTube and linked on the lab's tools page.
A whole-farm dairy simulation — and an engineering problem
DyNoFlo is Prof. Cabrera's most ambitious tool — a whole-farm simulator built in Excel that tracks everything at once: the herd's milk production, what the cows eat, how manure moves through the farm, how crops grow, and whether it all makes money. Its central question: can a dairy farm reduce the nitrogen that leaches from manure into groundwater, without sacrificing profit? And does the answer change depending on whether it's an El Niño year?
Six Integrated Model Components
Markov + DSSAT + LPTracks every cow group by stage of lactation and pregnancy — computing monthly milk output, feed consumption, and manure nitrogen produced.
Models how different crops (grasses, corn, sorghum) grow on each field under different soil types and rainfall conditions — providing the feed and land-use side of the farm equation.
Follows nitrogen from the barn through every step — storage pond, sludge, land application — tracking how much leaches into groundwater versus stays in the soil.
Assigns each simulated year an El Niño, La Niña, or neutral weather pattern. Wetter El Niño winters drive far more nitrogen leaching — January alone can account for 30–40% of the annual total.
Calculates monthly and annual profit from milk revenue, animal sales, and all major expense categories. In a published case study, the optimized management plan cut nitrogen leaching 25% while raising profit 3%.
Finds the management strategy that maximizes profit while keeping nitrogen below a set limit — or vice versa. Run separately for each climate pattern so recommendations adapt to the forecast.
The compatibility problem
All of DyNoFlo's data, formulas, charts, and outputs are perfectly intact. The problem is the interactive layer — the buttons that run the simulation, switch between scenarios, and trigger the optimizer. These are powered by Visual Basic macros (VBA) that were written for Excel in 2004, and they simply don't work on any version of Excel released since 2003.
PtrSafe)
that the original code doesn't have. Together these cause a compile failure that
prevents any macro from running — and, critically, prevents saving any changes.
It's a catch-22: the broken state prevents the fix.
Three repair pathways
Importantly, the simulation logic itself requires no changes — only the interactive shell around it is broken. Once access to the underlying code is unlocked (which requires a project password from Prof. Cabrera), the actual fix is straightforward.
Tutorial videos for the lab's tool suite
Prof. Cabrera's tools are powerful, but only useful if people know how to use them. Each video walks through the tool from start to finish — what to enter, what the outputs mean, and how to read the results. Sanjay wrote the script, recorded the screen, generated voiceover, and edited the final video for each one.
What the model reveals about dairy nitrogen management
- El Niño winters drive the most nitrogen leaching — wetter, cooler conditions increase water percolation and reduce plant nitrogen uptake. La Niña years show the opposite.
- January alone accounts for 30–40% of total annual nitrogen leaching in the case study farm, making winter management the highest-leverage intervention window.
- Sandy, shallow soils leach dramatically more nitrogen than more retentive soils under identical management — soil type selection and site matching are critical.
- The most effective levers for reducing leaching without sacrificing profit: lowering dietary crude protein, planting bermudagrass in pastures and sprayfields, and strip-planting corn into bermudagrass sod.
- Climate-adaptive management matters: optimizer recommendations differ by ENSO phase. When El Niño is forecast, additional strategies include voluntary culling, exporting manure off-farm, or renting additional pasture.
- In the published 400-cow case study, optimization reduced nitrogen leaching by 25% while increasing profit by 3%. Feasible adjustments (a practical subset) still achieved 23% leaching reduction with 2.5% profit gain.