About the project

Dairy Horizon is a decision-support tool that compares dairy heat-abatement measures as phased investment pathways rather than one-time equipment purchases. It also accounts for future herd plans.

Japanese summers are hot and humid, making it difficult for dairy cows to dissipate heat. Heat stress can affect milk yield, feed intake, reproduction, and health. Adding circulation fans can strengthen heat abatement, but it also increases equipment, installation, and electricity costs. Farms must balance animal protection with financial burden under limited budgets.

Herd size may also change within several years. Building for today’s herd can become excessive after herd reduction, while sizing only for a smaller future herd can leave cows insufficiently protected during the transition.

Dairy Horizon visualizes the current estimated gaps in a barn and compares three pathways: maintaining the current setup, adding a limited number of fans as Phase 1, or installing enough fans to reach the initial herd-size benchmark. It addresses both the need to protect cows now and the risk of overbuilding for the future.

The purpose is not to automatically recommend equipment. It is an initial screening tool for organizing this question:

How much should be improved now, what should be measured next, and under what conditions should the farm move to the next phase?

It is intended as a shared reference before requesting quotations or conducting an on-site assessment, not as a final investment decision.

This prototype focuses on existing tie-stall barns, where fixed cow positions make it possible to visualize estimated fan coverage and compare phased improvements. It is intended to improve current facilities, not to promote new tie-stall construction.

Inspiration

A single answer to “How many fans are needed?” is not enough to support an investment decision. Airflow effectiveness depends on barn structure, fan performance, placement, angle, obstacles, and air speed at cow level. The decision also depends on equipment cost, electricity cost, and both current and future herd size.

These inputs usually exist separately in weather datasets, industry documents, and information held by farmers and suppliers. Farmers may not have every value at the beginning.

Instead of declaring one optimal answer, we built a system that compares multiple pathways using the information currently available. It presents each pathway’s conditions for viability, limitations, and the next information worth verifying.

What it does

The prototype starts with a reference case in Chiba City: a two-row tie-stall barn with 60 cows, 10 existing fans, a target herd of 45 cows in five years, and five additional fans in Phase 1. Users can explore this reference farm or change the inputs to approximate their own operation.

1. Enter farm conditions in natural language or as numbers

A user can write:

We currently have 60 cows in two rows and 10 fans. We are considering reducing the herd to 45 cows in five years.

The OpenAI Responses API and Structured Outputs convert explicitly stated information into candidate inputs, including location, cow count, row count, existing fans, and future herd size when provided.

The AI does not invent equipment prices or required fan counts. Extracted values are shown for confirmation before calculation. Users can also enter values directly, and the main calculations remain available when the OpenAI API is unavailable.

2. Visualize the current estimated gap

For initial screening, Dairy Horizon uses the benchmark of at least one fan per three cows described in guidance from Japan’s National Federation of Dairy Co-operative Associations (ZENRAKUREN). For 60 cows, this gives an initial benchmark of 20 fans, 10 more than the existing setup.

The 2.5D barn view distinguishes covered, uncovered, and newly covered cows, together with candidate fan locations. It makes the remaining gap easier to discuss than a single number.

This is an early estimate based on herd size, row count, and evenly distributed equipment. It does not guarantee actual airflow coverage or the final number of fans required. A final plan must verify fan specifications, placement, angle, obstacles, and measured air speed at cow level.

3. Compare three investment pathways

Adding five fans in Phase 1 still leaves a gap for the current herd of 60 cows. However, if the herd is reduced to 45 cows within five years, 15 fans may satisfy the initial herd-size benchmark at that point.

Maintaining the current setup minimizes immediate investment but leaves the gap unchanged. Phase 1 reduces it while preserving the option to measure results before investing again. Full build-out reduces it most substantially, but has the highest cost and may become excessive after herd reduction.

For each pathway, Dairy Horizon shows added fans, estimated uncovered cows, equipment cost, annual burden, and the conditions required for economic viability. The comparison focuses on what each pathway improves and what uncertainty it leaves unresolved.

4. Show observed and future climate conditions

For the present-day baseline, Dairy Horizon uses observations from the Japan Meteorological Agency and calculates the Temperature-Humidity Index (THI). For future conditions, it uses multiple CMIP6 models available through the Open-Meteo Climate API.

The system calculates change between baseline and future periods within each model, applies that change to observations, and shows the median and inter-model spread rather than treating one model as the correct future.

Days with a daily mean THI of 72 or higher are grouped into the present-day baseline, 2026–2030, and 2031–2034. The system does not extrapolate beyond prepared data, and it does not derive a required fan count or installation year from THI alone. Heat-stress days are background information indicating how the operating season and equipment burden may change.

5. Present annual burden, boundary conditions, and the next item to verify

The investment model is based on ZENRAKUREN’s COW BELL No.178: Evaluating Investments in Heat-Abatement Equipment. Using equipment cost, installation cost, power consumption, operating days, electricity price, and service life, the system calculates the annual burden and the conditions under which an investment could be economically supported.

This is not a forecast of total farm profitability. It does not include loan repayment, taxes, labor, feed costs, or all farm-level fixed costs, and it does not automate a contract or lending decision.

The result is therefore not “this investment will succeed.” It is:

Under these assumptions, how much production impact would need to be avoided to cover the annual burden?

Users can change the equipment quotation, milk price, electricity rate, operating hours, and assumed production impact prevented by heat abatement. The system shows where the classification changes. This is sensitivity analysis, not a point forecast.

Finally, Dairy Horizon identifies one missing input that most strongly affects the result, such as the actual quotation, measured air speed, or future herd size. It asks for the next useful piece of information rather than demanding every value at the beginning.

The calculations, climate aggregation, and industry-based formulas are the more reliable parts of the prototype. Estimated airflow coverage, prevented milk loss, and real-farm investment effects remain unvalidated, and the interface states this explicitly.

How we built it

Dairy Horizon connects three foundations:

  1. Japan Meteorological Agency observations for present-day temperature, humidity, and THI
  2. Multiple CMIP6 models from Open-Meteo for future changes and inter-model spread
  3. ZENRAKUREN COW BELL No.178 for initial screening of circulation-fan investments

We distinguish observations, model outputs, industry assumptions, user inputs, and demo assumptions. Deterministic Python handles fan counts, costs, climate aggregation, pathway classification, sensitivity analysis, and the next item to verify. The AI does not generate equipment costs, climate values, or equipment effects.

The application was built with Python, FastAPI, Jinja2, JavaScript, and SVG. Calculation logic, climate processing, AI integration, and presentation are separated. Natural-language input uses Structured Outputs with a fixed schema, while result explanations receive only calculated data. pytest covers calculations, boundary cases, fallbacks, and validation of AI-generated explanations.

How Codex and GPT-5.6 contributed

We used GPT-5.6 as a design and validation partner. Together, we examined whether THI could directly determine equipment quantity, how to separate a herd-size benchmark from actual airflow effectiveness, how to connect observations to multiple climate models, and which parts of an investment decision should never be delegated to an LLM.

This clarified two boundaries. THI is background information about heat exposure, not sufficient evidence for determining fan quantity. AI should support input and explanation rather than perform calculations or make the final classification.

Early in development, we tested a design in which the LLM generated the main explanation and classified the pathways. It sometimes turned a cautious comparison into a strong recommendation, described a heat-abatement-only comparison as total farm profitability, or changed the meaning of a classification that had already been calculated.

We therefore moved pathway classification, economic assessment, and selection of the next item to verify back into Python. If an LLM explanation contradicts the result, the system rejects it and either regenerates the explanation or falls back to deterministic text.

Codex turned this design into software. It separated climate data, investment calculations, AI integration, and the interface into independent modules; converted industry formulas into reproducible Python; and added tests for invalid inputs, boundary cases, API unavailability, and AI contradictions. It also maintained fallbacks and regression tests as specifications changed.

The current project passes 159 automated tests, with nine external-environment-dependent tests skipped.

OpenAI’s contribution was not to make the investment decision. GPT-5.6 helped identify the boundary beyond which AI should not be trusted, and Codex translated that boundary into verifiable calculations, output checks, fallbacks, and automated tests.

Challenges we faced

1. THI cannot directly determine the required number of fans

THI alone does not account for barn dimensions, fan performance, placement, angle, obstacles, air speed at cow level, duration of heat exposure, nighttime recovery, or cow condition.

We therefore separated THI as climate context, one fan per three cows as an initial herd-size benchmark, and final equipment planning as a decision requiring on-site measurement. We did not implement a rule that automatically adds fans when the climate becomes hotter.

2. Avoiding false precision

When airflow coverage or prevented production loss has not been measured, the result depends on assumptions. We distinguish user inputs, observations, climate models, industry assumptions, calculated results, demo assumptions, and values requiring field measurement.

Displaying “unknown,” “not available,” or “requires on-site verification” is part of the product. We prioritized communicating how far a value can be trusted over displaying more precise-looking numbers.

3. An LLM can change the meaning of a calculated result

The LLM sometimes described conditional results as guaranteed effects, recommended phased investment as universally optimal, or introduced numbers not present in the calculation.

We fixed values and classifications in Python and limited AI to explaining validated results. Outputs are rejected if they introduce unknown numbers, guarantee an outcome, or contradict the calculated classification. The main application still works when AI is unavailable.

What we learned

The value of AI in decision support is not its ability to freely predict future numbers.

AI was useful for converting natural language into candidate inputs, organizing complex results, and explaining missing information and next actions. Equipment cost, electricity cost, climate aggregation, and pathway classification must be handled by deterministic code with sources, units, and tests.

Producing a natural explanation and preserving a decision correctly are different capabilities. Humans remain responsible for evidence selection, model boundaries, and unresolved relationships.

We also learned that a single recommendation is often less useful than showing what can be done now, what does not need to be decided yet, what should be measured next, what conditions would change the decision, and what the current model cannot determine. Phased investment is not always correct, but it is an important pathway to compare when future herd size and actual equipment effectiveness remain uncertain.

What's next

  1. Validate the model on real farms. Collect barn dimensions, fan positions and specifications, air speed at cow level, operating hours, and actual quotations, then test the estimated gaps and economic classifications before and after installation.
  2. Expand the scope. Add regions beyond Chiba City, different fan performance profiles, and other measures such as sprinklers, misting, and roof heat shielding when sufficient evidence is available.
  3. Extend the model into multi-year pathways. Incorporate hourly heat exposure and equipment operation, then compare what should be observed after Phase 1 and which conditions should trigger Phase 2. Longer term, farmers, veterinarians, extension advisors, and equipment suppliers could use the same interface to prioritize quotations and on-site measurements.

References

Built With

Share this project:

Updates