Optimizer.BasicOptimizer

Contents

Optimizer.BasicOptimizer#

BasicOptimizer.py

Copyright (c) 2021-2026, SAXS Team, KEK-PF

class BasicOptimizer(dsets, n_components, params_type, kwargs)#

Bases: object

accept_test(**kwargs)#
compute_LRF_matrices(x, y, xr_cy_list, xr_ty, uv_x, uv_y, uv_cy_list, uv_ty, debug=False)#
compute_comformance(xr_params, rg_params, seccol_params)#
compute_fv(lrf_info, xr_params, rg_params, seccol_params, penalties, p, debug=False)#
compute_moments_list(params=None, debug=False)#
compute_mw_integrity(P, C, preceder)#
compute_peak_deviation(xr_params, debug=False)#
create_lrf_info_for_debug(x, y, xr_ty, xr_cy_list, uv_x, uv_y, uv_ty, uv_cy_list)#
debug_plot_params(norm_params, **kwargs)#
freeze_components(frozen_components)#

Set component indices to freeze during optimization.

Parameters:

frozen_components (list of int) – 0-based indices of protein components to freeze. Their XR params, Rg, and UV scale will be held constant.

freeze_param_groups(groups)#

Freeze named parameter groups during optimization.

Works with all solvers (BH, NS, MCMC, …) because it operates through xr_params_indeces inside BasicOptimizer.solve().

Parameters:

groups (list of str) – Names of parameter groups to hold constant. See the comment above for valid group names.

get_function_code()#
get_guinier_deviation(P, Cxr, rg_params, debug=False)#
get_model_name()#
get_name()#
get_num_components()#
get_num_matrices()#
get_num_scores(penalties)#
get_param_bounds(params)#
get_parameter_names()#
get_paramslider_info()#
get_region_limit()#
get_required_params(params)#
get_score_names(major_only=False)#
get_strategy()#
get_xr_only()#
is_stochastic()#
minima_callback(x, f, accept)#
objective_func(p, plot=False, debug=False, fig_info=None, axis_info=None, return_full=False)#
objective_func_wrapper(norm_params, **kwargs)#
prepare_for_free_indices(init_params)#

Apply free_param_indices directly as xr_params_indeces.

Called last in prepare_for_optimization(); overrides any frozen_components / frozen_param_groups reduction already applied.

prepare_for_frozen_groups(init_params)#

Restrict optimized params by freezing named parameter groups.

Group names correspond to the elements returned by split_params_simple():

index 0 : xr_components index 1 : xr_baseline index 2 : rgs index 3 : mapping index 4 : uv_components index 5 : uv_baseline index 6 : mappable_range index 7+ : seccol_params (last element; may be None if no col params)

Works with all solvers (BH, NS, MCMC, …) because it operates through xr_params_indeces, just like prepare_for_frozen_optimization().

prepare_for_frozen_optimization(init_params)#

Restrict optimized params by freezing specified components.

For each frozen component k (0-based protein component index), the following parameter indices are held constant:

  • XR shape: 4*k .. 4*k+3 (H, mu, sigma, tau)

  • Rg: 4*n + k

  • UV scale: 5*n + 2 + k

where n = n_components (including baseline).

prepare_for_optimization(init_params, real_bounds=None, minimally=False)#
prepare_for_xr_only_optimization(init_params)#
reshape_xr_bounds(xr_bounds)#
set_composite(composite)#
set_free_param_indices(indices)#

Directly specify the free (optimized) parameter indices.

Overrides any frozen_components / frozen_param_groups reduction. Pass None to clear and restore the default (all params free).

Parameters:

indices (array-like of int or None) – Indices of the parameters to optimize. All others are held at their init_params values.

set_frozen_components(frozen_components)#

Deprecated alias for freeze_components().

set_params_scale(real_bounds, debug=False)#
set_xr_only(xr_only)#
solve(init_params, real_bounds=None, niter=100, seed=None, callback=True, method=None, debug=False, show_history=False, ns_narrow_bounds=True, ns_adaptive_nsteps=False, ns_nsteps=None)#
split_as_unified_params(p, **kwargs)#
split_bounds(bounds)#
split_params_simple(p)#
to_norm_params(real_params)#
to_real_params(norm_params)#
update_at_minima(x, f, accept)#
update_bounds(x, debug=False)#
update_bounds_hook(masked_init_params)#
update_guinier_region(params=None, debug=False)#
update_minima_props(params)#
update_primary_peak(debug=False)#
update_rg_params(lrf_info)#
uv_baseline(x, uv_baseparams, y_, cy_list)#
write_init_callback_txt(init_params)#
xr_baseline(x, xr_baseparams, y_, cy_list)#