Stores the modifications to the model since the previous checkpoint (or since creation of the Diff if Advance() has never been called).
Only the following modifications are tracked explicitly:
- elements before the checkpoint
- attributes with all elements in the key before the checkpoint as all changes involving an element after the checkpoint are implied to be in the difference.
- Note
- users of ElementalImpl can only access a const Diff.
When a element is deleted from the model, the creator of the Diff is responsible both for:
- Calling Diff::DeleteElement() on the element,
- For each Attr with a key element on the element type, calling Diff::EraseKeysForAttr() We cannot do this all at once for the user, as we do not have access to the relevant related keys in steps 3/4 above.
Definition at line 49 of file diff.h.
void operations_research::math_opt::Diff::Advance |
( |
const std::array< int64_t, kNumElements > & | checkpoints | ) |
|
Discards all tracked modifications, and in the future, track only modifications where all elements are at most checkpoint.
Generally, checkpoints should be component-wise non-decreasing with each invocation of Advance(), but this is not checked here.
Definition at line 23 of file diff.cc.
template<typename AttrType>
void operations_research::math_opt::Diff::EraseKeysForAttr |
( |
const AttrType | a, |
|
|
absl::Span< const AttrKeyFor< AttrType > > | keys ) |
|
inline |
Discard any tracked modifications for attribute a on keys.
Typically invoke when the element with id keys[i] is deleted from the model, and where keys are the keys k for all elements e where the e has a non-default value for a.
Definition at line 117 of file diff.h.