optuna.multi_objective.study.MultiObjectiveStudy

class optuna.multi_objective.study.MultiObjectiveStudy(study)[source]

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.

Warning

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.

Parameters

study (Study) –

property directions: List[StudyDirection]

Return the optimization direction list.

Returns

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

enqueue_trial(params)[source]

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.

Parameters

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

Return type

None

get_pareto_front_trials()[source]

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.

Returns

A list of FrozenMultiObjectiveTrial objects.

Return type

List[FrozenMultiObjectiveTrial]

get_trials(deepcopy=True, states=None)[source]

Return all trials in the study.

The returned trials are ordered by trial number.

Parameters
  • 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[Container[TrialState]]) – Trial states to filter on. If None, include all states.

Returns

A list of FrozenMultiObjectiveTrial objects.

Return type

List[FrozenMultiObjectiveTrial]

property n_objectives: int

Return the number of objectives.

Returns

Number of objectives.

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

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.

Example

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)
Parameters
Return type

None

property sampler: BaseMultiObjectiveSampler

Return the sampler.

Returns

A BaseMultiObjectiveSampler object.

set_system_attr(key, value)[source]

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.

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

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

Return type

None

set_user_attr(key, value)[source]

Set a user attribute to the study.

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

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

Return type

None

property system_attrs: Dict[str, Any]

Return system attributes.

Returns

A dictionary containing all system attributes.

property trials: List[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).

Returns

A list of FrozenMultiObjectiveTrial objects.

property user_attrs: Dict[str, Any]

Return user attributes.

Returns

A dictionary containing all user attributes.