jijzepttools.blackbox_optimization.bbo_ommx#
Attributes#
Classes#
Generic enumeration. |
|
Blackbox optimization using surrogate models. |
Module Contents#
- logger#
- class BBOMethod#
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- FMO = 'FMO'#
- BOCS = 'BOCS'#
- BayesianFMO = 'BayesianFMO'#
- TPE = 'TPE'#
- class BlackboxOptimization(bb_model: jijzepttools.blackbox_optimization.problem.BlackboxProblem)#
Blackbox optimization using surrogate models.
This class provides a unified interface for optimizing blackbox functions using different surrogate modeling approaches such as Factorization Machine and BOCS.
The typical workflow is: 1. Initialize with a BlackboxProblem 2. Setup with initial data and objectives 3. Run optimization with specified method and parameters
- bb_model#
- X: numpy.ndarray | None = None#
- y: numpy.ndarray | None = None#
- experiment_details: minto.Experiment | None = None#
- setup(dataset: pandas.DataFrame | tuple[list[dict], list[dict]], objectives: list[str], instance_data: dict | None = None, record_experiment_details: bool = False, record_instance_in_experiment_details: bool = False, record_solution_in_experiment_details: bool = False, experiment_name: str = 'blackbox_optimization')#
Setup the optimization with initial data and objectives. Creates a minto.Experiment and logs initial data.
- Parameters:
dataset (pd.DataFrame or tuple[list[dict], list[dict]]) – Initial dataset containing decision variables and objective values. Can be either a DataFrame or tuple of (input_dicts, output_dicts).
objectives (list[str]) – Names of objective functions to optimize.
instance_data (dict, optional) – Additional data for creating the problem instance.
record_experiment_details (bool, default=False) – Whether to record the experiment details. If True, the experiment details will be recorded and you can see this by using get_experiment_details() method.
record_instance_in_experiment_details (bool, default=False) – Whether to record the instance in the experiment details. If True, the instance will be recorded in the experiment details. Instance Recording can be so heavy.
record_solution_in_experiment_details (bool, default=False) – Whether to record the solution in the experiment details. If True, the solution will be recorded in the experiment details. Solution Recording can be so heavy.
experiment_name (str, default="blackbox_optimization") – Name for the minto experiment.
- run(n_iter: int, time_limit_sec: float | None = None, blackbox_func: Callable[[dict], dict[str, float]] | None = None, solver: Callable | None = None, methods: List[BBOMethod] | None = None, surrogate_params: jijzepttools.blackbox_optimization.surrogate_model.SurrogateModelParams | None = None, enable_binary_conversion: bool = False, resolution_continuous_to_integer: int | None = None, max_surrogate_model_data_size: int | None = None, neighbor_sampler_params: jijzepttools.blackbox_optimization.neighbor_sampler.NeighborSamplerParams | None = None) minto.Experiment#
Run blackbox optimization iterations using the existing experiment.
# TODO: FMOやBOCSのサロゲートベースの方法だけでなく、Optunaにも対応できるようにする。 # TODO: 複数メソッドを使ってブラックボックス最適化できるようにする。またそれをデフォルトにする。 # TODO: 連続変数の問題に対して、FMのfit前にバイナリ変数への変換を行う機能を実装する。 # TODO: enable_binary_conversionが現在FMOのみ対応だが、他の必要なメソッドにも対応できるようにする。 # TODO: 多目的最適化への対応を行う。
- Parameters:
n_iter (int) – Number of optimization iterations.
time_limit_sec (float, optional) – Time limit for the optimization run in seconds. If None, no time limit is applied. Note: The loop checks the time limit after each iteration. Note that the total runtime may exceed time_limit_sec.
methods (list of BBOMethod, optional) – List of surrogate model methods. Currently only supports a list with one method. #TODO: 複数メソッドに対応させる Defaults to [BBOMethod.FMO].
blackbox_func (callable, optional) – Function to evaluate new candidates. Required if n_iter > 1.
solver (callable, optional) – OMMX solver function. Defaults to ommx_pyscipopt_adapter.OMMXPySCIPOptAdapter.solve.
surrogate_params (SurrogateModelParams, optional) – Parameters for the surrogate model. Uses defaults if None.
enable_binary_conversion (bool, default=False) – Whether to use binary variable conversion (now, support only BBOMethod.FMO).
resolution_continuous_to_integer (int, optional) – Resolution for continuous to integer conversion (required if enable_binary_conversion=True).
max_surrogate_model_data_size (int, optional) – Maximum number of samples to keep in the training dataset (X and y). When the dataset size exceeds this limit after adding new observations, the dataset is pruned to keep only the top max_size elite solutions based on the primary objective function value (assumes minimization). If None (default), no pruning is performed and all data is retained. Note: Currently only supported for single-objective optimization. For multi-objective problems, use None or raise NotImplementedError.
neighbor_sampler_params (NeighborSamplerParams, optional) – Parameters for neighbor sampling. If provided, a NeighborSampler will be automatically created (if not already created) and neighbor sampling will be performed at intervals specified by params.interval. All generated neighbors are evaluated with blackbox_func and added to the dataset (subject to pruning by max_surrogate_model_data_size).
- Returns:
The experiment object containing all optimization history.
- Return type:
minto.Experiment
- Raises:
ValueError – If setup() hasn’t been called or invalid parameters are provided.
- get_experiment_details() minto.Experiment#