petab_v2.benchmark
The problems of the PEtab benchmark collection.
The benchmark collection
is a set of published parameter estimation problems, each in
problems/<name>/v1 in PEtab v1 with the simulations of its measurements at
the nominal parameters, simulations.tsv, and some also in
problems/<name>/v2 in PEtab v2. sbmlsim reads PEtab v2 only: a problem is
its encoding in PEtab v2 where the collection has one, otherwise it is
converted from PEtab v1 with petab.v2.petab1to2; its simulations are
converted with it, see sbmlsim.fit.petab_v2.conversion. The problem is read
with PetabReader, simulated at the nominal values of its parameter table
and compared with the simulations of the collection; where AMICI states the
log-likelihood of the problem (tests/benchmark_models/benchmark_models.yaml
of AMICI), it is compared too. The problems of EXCLUDED_PROBLEMS take too
long and are left out.
| status | meaning |
|---|---|
pass |
the simulations and the log-likelihood agree |
tolerance |
a simulation or the log-likelihood is outside of its tolerance |
conversion |
petab1to2 cannot convert the problem |
error |
the problem cannot be read or simulated |
The collection has no releases, so it is pinned by a commit, the references
of AMICI by another. BenchmarkCollection is a commit of the collection with
the download, the conversion and the cache.
BenchmarkStatus
¶
Bases: StrEnum
The outcome of a problem.
BenchmarkResult
dataclass
¶
BenchmarkResult(
name,
status,
message="",
max_difference=None,
n_simulations=0,
llh=None,
llh_reference=None,
timings=dict(),
)
The outcome of a problem.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
the name of the problem. |
status |
BenchmarkStatus
|
the outcome. |
message |
str
|
what failed, or a note on what was not compared. |
max_difference |
float | None
|
the largest absolute difference of a simulation to
the collection, |
n_simulations |
int
|
the number of simulations which were compared. |
llh |
float | None
|
the log-likelihood at the nominal values, |
llh_reference |
float | None
|
the log-likelihood of AMICI it was compared with. |
timings |
dict[str, float]
|
the seconds it took to |
ProblemTimeout
¶
Bases: Exception
A problem took longer than the time it was given.
BenchmarkProblem
dataclass
¶
A problem of the benchmark collection.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
the name of the problem. |
source_dir |
Path
|
the directory of the problem in the collection, with its
encodings |
v2_dir |
Path
|
the directory of the problem in PEtab v2 which is run: the
encoding of the collection in PEtab v2 or the one converted from
PEtab v1, with the simulations of the collection converted to
PEtab v2, |
run
¶
Read, simulate and compare the problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llh_reference
|
float | None
|
the log-likelihood of AMICI, which is compared. |
None
|
settings
|
FitSettings | None
|
the settings the problem is simulated with, by default
the ones of |
None
|
timeout
|
float | None
|
the seconds the problem may take, a problem which takes
longer is an error. The time is measured with the timer
|
None
|
Returns:
| Type | Description |
|---|---|
BenchmarkResult
|
The outcome. |
BenchmarkCollection
dataclass
¶
A commit of the benchmark collection, converted to PEtab v2.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
the directory with the problems of the collection in
|
commit |
str
|
the commit of the collection. |
cache_path
staticmethod
¶
Get the directory a commit of the collection is unpacked into.
SBMLSIM_BENCHMARK_PATH overrides it. Otherwise it is
sbmlsim/petab-benchmark/<commit> in the user cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
str
|
the commit of the collection. |
BENCHMARK_COMMIT
|
Returns:
| Type | Description |
|---|---|
Path
|
The directory of the collection. |
cached
classmethod
¶
Get a commit of the collection if it is already on this machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
str
|
the commit of the collection. |
BENCHMARK_COMMIT
|
Returns:
| Type | Description |
|---|---|
BenchmarkCollection | None
|
The collection, or |
load
classmethod
¶
Get a commit of the collection, downloading and converting it.
The problems are downloaded once, converted once and the references of AMICI are fetched once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit
|
str
|
the commit of the collection. |
BENCHMARK_COMMIT
|
Returns:
| Type | Description |
|---|---|
BenchmarkCollection
|
The collection in the cache. |
Raises:
| Type | Description |
|---|---|
OSError
|
if the commit or the references cannot be downloaded. |
problem_names
¶
Get the names of the problems, sorted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
excluded
|
bool
|
whether the problems of |
False
|
convert
¶
Write the problems in PEtab v2 which are not written yet.
A problem is its encoding in PEtab v2 of the collection or, without
one, its encoding in PEtab v1 converted with petab1to2; the
simulations of the collection are converted from PEtab v1 in both
cases, see sbmlsim.fit.petab_v2.conversion. A problem which cannot
be converted gets the file v2/<name>.error with the reason, see
BenchmarkProblem.conversion_error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Sequence[str] | None
|
the problems, all of them by default. |
None
|
run
¶
Run the problems of the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Sequence[str] | None
|
the problems, all of them by default. |
None
|
progress
|
Callable[[BenchmarkResult], None] | None
|
called with the result of every problem. |
None
|
Returns:
| Type | Description |
|---|---|
list[BenchmarkResult]
|
The results in the order of the names. |