-
Notifications
You must be signed in to change notification settings - Fork 23
Don't store pointers in the ABM #757
Copy link
Copy link
Closed
Labels
class::improvementCleanup that doesn't affect functionalityCleanup that doesn't affect functionalityclass::performancePerformance related issuesPerformance related issuesloc::backendThis issue concerns the C++ backend implementation.This issue concerns the C++ backend implementation.model::abmThis issue concerns any kind of agent-based model.This issue concerns any kind of agent-based model.prio::highThe priority of this task is high.The priority of this task is high.status::in reviewThis issues is in review.This issues is in review.
Metadata
Metadata
Assignees
Labels
class::improvementCleanup that doesn't affect functionalityCleanup that doesn't affect functionalityclass::performancePerformance related issuesPerformance related issuesloc::backendThis issue concerns the C++ backend implementation.This issue concerns the C++ backend implementation.model::abmThis issue concerns any kind of agent-based model.This issue concerns any kind of agent-based model.prio::highThe priority of this task is high.The priority of this task is high.status::in reviewThis issues is in review.This issues is in review.
Type
Projects
Status
Done (Total) 💯
Motivation / Current Behaviour
Storing pointers to persons and locations in the ABM is convenient for programming, since it reduces the number of function arguments. But storing indices and only passing the actual objects when needed is much more flexible. Apart from performance improvements, it would also enable e.g. copying the World.
Two major performance problems that are caused by storing pointers:
Enhancement description
Persons don't store a pointer to locations. Instead they store an index, the location object is passed by the World as a function argument when necessary.
Locations don't store persons at all. When some accumulation of persons per Location is necessary, this should be done by iterating over all persons and caching the result. This requires less synchronization. (It might become necessary later for the locations to store indices to its persons. This can be added later.)
The world can store the locations and persons directly and doesn't need unique_ptr.
Additional context
No response
Checklist