Skip to content

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

Open
@benbovy

Description

@benbovy

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions