tracts.driver.run_sex_bias_fixing_reoptimizations#

run_sex_bias_fixing_reoptimizations(driver_spec, model_param_names, optimal_params, optimal_likelihood, run_optimization_fixed_options)#

Repeats driver_spec.optim.n_reoptimizations times: fixing the sex-bias parameters at their most recently optimized values and re-running the optimization starting from the current optimal parameters (using a copy of driver_spec with repetitions=1 and starting parameters set to the current optimum, rebuilt at every repetition, see _get_driver_for_reoptimization; this also means, per core.py, that sex-bias parameters end up fixed only during step 1, remaining free to be optimized again in step 2, which starts from the sex-bias values of the previous repetition). Stops early if the likelihood no longer improves between repetitions. Since only one run per step is performed, each repetition runs with print_run_details=False (see run_optimization): step headers and the optimizer’s own iteration table are still shown, but the starting-parameters table, “Optimization run #N” line, and step-transition messages are suppressed.

Parameters:
  • driver_spec (InferenceConfig) – The current driver-file configuration; controls the number of repetitions (driver_spec.optim.n_reoptimizations).

  • model_param_names (list[str]) – Names of all of the current demographic model’s free base parameters, in order.

  • optimal_params (ndarray) – The current optimal parameters (physical units), before these re-optimizations.

  • optimal_likelihood (float) – The current optimal likelihood, before these re-optimizations.

  • run_optimization_fixed_options (Callable) – A partially-applied run_optimization (with genetic_model, population, likelihood_options, model_param_names, and sex_bias_param_names already bound), taking physical_start_params and driver_spec as its remaining arguments.

Returns:

The updated optimal parameters and likelihood after the re-optimization repetitions.

Return type:

tuple[ndarray, float]