[Econ] Purchased feed cost preprocessing - #3215
Open
matthew7838 wants to merge 1 commit into
Open
Conversation
Adapts the purchased feed cost work to the refactored preprocessing pipeline: PurchasedFeedCostHandler reports purchased amounts (kg) as the biophysical quantity, derives per-feed prices from cost/amount outputs, and uses the purchase-amount-weighted average price so that biophysical_aggregate * price_aggregate equals the line item total. Shared fetch/expansion helpers move into PreprocessingContext.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uses the ration interval feed purchases (priced from the feed input file) for the "Purchased feed costs" economics line item, and teaches the preprocessing to handle interval-reported data.
Context
Issue(s) closed by this pull request: closes #3096
What
biophysical_aggregateis kg purchased (ration_interval_.*_amount_purchased),price_aggregateis the $/kg actually paid weighted by purchase amount (total $ ÷ total kg), andline_item_values_by_scenariois the $ total fromration_interval_.*_cost— sobiophysical_aggregate × price_aggregate = line_itemholds. The 23 commodity reference files are no longer fetched for this item.BIOPHYSICAL_FALLBACKSkeys for these patterns (ration_interval_*_costcould never match the mapping's pattern string)._fetch_pricesand the pricing logic inpreprocess()into small helpers (CodeFactor complexity).Why
The generic preprocessing treated the already-in-dollars interval costs as physical quantities and multiplied their sum by an average of 23 $/kg commodity prices — double-counting price. Ration interval outputs are also only reported on formulation days, so the series is shorter than daily data and needed explicit handling.
How
cost_simulationmapping key pairs the quantity pattern with the cost pattern; such items derive per-feed prices (cost ÷ kg, recovering the feed input file'spurchased_feed_cost) and sum costs directly for the line item instead of fetching commodity prices.expand_interval_to_dailymapping key fetches viafilter_variables_poolwithexpand_data/fill_value: 0.0(keyed by each value'ssimulation_day); skipped with a warning ifOutputManager.timeisn't initialized.Test plan
time, mapping/fallback key wiring, and the real mapping entry with data and with the empty-pool fallback.Input Changes
ECONOMIC_MAP).Output Changes
economic_preprocessedresults for "Purchased feed costs":biophysical_valuesare daily-length kg purchased (previously $ on formulation days),price_values/price_aggregateare the prices actually paid (previously unused commodity reference averages), and the line item total is unchanged.Filter
N/A