Closed luisfabib closed 4 years ago
Just my two cents, feel free to ignore: Why not using classes for that? ;-) Then it would be possible to inherit from a base 'model' class to all models and also combining of models could be easier, if a destinguished method is implemented.
All parametric models in DeerLab when called without inputs return a
info
structure which contains the essentials (start values, boundaries, parameter names,...) needed to setup optimization with built-in models and constraints.Structure
At the moment
info
looks like this, e.g. for thedd_gauss
model it is defined as:and calling the model function returns
While it is a simple data type, extracting the information on the parameters is cumbersome, since for each parameter there is an associated nested structure:
First there is no clear oversight of the parameters due to the nested nature of these structures. Second, extracting the different default values, ranges, and so on for all parameters is cumbersome:
Here I propose an alternative interface.
Tables
This data fundamental data type from MATLAB provides an interesting candidate for the interface of these models. A table for the
dd_gauss
can be defined similarly as above:but now calling the model function returns a full (and well formatted) table with the full summary of the model parameters:
The retrieval of information would also be largely simplified. For example to reproduce the code above to retrieve the start, upper and lower bound values we need:
The main difference is that the additional fields
nparam
andmodel
, containing the number of parameters and model name cannot be included in the table. The loss ofnparam
is irrelevant as it can be obtained from the number of rows, but the model name cannot be hard-coded into the table.Therefore, tables appear to be a potential candidate for this interface. Although I would need more thought before implementing this.