tracts.driver_utils.get_alternate_implicit_population#

get_alternate_implicit_population(demographic_model, optimal_sex_bias_at_boundaries)#

Checks whether any of the boundary-violating sex-bias parameter names in optimal_sex_bias_at_boundaries is a derived remainder parameter (i.e. corresponds to demographic_model’s current implicit population, rather than a directly-optimized sex-bias parameter). If so, returns the name of a different source population from the same founder event, whose own sex-bias parameter is neither itself at a boundary nor already fixed by value, that could be used as the implicit population instead.

A candidate already fixed by value is excluded even though it is not “at a boundary” (fixed parameters are skipped by check_optimal_sex_bias_parameters_at_boundaries, so they never appear in optimal_sex_bias_at_boundaries): switching the implicit population to it would silently discard its fixed value (fixed parameters become non-optimizable once a population is implicit; see base_parametrized_demography.set_up_fixed_parameters) and, if it was fixed by a previous boundary re-optimization iteration, would simply undo that iteration’s fix rather than making progress, risking an infinite switch-back-and-forth cycle.

Parameters:
  • demographic_model (ParametrizedDemographySexBiased) – The demographic model whose founder events are inspected.

  • optimal_sex_bias_at_boundaries (list[str]) – Parameter names near their +-1 boundary, as returned by check_optimal_sex_bias_parameters_at_boundaries.

Returns:

The name of an alternate source population to use as the implicit population, or None if no boundary-violating parameter corresponds to the current implicit population, or if every other source population in that founder event is either at a boundary or already fixed by value.

Return type:

str | None