paradance.optimization.BaseObjective
- class paradance.optimization.BaseObjective(calculator: Calculator | LogarithmPCACalculator, direction: str | None = None, formula: str | None = None, warmup_formula: str | None = None, warmup_trials: int = 200, first_order: bool | None = False, power: bool | None = True, dirichlet: bool | None = False, weights_num: int | None = None, study_name: str | None = None, study_path: str | None = None, save_study: bool | None = True, checkpoint_path: str | None = None, config: Dict | None = None)[source]
BaseObjective serves as an abstract base class for objective optimization. It provides core functionalities for setting up and optimizing objectives using the optuna library.
- calculator
An instance of Calculator for various evaluations.
- Type:
- study
Optuna study object for optimization.
- Type:
Study
- logger
Logger object for logging optimization progress.
- Type:
- objective(trial) float[source]
Abstract method for objective function to be overridden in derived classes.
- __init__(calculator: Calculator | LogarithmPCACalculator, direction: str | None = None, formula: str | None = None, warmup_formula: str | None = None, warmup_trials: int = 200, first_order: bool | None = False, power: bool | None = True, dirichlet: bool | None = False, weights_num: int | None = None, study_name: str | None = None, study_path: str | None = None, save_study: bool | None = True, checkpoint_path: str | None = None, config: Dict | None = None) None[source]
Initializes the BaseObjective class with necessary parameters.
- Parameters:
calculator (Calculator) – Calculator for evaluations.
direction (str) – Direction of optimization.
weights_num (int) – Number of weights.
formula (str) – Formula for objective.
first_order (bool, optional) – Use first order optimization or not. Defaults to False.
power (bool, optional) – Include power in optimization. Defaults to True.
dirichlet (bool, optional) – Use Dirichlet distribution. Defaults to False.
study_name (Optional[str], optional) – Name of the study. Defaults to None.
study_path (Optional[str], optional) – Path to the study directory. Defaults to None.
Methods
__init__(calculator[, direction, formula, ...])Initializes the BaseObjective class with necessary parameters.
build_logger([process_id])Constructs a logger for the optimization process.
evaluate_custom_weights(weights)Evaluates the custom weights for the given list of weights.
Returns the number of weights.
objective(trial)Abstract method for the objective function.
optimize(n_trials)Optimizes the objective for a set number of trials.
- build_logger(process_id: int | None = None) None[source]
Constructs a logger for the optimization process.
- Parameters:
process_id (Optional[int], optional) – ID of the process, used for creating unique log filenames. Defaults to None.
- abstract evaluate_custom_weights(weights: List[float]) List[float][source]
Evaluates the custom weights for the given list of weights.
- abstract objective(trial: Trial) float[source]
Abstract method for the objective function. Must be overridden in derived classes.
- Parameters:
trial (Trial) – Optuna trial instance.
- Returns:
Objective value for the given trial.
- Return type: