pyfemtet.opt.optimizer.optuna_optimizer package
Module contents
- class pyfemtet.opt.optimizer.optuna_optimizer.OptunaOptimizer(sampler_class=None, sampler_kwargs=None)[source]
Bases:
AbstractOptimizerAn optimizer class utilizing Optuna for hyperparameter optimization.
This class provides an interface to conduct optimization studies using Optuna. It manages the study lifecycle, sampler configuration, and trial execution.
- current_trial
The current Optuna trial being evaluated.
- Type:
optuna.trial.Trial | None
- Parameters:
- Raises:
None –
Examples
>>> optimizer = OptunaOptimizer() >>> optimizer.n_trials = 100 >>> optimizer.timeout = 600 >>> # Further configuration and usage...
- add_categorical_parameter(name, initial_value, choices, properties=None, *, pass_to_fem=True, fix=False)[source]
- add_parameter(name, initial_value, lower_bound=None, upper_bound=None, step=None, properties=None, *, pass_to_fem=True, fix=False)[source]
- entire_status: WorkerStatus
- study_name = 'pyfemtet-study'
- trial_queue: TrialQueue
- worker_status: WorkerStatus
- worker_status_list: list[WorkerStatus]
- class pyfemtet.opt.optimizer.optuna_optimizer.PartialOptimizeACQFConfig(*, gen_candidates='scipy', timeout_sec=None, method=None, scipy_minimize_kwargs=None, constraint_enhancement=None, constraint_scaling=1000000.0)[source]
Bases:
object- Parameters:
- default_method = 'SLSQP'
- class pyfemtet.opt.optimizer.optuna_optimizer.PoFBoTorchSampler(*, candidates_func=None, constraints_func=None, n_startup_trials=10, consider_running_trials=False, independent_sampler=None, seed=None, device=None, observation_noise=None, partial_optimize_acqf_kwargs=None, pof_config=None)[source]
Bases:
BoTorchSamplerNote
Added in v2.4.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v2.4.0.
- Parameters:
candidates_func (CandidateFunc) –
constraints_func (Callable[[FrozenTrial], Sequence[float]] | None) –
n_startup_trials (int) –
consider_running_trials (bool) –
independent_sampler (BaseSampler | None) –
seed (int | None) –
device (torch.device | None) –
partial_optimize_acqf_kwargs (PartialOptimizeACQFConfig) –
pof_config (PoFConfig) –
- partial_optimize_acqf_kwargs: PartialOptimizeACQFConfig
- pyfemtet_optimizer: AbstractOptimizer
- sample_relative(study, trial, search_space)[source]
Sample parameters in a given search space.
This method is called once at the beginning of each trial, i.e., right before the evaluation of the objective function. This method is suitable for sampling algorithms that use relationship between parameters such as Gaussian Process and CMA-ES.
Note
The failed trials are ignored by any build-in samplers when they sample new parameters. Thus, failed trials are regarded as deleted in the samplers’ perspective.
- Parameters:
- Returns:
A dictionary containing the parameter names and the values.
- Return type:
- class pyfemtet.opt.optimizer.optuna_optimizer.PoFConfig(consider_pof: 'bool' = True, consider_explicit_hard_constraint: 'bool' = True, _states_to_consider_pof: 'list[PFTrialState]' = <factory>, feasibility_cdf_threshold: 'float | str' = 0.5, feasibility_noise: 'float | str | None' = None, remove_hard_constraints_from_gp: 'bool' = False)[source]
Bases:
object- Parameters: