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

Separating the translation from the building #302

Closed
enekomartinmartinez opened this issue Nov 24, 2021 · 0 comments · Fixed by #312
Closed

Separating the translation from the building #302

enekomartinmartinez opened this issue Nov 24, 2021 · 0 comments · Fixed by #312
Assignees
Milestone

Comments

@enekomartinmartinez
Copy link
Collaborator

Separating the translation from the building may allow us to easily add more features in PySD.
One possible option is building a class that contains each element information and an abstract syntax tree (AST) using Vensim or Vensim-like notation.
Then we can apply a builder over this syntax tree. Some profits from this approach:

  • Merge in better way elements from different equations, making the output code much cleaner and faster
  • Identify better the operations inside Vensim definition, it will make it possible to identify the final subscript after any operation and thus to move to numpy.array based backend instead of xarray.DataArray, see also Identifying subscripts as Vensim does #301
  • Allow flexible translation to other languages, the AST can be used to build model elements in other languages or for example to Latex documents with the mathematical expressions or other coding languages.
  • Better debugging, if we split the translation from the building we will be able to better understand if we have some functions missing in PySD or the code from Vensim is corrupted.
  • Easier maintenance of Xmile-Vensim together, building the AST with Xmile models as well as with Vensim models will allow us to easily maintain both translators, as we only will have the syntax for splitting the information.
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 a pull request may close this issue.

1 participant