Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement DEPRECIATE STRAIGHTLINE #264

Merged
merged 5 commits into from
Oct 24, 2022

Conversation

ToddFincannonEI
Copy link
Collaborator

@ToddFincannonEI ToddFincannonEI commented Oct 24, 2022

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. Unlike FIXED DELAY, which is a special kind of level, DEPRECIATE STRAIGHTLINE is an aux variable. The implementation assigns a variable subtype of depreciation to trigger special handling in code gen. Also unlike FIXED 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. (The FIXED 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.

Copy link
Contributor

@chrispcampbell chrispcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ToddFincannonEI: This all looks like a clean addition to me, thanks.

Re: this comment in the PR description:

The fisc fiscal period argument is not supported in this implementation.

I think it would be good to have a table in the README (or somewhere in the docs) that lists out all the supported Vensim functions along with any per-function limitations/caveats. I just filed #265 today to track improvements I've been wanting to make to the README and docs in general, so assuming I add that table of supported functions as part of that work, I can include a note about fiscal period being unimplemented at this time.

@chrispcampbell chrispcampbell mentioned this pull request Oct 24, 2022
3 tasks
@chrispcampbell chrispcampbell changed the title feat: implement DEPRECIATE STRAIGHTLINE (#258) feat: implement DEPRECIATE STRAIGHTLINE Oct 24, 2022
@chrispcampbell chrispcampbell merged commit e93101e into main Oct 24, 2022
@chrispcampbell chrispcampbell deleted the todd/258-depreciate-straightline branch October 24, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the DEPRECIATE STRAIGHTLINE function
2 participants