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

Model optimization: allow easy integration with scipy.optimize API #42

Open
benbovy opened this issue May 12, 2018 · 0 comments
Open

Model optimization: allow easy integration with scipy.optimize API #42

benbovy opened this issue May 12, 2018 · 0 comments

Comments

@benbovy
Copy link
Member

benbovy commented May 12, 2018

A preliminary idea would be to provide a helper function that returns a callable that can be easily used with scipy.optimize functions or with scikit-optimize.

The returned callable would basically do three things:

  • setup a new simulation (i.e., update from an existing setup with a new set of free parameters)
  • run the simulation
  • compute and return the result of either an external function that takes simulation output as input or a function attached to the model as a process.

The signature of the helper function might look like (naming could be better):

xsimlab.create_minimize_func(model, in_dataset, params, fvalue)

where:

  • model is an instance of xsimlab.Model
  • in_dataset is an input xarray.Dataset, which has for example been created using xsimlab.create_setup(model=model, ...)
  • params is a list with the names of the model inputs that are free parameters. This will correspond to the input arguments of the returned function to minimize.
  • fvalue is either the name of the variable in Model that correspond to the value of the function to minimize or a callable that take an output xarray.Dataset (as returned by Dataset.xsimlab.run(model=model)) and that returns the value of the function to minimize.

Optionally, the helper function might also return initial guesses for each free parameter (i.e., x0), taken directly from in_dataset.

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

No branches or pull requests

1 participant