petab_select.model_subspace

Functions

decompress_parameter_values(values)

Decompress parameter values.

Classes

ModelSubspace(model_subspace_id, petab_yaml, ...)

Efficient representation of exponentially large model subspaces.

class petab_select.model_subspace.ModelSubspace(model_subspace_id, petab_yaml, parameters, exclusions=None)[source]

Efficient representation of exponentially large model subspaces.

model_subspace_id

The ID of the model subspace.

petab_yaml

The location of the PEtab problem YAML file.

parameters

The key is the ID of the parameter. The value is a list of values that the parameter can take (including ESTIMATE).

exclusions

Hashes of models that have been previously submitted to a candidate space for consideration (CandidateSpace.consider()).

__init__(model_subspace_id, petab_yaml, parameters, exclusions=None)[source]
property can_estimate: List[str]

Parameters that can be estimated, according to the subspace.

Parameters that are estimated as part of the PEtab problem are not considered.

property can_estimate_all: List[str]

All parameters than can be estimated in this subspace.

property can_fix: List[str]

Parameters that can be fixed, according to the subspace.

Parameters that are fixed as part of the PEtab problem are not considered.

check_compatibility_stepwise_method(candidate_space)[source]

Check whether a candidate space is compatible with this subspace.

Directional methods (e.g. forward, backward) are not supported among different PEtab problems.

Parameters:

candidate_space (CandidateSpace) – The candidate space with a stepwise method.

Return type:

bool

Returns:

Whether the candidate space is compatible.

exclude_model(model)[source]

Exclude a model from the model subspace.

Models are excluded in ModelSubspace.indices_to_model, which contains the only call to Model.__init__ in the ModelSubspace class.

Parameters:

model (Model) – The model that will be excluded.

Return type:

None

exclude_model_hash(model_hash)[source]

Exclude a model hash from the model subspace.

Parameters:

model_hash (str) – The model hash.

Return type:

None

exclude_model_hashes(model_hashes)[source]

Exclude model hashes from the model subspace.

Parameters:

model_hashes (Iterable[str]) – The model hashes.

Return type:

None

exclude_models(models)[source]

Exclude models from the model subspace.

Models are excluded in ModelSubspace.indices_to_model(), which contains the only call to Model.__init__() in the ModelSubspace class.

Parameters:

models (Iterable[Model]) – The models that will be excluded.

Return type:

None

excluded(model)[source]

Whether a model is excluded.

Return type:

bool

static from_definition(model_subspace_id, definition, parent_path=None)[source]

Create a ModelSubspace from a definition.

Parameters:
  • model_subspace_id (str) – The model subspace ID.

  • definition (Union[Dict[str, str], Series]) – A description of the model subspace. Keys are properties of the model subspace, including parameters that can take different values.

  • parent_path (Union[str, Path]) – Any paths in the definition will be set relative to this path.

Return type:

ModelSubspace

Returns:

The model subspace.

get_estimated(additional_parameters=None)[source]

Get the IDs of parameters that are estimated.

Parameters:

additional_parameters (Optional[Dict[str, Union[float, int, Literal['estimate']]]]) – A specific parameterization that will take priority when determining estimated parameters.

Return type:

List[str]

Returns:

The parameter IDs.

get_models(estimated_parameters)[source]

Get models in the subspace by estimated parameters.

All models that have the provided estimated_parameters are returned.

Parameters:

estimated_parameters (List[str]) –

The IDs of parameters that are estimated in the model. All other parameters will be fixed. Note that these parameters are in the subset of PEtab parameters that exist in the model subspace definition. Parameters in the PEtab problem but not the model subspace definition should not be included here.

FIXME(dilpath) TODO support the full set of PEtab parameters? Then would need to turn off estimation for parameters that are not provided in estimated_parameters – maybe unexpected for users.

Return type:

Iterator[Model]

Returns:

A list of models.

indices_to_model(indices)[source]

Get a model from the subspace, by indices of possible parameter values.

Model exclusions are handled here.

Parameters:

indices (List[int]) – The indices of the lists in the values of the ModelSubspace.parameters dictionary, ordered by the keys of this dictionary.

Return type:

Optional[Model]

Returns:

A model with the PEtab problem of this subspace and the parameterization that corresponds to the indices. None, if the model is excluded from the subspace.

indices_to_parameters(indices)[source]

Convert parameter indices to values.

Parameters:

indices (List[int]) – See ModelSubspace.indices_to_model().

Return type:

Dict[str, Union[float, int, Literal['estimate']]]

Returns:

The parameterization that corresponds to the indices.

property must_estimate: List[str]

Subspace parameters that must be estimated.

Does not include parameters that are estimated in the PEtab parameters table.

property must_estimate_all: List[str]

All parameters that must be estimated in this subspace.

property must_fix: List[str]

Subspace parameters that must be fixed.

Parameters that are fixed as part of the PEtab problem are not considered.

property must_fix_all: List[str]

All parameters that must be fixed in this subspace.

property parameters_all: Dict[str, float | int | Literal['estimate']]

Get all parameters, including those only in the PEtab problem.

Parameter values in the PEtab problem are overwritten by the model subspace values.

parameters_to_indices(parameters)[source]

Convert parameter values to indices.

Parameters:

parameters (Dict[str, Union[float, int, Literal['estimate']]]) – Keys are parameter IDs, values are parameter values.

Returns:

The indices of the subspace that correspond to the parameterization.

parameters_to_model(parameters)[source]

Convert parameter values to a model.

Parameters:

parameters (Dict[str, Union[float, int, Literal['estimate']]]) – Keys are parameter IDs, values are parameter values.

Return type:

Optional[Model]

Returns:

A model with the PEtab problem of this subspace and the parameterization. None, if the model is excluded from the subspace.

property petab_parameter_ids_estimated: List[str]

Get the IDs of all estimated parameters.

Returns:

The parameter IDs.

property petab_parameter_ids_fixed: List[str]

Get the IDs of all fixed parameters.

Returns:

The parameter IDs.

property petab_parameters_singular: Dict[str, float | int | Literal['estimate']]

TODO deprecate and remove?

search(candidate_space, limit=inf)[source]

Search for candidate models in this model subspace.

Nothing is returned, as the result is managed by the candidate_space.

Parameters:
  • candidate_space (CandidateSpace) – The candidate space.

  • limit (int) – Limit the number of models.

send_model_to_candidate_space(model, candidate_space, exclude=False)[source]

Send a model to a candidate space for consideration.

Parameters:
  • model (Model) – The model.

  • candidate_space (CandidateSpace) – The candidate space.

  • exclude (Optional[bool]) – Whether to add the model to the exclusions.

Return type:

bool

Returns:

Whether it is OK to send additional models to the candidate space. For example, if len(candidate_space.models) == candidate_space.limit, then no further models should be sent.