Skip to content

fix: preserve falsy evaluation values in find_combinations#3237

Merged
quaquel merged 4 commits intomesa:mainfrom
souro26:fix-find-combinations-falsy-values
Feb 4, 2026
Merged

fix: preserve falsy evaluation values in find_combinations#3237
quaquel merged 4 commits intomesa:mainfrom
souro26:fix-find-combinations-falsy-values

Conversation

@souro26
Copy link
Copy Markdown
Contributor

@souro26 souro26 commented Feb 3, 2026

Summary

This PR fixes a logic error in find_combinations where valid evaluation results were silently discarded when their value was falsy (e.g. 0.0). As a result, combinations with legitimate zero-valued scores were incorrectly excluded from the output.

Bug / Issue

evaluation_func is typed to return a float, and evaluate_combination returns (candidate_group, value) when evaluation succeeds.
However, find_combinations previously filtered results using a truthiness check (if result:), which caused valid falsy values such as 0.0 to be dropped unintentionally.

This behavior is inconsistent with the function’s type contract and makes it impossible for users to represent neutral or zero-utility combinations.

Implementation

  • Replaced the truthiness check with an explicit is not None check to distinguish between “no evaluation result” and valid falsy values

  • Renamed a local variable for clarity to reflect that the group is a tuple rather than a set

The change is behavior-preserving for all non-falsy values and only affects cases that were previously handled incorrectly.

Testing

  • Added a regression test that verifies combinations with zero-valued evaluation results are preserved

  • All existing meta_agents tests pass

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 3, 2026

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -1.5% [-2.7%, -0.1%] 🔵 -0.6% [-0.8%, -0.4%]
BoltzmannWealth large 🔵 +0.3% [-0.4%, +1.1%] 🔵 -2.9% [-3.9%, -1.7%]
Schelling small 🔵 +1.4% [+1.0%, +1.9%] 🔵 +2.2% [+2.1%, +2.4%]
Schelling large 🔵 +1.2% [+0.8%, +1.6%] 🔴 +7.1% [+4.8%, +9.4%]
WolfSheep small 🔵 -1.5% [-2.0%, -0.9%] 🔵 +0.8% [+0.5%, +1.0%]
WolfSheep large 🔵 +4.0% [+1.9%, +5.7%] 🔵 +4.1% [+2.5%, +5.8%]
BoidFlockers small 🔵 +1.6% [+0.7%, +2.5%] 🔵 +0.2% [-0.1%, +0.4%]
BoidFlockers large 🔵 +1.5% [+1.0%, +2.0%] 🔵 +0.0% [-0.4%, +0.4%]

@quaquel quaquel added the bug Release notes label label Feb 3, 2026
@quaquel quaquel merged commit 706051e into mesa:main Feb 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants