feat: implement DEPRECIATE STRAIGHTLINE #264
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #258
This PR implements the Vensim
DEPRECIATE STRAIGHTLINE
function as required in #258.The C implementation is similar to
FIXED DELAY
. It uses a ring buffer to accumulate contributions from an input stream uniformly spread over a depreciation time. UnlikeFIXED DELAY
, which is a special kind of level,DEPRECIATE STRAIGHTLINE
is an aux variable. The implementation assigns a variable subtype ofdepreciation
to trigger special handling in code gen. Also unlikeFIXED DELAY
, it is necessary to initialize the ring buffer values to zero, because the buffer contents will start to be emitted on the very first time step. (TheFIXED DELAY
buffer has to fill up first before emitting any data.)A new
depreciate
test model demonstrates the function.The
fisc
fiscal period argument is not supported in this implementation.