Document Agent hashability requirement#3104
Conversation
|
Performance benchmarks:
|
|
Wow I didn’t expect this much performance impact. Especially WolfSheep is terrible, it’s the only model that actively removes and adds agents during the run. I don’t think this is a proportional performance trade-off, glad we have the benchmarks. Curious if there are more efficient ways to enforce hashibility. |
Right, benchmarks got us safe. |
Agent hashability explicit in type systemAgent hashability requirement
|
I have updated the pr description to be precise. |
|
Performance benchmarks:
|
Summary
Clarifies the requirement for Mesa agents to be hashable and adds tests to verify this behavior, particularly when
__eq__is overridden in subclasses.Motive
AgentSetrequires agents to be hashable because it uses them in aWeakKeyDictionary. This requirement was previously implicit. An earlier attempt to enforce this via the type system (collections.abc.Hashable) was reverted due to significant performance regressions.Implementation
Usage Examples
Additional Notes