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

More flexible API for model creation and customization #62

Open
benbovy opened this issue Sep 27, 2019 · 2 comments
Open

More flexible API for model creation and customization #62

benbovy opened this issue Sep 27, 2019 · 2 comments
Labels

Comments

@benbovy
Copy link
Member

benbovy commented Sep 27, 2019

An alternative (or orthogonal) option to #52, inspired by PyMC3 and Keras Sequential model:

with xs.Model() as model:
    model.add(Grid, name='grid')
    model.add(Flow, name='flow')

    in_ds = xs.create_setup(...)
    out_ds.xsimlab.run()

The advantages of this approach:

  • Combine model creation/customization and setup/run within a same context block.
  • Allows to customize models in a more imperative style (i.e., track the order in which grid and flow are defined in the example above), which is sometimes necessary.
  • Possibility to add options to Model.add(), e.g., for setting user-defined process dependencies or resetting foreign variables.
@ben1post
Copy link

ben1post commented Jul 6, 2020

This possible feature looks very interesting, and might be helpful for my workflow.

To understand the aim correctly: Is the order that processes are added to the model recorded, and the processes will be initialized in that order at runtime? Or is this order only related to foreign variables and process dependencies?

@benbovy benbovy added the design label Nov 16, 2020
@benbovy
Copy link
Member Author

benbovy commented Mar 23, 2021

To understand the aim correctly: Is the order that processes are added to the model recorded, and the processes will be initialized in that order at runtime? Or is this order only related to foreign variables and process dependencies?

It should enable both. This is discussed in #164 (comment) and in #177, although using a different API that is a bit more flexible than the one here above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants