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()
andload_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.
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
Return the optimization direction list.
Return the number of objectives.
Return the sampler.
Return system attributes.
Return all trials in the study.
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.
- 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 trialt1
ifall(v0 <= v1) for v0, v1 in zip(t0.values, t1.values)
andany(v0 < v1) for v0, v1 in zip(t0.values, t1.values)
are held.- Returns
A list of
FrozenMultiObjectiveTrial
objects.- Return type
- 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 toFalse
, 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
- 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
objective (Callable[[MultiObjectiveTrial], Sequence[float]]) –
n_jobs (int) –
callbacks (Optional[List[Callable[[MultiObjectiveStudy, FrozenMultiObjectiveTrial], None]]]) –
gc_after_trial (bool) –
show_progress_bar (bool) –
- 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.
- 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.