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: add basic support for GET DATA BETWEEN TIMES function #42

Merged
merged 1 commit into from
Sep 13, 2020

Conversation

chrispcampbell
Copy link
Contributor

This adds support for the GET DATA BETWEEN TIMES function, which can be used to look up a value from an external data variable.

I originally thought it would behave exactly like the existing __lookup function, but there are subtle differences so I split it out into a separate __get_data_between_times function.

Our results match Vensim exactly for mode=1 ("look forward") and mode=-1 ("hold backward") for both whole and fractional inputs, and for mode=0 ("interpolate") for integral inputs. For some reason Vensim produces unexpected results for interpolate mode when the input is fractional. For now I added a warning message that gets printed once if this case is detected.

In the En-ROADS model, this function is only used in a few places, and each time it passes mode=1 ("look forward"), so it's not urgent to fix that issue with the interpolate case (and fractional inputs are probably uncommon for that scenario), but we can circle back to it another time.

Fixes #33

@chrispcampbell chrispcampbell merged commit 8a294aa into develop Sep 13, 2020
@chrispcampbell chrispcampbell deleted the ccampbell/33-get-data-between-times branch September 13, 2020 06:54
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.

Add support for GET DATA BETWEEN TIMES
1 participant