optuna.multi_objective.study.MultiObjectiveStudy

class optuna.multi_objective.study.MultiObjectiveStudy(study)[源代码]

A study corresponds to a multi-objective optimization task, i.e., a set of trials.

This object provides interfaces to run a new Trial, access trials’ history, set/get user-defined attributes of the study itself.

Note that the direct use of this constructor is not recommended. To create and load a study, please refer to the documentation of create_study() and load_study() respectively.

警告

Deprecated in v2.4.0. This feature will be removed in the future. The removal of this feature is currently scheduled for v4.0.0, but this schedule is subject to change. See https://github.com/optuna/optuna/releases/tag/v2.4.0.

Methods

enqueue_trial(params)

Enqueue a trial with given parameter values.

get_pareto_front_trials()

Return trials located at the pareto front in the study.

get_trials([deepcopy, states])

Return all trials in the study.

optimize(objective[, timeout, n_trials, ...])

Optimize an objective function.

set_system_attr(key, value)

Set a system attribute to the study.

set_user_attr(key, value)

Set a user attribute to the study.

Attributes

directions

Return the optimization direction list.

n_objectives

Return the number of objectives.

sampler

Return the sampler.

system_attrs

Return system attributes.

trials

Return all trials in the study.

user_attrs

Return user attributes.

参数

study (optuna.study.Study) –

property directions: List[optuna._study_direction.StudyDirection]

Return the optimization direction list.

返回

A list that contains the optimization direction for each objective value.

enqueue_trial(params)[源代码]

Enqueue a trial with given parameter values.

You can fix the next sampling parameters which will be evaluated in your objective function.

Please refer to the documentation of optuna.study.Study.enqueue_trial() for further details.

参数

params (Dict[str, Any]) – Parameter values to pass your objective function.

返回类型

None

get_pareto_front_trials()[源代码]

Return trials located at the pareto front in the study.

A trial is located at the pareto front if there are no trials that dominate the trial. It’s called that a trial t0 dominates another trial t1 if all(v0 <= v1) for v0, v1 in zip(t0.values, t1.values) and any(v0 < v1) for v0, v1 in zip(t0.values, t1.values) are held.

返回

A list of FrozenMultiObjectiveTrial objects.

返回类型

List[optuna.multi_objective.trial.FrozenMultiObjectiveTrial]

get_trials(deepcopy=True, states=None)[源代码]

Return all trials in the study.

The returned trials are ordered by trial number.

参数
  • deepcopy (bool) – Flag to control whether to apply copy.deepcopy() to the trials. Note that if you set the flag to False, you shouldn’t mutate any fields of the returned trial. Otherwise the internal state of the study may corrupt and unexpected behavior may happen.

  • states (Optional[Tuple[optuna.trial._state.TrialState, ...]]) – Trial states to filter on. If None, include all states.

返回

A list of FrozenMultiObjectiveTrial objects.

返回类型

List[optuna.multi_objective.trial.FrozenMultiObjectiveTrial]

property n_objectives: int

Return the number of objectives.

返回

Number of objectives.

optimize(objective, timeout=None, n_trials=None, n_jobs=1, catch=(), callbacks=None, gc_after_trial=True, show_progress_bar=False)[源代码]

Optimize an objective function.

This method is the same as optuna.study.Study.optimize() except for taking an objective function that returns multi-objective values as the argument.

Please refer to the documentation of optuna.study.Study.optimize() for further details.

示例

import optuna


def objective(trial):
    # Binh and Korn function.
    x = trial.suggest_float("x", 0, 5)
    y = trial.suggest_float("y", 0, 3)

    v0 = 4 * x ** 2 + 4 * y ** 2
    v1 = (x - 5) ** 2 + (y - 5) ** 2
    return v0, v1


study = optuna.multi_objective.create_study(["minimize", "minimize"])
study.optimize(objective, n_trials=3)
参数
返回类型

None

property sampler: optuna.multi_objective.samplers._base.BaseMultiObjectiveSampler

Return the sampler.

返回

A BaseMultiObjectiveSampler object.

set_system_attr(key, value)[源代码]

Set a system attribute to the study.

Note that Optuna internally uses this method to save system messages. Please use set_user_attr() to set users’ attributes.

参数
  • key (str) – A key string of the attribute.

  • value (Any) – A value of the attribute. The value should be JSON serializable.

返回类型

None

set_user_attr(key, value)[源代码]

Set a user attribute to the study.

参数
  • key (str) – A key string of the attribute.

  • value (Any) – A value of the attribute. The value should be JSON serializable.

返回类型

None

property system_attrs: Dict[str, Any]

Return system attributes.

返回

A dictionary containing all system attributes.

property trials: List[optuna.multi_objective.trial.FrozenMultiObjectiveTrial]

Return all trials in the study.

The returned trials are ordered by trial number.

This is a short form of self.get_trials(deepcopy=True, states=None).

返回

A list of FrozenMultiObjectiveTrial objects.

property user_attrs: Dict[str, Any]

Return user attributes.

返回

A dictionary containing all user attributes.