Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Nov 8, 2024
1 parent 15cb30d commit 63def3e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions python/parpe/hdf5_pe_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,18 @@ def _generate_simulation_to_optimization_parameter_mapping(self) -> None:

logger.debug(cond_par_map)

def _get_par(mapped_parameter: str, mapping, default=None):
"""Resolve parameter mapping."""
mapped_parameter = mapping.get(mapped_parameter, default)
while ((maps_to := mapping.get(mapped_parameter, mapped_parameter)) != mapped_parameter
and isinstance(maps_to, str)):
mapped_parameter = maps_to
return mapped_parameter

# update mapping matrix
for model_parameter_idx, model_parameter_id \
in enumerate(variable_par_ids):
mapped_parameter = cond_par_map.map_sim_var[model_parameter_id]
while ((maps_to := cond_par_map.map_sim_var.get(mapped_parameter, mapped_parameter)) != mapped_parameter
and isinstance(maps_to, str)):
mapped_parameter = maps_to
mapped_parameter = _get_par(model_parameter_id, cond_par_map.map_sim_var)
try:
(mapped_idx, override) = self.get_index_mapping_for_par(
mapped_parameter, optimization_parameter_name_to_index)
Expand All @@ -383,8 +388,10 @@ def _generate_simulation_to_optimization_parameter_mapping(self) -> None:
for amici_id in variable_par_ids)

fixed_parameter_matrix[:, self.condition_map[condition_idx, 1]] = \
np.array([cond_par_map.map_sim_fix[par_id]
for par_id in fixed_par_ids])
np.array([
_get_par(par_id, cond_par_map.map_sim_fix)
for par_id in fixed_par_ids
])

if cond_par_map.map_preeq_fix:
fixed_parameter_matrix[:,
Expand All @@ -394,7 +401,7 @@ def _generate_simulation_to_optimization_parameter_mapping(self) -> None:
# in this case. only NaN is problematic, because it will
# propagate through multiplication with the indicator
# variable.
np.array([cond_par_map.map_preeq_fix.get(par_id, 0.0)
np.array([_get_par(par_id, cond_par_map.map_preeq_fix, 0.0)
for par_id in fixed_par_ids])
)

Expand Down

0 comments on commit 63def3e

Please sign in to comment.