Repository navigation
fix: invalidate optimization grids when scenario inputs change - #1997
Open
AliFozooni wants to merge 1 commit into
Open
AliFozooni wants to merge 1 commit into
AliFozooni wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This branch has not been deployed
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.
Fixes #1996.
Reusing an optimization grid after changing media delivery at the same spend and dates can optimize the old response curves while reporting results for the new scenario. The existing grid validator checks dates, channel names, options, and spend bounds, but not the inputs that generated those curves.
This change fingerprints the filled scenario inputs when building a grid and checks them before reuse. It covers media, reach, frequency, media/RF spend, revenue per KPI, and time coordinates. Equivalent explicit and implicit historical data still share a grid; changing scenario data warns and rebuilds it. The fingerprint keeps no additional copies of the input tensors.
Weekly grids carry the fingerprint into
to_optimization_grid. Combining weekly grids preserves it only when all source fingerprints agree. Grids with unknown provenance, including older or manually constructed grids, are rebuilt byBudgetOptimizerrather than being assumed compatible; standalone grid allocation remains available.Tests exercise the public optimizer and compare rebuilt grids and results against fresh optimization for each scenario input. They also cover returning from an overridden scenario to historical data, unchanged-input reuse, weekly conversion, and combined grids. The reproduction fails on unchanged upstream code because the stale grid is accepted.
Two existing weekly comparison tests used autospecced
wrapsspies that returned empty mocks on Python 3.11, producing six failures on unchanged upstream. They now execute the real grid construction and assert thatBudgetOptimizerreuses the returned grid directly.Validation (Python 3.11):
optimizer_test.pyandweekly_optimization_grid_test.py(-k grid).git diff --checkpassed.Focused reproduction: