-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49b1314
commit cb39e92
Showing
13 changed files
with
350 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/sbmlsim/examples/experiments/midazolam/fitting_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import Callable | ||
|
||
from sbmlsim.examples.experiments.midazolam import MIDAZOLAM_PATH | ||
from sbmlsim.examples.experiments.midazolam.fitting_problems import ( | ||
op_kupferschmidt1995, | ||
op_mandema1992, | ||
op_mid1oh_iv, | ||
) | ||
from sbmlsim.fit.optimization import OptimizationProblem | ||
from sbmlsim.fit.options import ( | ||
FittingStrategyType, | ||
OptimizationAlgorithmType, | ||
ResidualType, | ||
WeightingPointsType, | ||
) | ||
from sbmlsim.fit.result import OptimizationResult | ||
|
||
from sbmlsim.fit.runner import run_optimization | ||
from sbmlsim.fit.analysis import OptimizationAnalysis | ||
|
||
|
||
def fitting_example(op_factory: Callable, size: int = 10, n_cores: int = 10) -> None: | ||
"""Demonstrate fitting functionality.""" | ||
|
||
fit_kwargs = { | ||
"seed": 1234, | ||
"fitting_strategy": FittingStrategyType.ABSOLUTE_VALUES, | ||
"residual_type": ResidualType.ABSOLUTE_NORMED_RESIDUALS, | ||
"weighting_points": WeightingPointsType.ABSOLUTE_ONE_OVER_WEIGHTING, | ||
"absolute_tolerance": 1e-6, | ||
"relative_tolerance": 1e-6, | ||
} | ||
|
||
for alg_key, algorithm in [ | ||
("lsq", OptimizationAlgorithmType.LEAST_SQUARE), | ||
("de", OptimizationAlgorithmType.DIFFERENTIAL_EVOLUTION), | ||
]: | ||
|
||
op: OptimizationProblem = op_factory() | ||
fit_path = MIDAZOLAM_PATH / "results_fit" / op.opid / alg_key | ||
if not fit_path.exists(): | ||
fit_path.mkdir(parents=True) | ||
|
||
opt_result: OptimizationResult = run_optimization( | ||
problem=op, | ||
algorithm=algorithm, | ||
size=size, | ||
n_cores=n_cores, | ||
**fit_kwargs | ||
) | ||
|
||
# OptimizationAnalysis(opt_result=opt_result, op=op) | ||
|
||
|
||
if __name__ == "__main__": | ||
for op_factory in [op_mandema1992, op_kupferschmidt1995, op_mid1oh_iv]: | ||
fitting_example(op_factory=op_factory) |
113 changes: 0 additions & 113 deletions
113
src/sbmlsim/examples/experiments/midazolam/fitting_parallel.py
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
src/sbmlsim/examples/experiments/midazolam/fitting_serial.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.