fix: average reward over agents in compute_system_rewards#7
Open
Dreamstick9 wants to merge 1 commit into
Open
Conversation
The averaging loop was inside the for-agent loop and modified agent_reward (the local per-agent dict) instead of reward (the accumulated total). This meant reward always held the raw sum of all agents' stats, inflating all values by N (num agents). Fix: move the averaging loop outside the for-agent loop and apply it to reward instead of agent_reward.
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: #4
Bug:
compute_system_rewardsreturns sum instead of averagePopulation.compute_system_rewardsis supposed to return the average of per-agent morphology statistics, but always returns the raw sum, inflating every value by a factor of N (number of agents).Root Cause
The averaging loop has two bugs:
agent_reward(local per-agent dict) instead ofreward(accumulated total)for agentloop, so the result is overwritten and discarded on the next iterationFix
Move the averaging loop outside the
for agentloop and apply it toreward:Impact
All keys returned by
compute_system_rewards—paradigms,stem_alternate_patterns,phonetic_non_confusability,stem_alternation_entropy,complexity,transfers, and the derivedtotal— are N× too large in any run with more than one agent.The existing test (
test_compute_system_rewards_presence_and_bounds) only checks key presence and that values are finite, so this was not caught automatically.