xarray-simlab icon indicating copy to clipboard operation
xarray-simlab copied to clipboard

Model optimization: allow easy integration with scipy.optimize API

Open benbovy opened this issue 7 years ago • 0 comments

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.

benbovy avatar May 12 '18 11:05 benbovy