Open-Systems-Pharmacology / OSPSuite.ParameterIdentification

R package for parameter identification for OSPS models
http://www.open-systems-pharmacology.org/OSPSuite.ParameterIdentification/
GNU General Public License v2.0
3 stars 2 forks source link

How to change a single option of the objective funtion? #103

Closed PavelBal closed 3 months ago

PavelBal commented 4 months ago

Trying this:

piConfiguration <- PIConfiguration$new()
piConfiguration$objectiveFunctionOptions$objectiveFunctionType <- "lsq"

throws an error

Error in validateIsOption(inputOptions, ObjectiveFunctionOptions) : 
  logScaleSD must be a single numeric value.
3.
stop(paste(messages, collapse = "\n")) at utilities-helper.R#65
2.
validateIsOption(inputOptions, ObjectiveFunctionOptions) at PIConfiguration.R#67
1.
(function (inputOptions = list())
{
if (missing(inputOptions)) {
private$.objectiveFunctionOptions ...
PavelBal commented 4 months ago

Add a test for this use case.

rengelke commented 4 months ago

Implementing option validation for objectiveFunctionOptions revealed a limitation with active bindings: modifying individual fields does not invoke the setter function, making it problematic to run the validation logic. There is also no simple way to intercept changes to individual list elements in order to trigger validation. I think we have two options: (1) since direct modification seems to be common in ospsuite, we could remove this direct validation functionality and validate (throw meaningful error messages to users) later, e.g., within ParameterIdentification$run(). (2) keep the validation, but require that configurations are made through active binding using a named list of options.

PavelBal commented 4 months ago

Can objectiveFunctionOptions be another R6 class with pre-defined fields? You could then implement validations within this class.

PavelBal commented 4 months ago