cyclus/core — Issue #32: Fix agent list bookkeeping to function despite model dealloc
Author: rwcarlsen
Created: 2012-02-13 20:23:41+00:00
State: open

This was discovered while trying to implement issue #30. Current Agent list recording paradigm:

* the simulation runs the entire specified duration
* at sim end, BookKeeper queries a unversal (static) model list kept in the Model class
* BookKeeper builds structured tables of model data
* BookKeeper writes data to file.

Problems with this:

* Model bookkeeping is only performed at the end of the simulation - no ability for 'chunking', buffering
* Forces us to keep all model objects in memory for duration of the simulation - we can never use destructors - at least not until after BookKeeper queries the model list and builds the structured data.

Proposed solution:

* BookKeeper keeps a map of structs: keys=model-ID, values=structs filled with the agent data (ID, name, impl, birth, death, isTemplate, etc.)
* Whenever a model undergoes any change, it invokes BI->registerAgentDatum(model_id, "[parameter name]", param_new_value).

This will allow the bookkeeper to write as often as it wants. And since it won't store/use the actual model objects (or pointers to them) themselves, the process is unaffected by the deallocation of model objects. This will eliminate the need to keep is/isn't template-segregated static lists in the Model class - just kidding - I think we need to keep the lists separate to facilitate fast/clean access to templates throughout the simulation regardless of how many non-template models there are.