Skip to content

fit.parameter_mapping

The binding of the parameters of a fit to the simulations they apply to.

A FitParameter writes its value to an entity of a model. A parameter which carries a selector writes it only for the fit mappings the selector passes, so one entity is estimated separately for parts of the data, e.g. an absorption rate once for the tablet arms and once for the solution arms of one fit.

ParameterMapping is that binding as an object: it resolves the selectors to the simulation groups of an initialized OptimizationProblem, refuses a binding which cannot be simulated, and answers which changes a group is run with. It is the same knowledge a PEtab problem keeps in its condition table, which is why sbmlsim.fit.petab_v2 reads it instead of deriving it again.

CoverageRow dataclass

CoverageRow(
    pid,
    target,
    n_covered,
    n_groups,
    uncovered_groups=list(),
)

What one parameter of a fit reaches.

Attributes:

Name Type Description
pid str

id of the estimated parameter.

target str

entity of the model it writes.

n_covered int

number of simulations it applies to.

n_groups int

number of simulations of the problem.

uncovered_groups list[str]

the simulations it does not apply to, by name. They keep the value the model has for the target.

ParameterMapping

ParameterMapping(
    parameters,
    mapping_indices,
    groups,
    mapping_keys,
    group_names=None,
)

Which parameter writes which entity in which simulation.

Resolve and validate the binding.

Parameters:

Name Type Description Default
parameters Sequence[FitParameter]

the parameters of the problem, in the order of the parameter vector.

required
mapping_indices dict[int, set[int]]

for the index of every versioned parameter the indices of the fit mappings its selector passed. A parameter which is not versioned is absent and applies everywhere.

required
groups Sequence[Sequence[int]]

the simulation groups, each a list of mapping indices, see OptimizationProblem.mapping_groups.

required
mapping_keys Sequence[str]

id of every fit mapping, for the messages.

required
group_names Sequence[str] | None

name of every simulation group, for the coverage. The index of the group is used when they are not given.

None

Raises:

Type Description
ValueError

if two parameters write one target in one simulation, if a selector splits a simulation, or if the versions of a target disagree on their unit.

indices_for

indices_for(group)

Get the parameter which writes every target of a simulation.

Parameters:

Name Type Description Default
group int

index of the simulation group.

required

Returns:

Type Description
dict[str, int]

The index into the parameter vector, by target. A target no

dict[str, int]

parameter writes is absent, so the model keeps its value.

changes_for

changes_for(group, quantities)

Get the changes a simulation is run with.

Parameters:

Name Type Description Default
group int

index of the simulation group.

required
quantities Sequence[Any]

the quantity of every parameter, in the order of the parameter vector. They are built once per evaluation of the residuals and referenced here.

required

Returns:

Name Type Description
dict[str, Any]

The quantity by entity of the model. A target which is not an

dict[str, Any]

entity of the model, see FitParameter.is_external, is not a

change dict[str, Any]

the derived changes of the problem read its value.

coverage

coverage()

Get what every parameter reaches, for the console and the report.

has_renamed_targets

has_renamed_targets(parameters)

Check whether any parameter writes an entity of another name.

This is not FitParameter.is_versioned, which asks whether a parameter carries a selector: a parameter can be versioned and still write its own id (several versions all named after the target with a selector each), or write a different id without a selector (a plain rename). What a fit's display, its report and the PEtab export need instead is this question, i.e. whether a target column is worth showing at all -- one parameter answers it with a one-element list, a whole parameter vector with all of them.

Parameters:

Name Type Description Default
parameters Sequence[FitParameter]

the parameters to check, e.g. an OptimizationProblem's or a single [parameter].

required

Returns:

Type Description
bool

True if some parameter's target_id differs from its pid.