tracts.driver.run_model_multi_init#

run_model_multi_init(genetic_model, population, start_params_list, population_dict, likelihood_options=None, max_iter=None, exclude_tracts_below_cM=0, npts=50, two_steps_optimization=True, autosomes_in_step_2=True, steps=None, start_params_title=None, print_start_params_table=True, print_run_number=True)#

Runs the model multiple times with different initial parameters.

Parameters:
  • genetic_model (GeneticModel) – Bundles the demographic model (whose parameter_handler handles parameter transformations and fixed parameters, and whose model_func/outofbounds_fun methods compute migration matrices and violation scores) with the admixture and phase-type model configuration (ad_model_autosomes, ad_model_allosomes, rho_f, rho_m, TP, N_cores) used to compute the likelihood.

  • population (Population) – The population object containing individual data.

  • start_params_list (list[ndarray]) – A list of initial parameter arrays to start the optimization.

  • population_dict (dict) – A dictionary mapping population labels to their corresponding indices in the model.

  • likelihood_options (LikelihoodOptions | None) – Logging verbosity (verbose_log, verbose_screen) for this run. If None, defaults to LikelihoodOptions().

  • max_iter (int) – Maximum number of iterations for the optimization algorithm. Default is None, which means no limit.

  • exclude_tracts_below_cM (int) – Minimum tract length in centimorgans to exclude from analysis. Default is 0.

  • npts (int) – Number of bins for the tract length histogram. Default is 50.

  • two_steps_optimization (bool) – Whether to use a two-step optimization procedure for sex-biased models. Default is True.

  • autosomes_in_step_2 (bool) – If two_steps_optimization is True, whether both autosomal and allosomal data will be used in the second optimization step. If True, both types of data will be used. If False, only allosomal data will be used in the second step. Default is True.

  • steps (list[int | str] | None) – If two_steps_optimization is True, a list specifying which steps to run. Step 1 (non-sex-bias parameter optimization) can be denoted as 1 or ‘step1’, and step 2 (sex-bias parameter optimization) can be denoted as 2 or ‘step2’. The only allowed combinations are step 1 only, step 2 only, or both steps. Examples of valid values are [1], [‘step1’], [2], [‘step2’], [1, 2], or [‘step1’, ‘step2’]. Mixed types are allowed, but duplicate references to the same step such as [1, ‘step1’] are not. Default is None (both steps will be run).

  • start_params_title (str | None) – For internal use only. An optional title to display above the starting parameters table. If None, a default title will be generated based on the steps being run. Default is None.

  • print_start_params_table (bool) – For internal use only. Whether to print the starting parameters table. Default is True.

  • print_run_number (bool) – For internal use only. Whether to print the “Optimization run #N” line before each run. Default is True.

Returns:

A tuple containing three lists: (i) optimal parameters for each run, (ii) optimization likelihoods for each run, and (iii) optional full-data likelihoods (only populated when step 2 is run with allosomal data only).

Return type:

tuple[list[ndarray], list[float], list[float | None]]