Skip to content

Commit

Permalink
🩹 Fixed integration benchmark
Browse files Browse the repository at this point in the history
The unitest benchmarks are still partially broken since we decided that they are not very informative since they mostly reflect setup time
  • Loading branch information
s-weigand committed Nov 4, 2022
1 parent a23d15e commit c5996bf
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 11 deletions.
11 changes: 9 additions & 2 deletions benchmark/benchmarks/integration/ex_two_datasets/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path

from glotaran import __version__

try:
# 0.4.0 -0.5.1
from glotaran.analysis.optimize import optimize
Expand Down Expand Up @@ -28,15 +30,20 @@ class IntegrationTwoDatasets:
def setup(self):
dataset1 = load_dataset(SCRIPT_DIR / "data/data1.ascii")
dataset2 = load_dataset(SCRIPT_DIR / "data/data2.ascii")
model = load_model(str(SCRIPT_DIR / "models/model.yml"))
parameters = load_parameters(str(SCRIPT_DIR / "models/parameters.yml"))
addition_kwargs = {}
if int(__version__.split(".")[1]) < 7:
model = load_model(str(SCRIPT_DIR / "models/model_lt_0.7.0.yml"))
addition_kwargs["non_negative_least_squares"] = True
else:
model = load_model(str(SCRIPT_DIR / "models/model.yml"))
self.scheme = Scheme(
model,
parameters,
{"dataset1": dataset1, "dataset2": dataset2},
maximum_number_function_evaluations=11,
non_negative_least_squares=True,
optimization_method="TrustRegionReflection",
**addition_kwargs,
)

def time_optimize(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: kinetic-spectrum
default_megacomplex: decay

dataset:
dataset1:
Expand Down Expand Up @@ -33,16 +33,16 @@ initial_concentration:

irf:
irf1:
type: spectral-multi-gaussian
center: [irf.center]
width: [irf.width]
type: gaussian
center: irf.center
width: irf.width
irf1_no_dispersion:
type: spectral-multi-gaussian
center: [irf.center]
width: [irf.width]
type: gaussian
center: irf.center
width: irf.width

# It works without equal_area_penalties but then the inputs cannot be estimated
equal_area_penalties:
clp_penalties:
- type: equal_area
source: s1
source_intervals: [[300, 3000]]
Expand All @@ -57,7 +57,6 @@ equal_area_penalties:
target_intervals: [[300, 3000]]
parameter: area.1
weight: 0.1

# Example of weight application:
# weights:
# - datasets: [dataset1, dataset2]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
type: kinetic-spectrum

dataset:
dataset1:
megacomplex: [complex1]
initial_concentration: input1
irf: irf1
scale: scale.1
dataset2:
megacomplex: [complex1]
initial_concentration: input2
irf: irf1
scale: scale.2

megacomplex:
complex1:
k_matrix: [km1]

k_matrix:
km1:
matrix:
(s1, s1): "rates.k1"
(s2, s2): "rates.k2"
(s3, s3): "rates.k3"

initial_concentration:
input1:
compartments: [s1, s2, s3]
parameters: [inputs.1, inputs.2, inputs.3]
input2:
compartments: [s1, s2, s3]
parameters: [inputs.1, inputs.7, inputs.8]

irf:
irf1:
type: spectral-multi-gaussian
center: [irf.center]
width: [irf.width]
irf1_no_dispersion:
type: spectral-multi-gaussian
center: [irf.center]
width: [irf.width]

# It works without equal_area_penalties but then the inputs cannot be estimated
equal_area_penalties:
- type: equal_area
source: s1
source_intervals: [[300, 3000]]
target: s2
target_intervals: [[300, 3000]]
parameter: area.1
weight: 0.1
- type: equal_area
source: s1
source_intervals: [[300, 3000]]
target: s3
target_intervals: [[300, 3000]]
parameter: area.1
weight: 0.1
# Example of weight application:
# weights:
# - datasets: [dataset1, dataset2]
# global_interval: [100, 102]
# model_interval: [301, 502]
# value: 0.95

0 comments on commit c5996bf

Please sign in to comment.