Skip to content

Commit

Permalink
not clean, but support automatic calibration of uncalibrated predeces…
Browse files Browse the repository at this point in the history
…sor models
  • Loading branch information
dilpath committed Dec 16, 2023
1 parent 87f0243 commit c883635
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion petab_select/ui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
from pathlib import Path
from typing import Dict, List, Optional, Union

Expand Down Expand Up @@ -76,10 +77,29 @@ def candidates(
candidate_space.exclude_hashes(calibrated_models)

# Set the predecessor model to the previous predecessor model.
predecessor_model = candidate_space.previous_predecessor_model

# If the predecessor model has not yet been calibrated, then calibrate it.
if (
predecessor_model.get_criterion(
criterion,
raise_on_failure=False,
)
is None
):
candidate_space.models = [copy.deepcopy(predecessor_model)]
# Dummy zero likelihood, which the predecessor model will
# improve on after it's actually calibrated.
predecessor_model.set_criterion(Criterion.LH, 0.0)
return candidate_space

# Exclude the calibrated predecessor model.
if not candidate_space.excluded(predecessor_model):
candidate_space.exclude(predecessor_model)

# Set the new predecessor_model from the initial model or
# by calling ui.best to find the best model to jump to if
# this is not the first step of the search.
predecessor_model = candidate_space.previous_predecessor_model
if newly_calibrated_models:
predecessor_model = problem.get_best(
newly_calibrated_models.values(),
Expand Down

0 comments on commit c883635

Please sign in to comment.