コード例 #1
0
ファイル: _study.py プロジェクト: xnchu/optjournal
    def _set_trial_param(self, data: Dict[str, Any], worker_id: str) -> None:
        number = _id.get_trial_number(data["trial_id"])
        name = data["name"]

        self.trials[number].params[name] = data["value"]
        self.trials[number].distributions[
            name] = distributions.json_to_distribution(data["distribution"])
コード例 #2
0
ファイル: _study.py プロジェクト: xnchu/optjournal
    def _set_trial_state(self, data: Dict[str, Any], worker_id: str) -> None:
        number = _id.get_trial_number(data["trial_id"])
        trial = self.trials[number]

        state = TrialState(data["state"])
        if state == TrialState.RUNNING:
            if trial.owner != data["worker_id"]:
                if data["worker_id"] == worker_id:
                    raise RuntimeError(
                        "Trial {} cannot be modified from the owner.".format(
                            number))
                else:
                    return

            if self.trials[number].state != TrialState.WAITING:
                return

        if trial.state.is_finished():
            if data["worker_id"] == worker_id:
                raise RuntimeError(
                    "Trial {} has already been finished.".format(number))
            else:
                return

        trial.state = state
        if state.is_finished():
            trial.datetime_complete = datetime.fromtimestamp(
                data["datetime_complete"])
            trial.owner = None

        if state == TrialState.RUNNING:
            self.trials[number].owner = data["worker_id"]

        if state == TrialState.COMPLETE:
            if (self.best_trial is None
                    or (self.direction == optuna.study.StudyDirection.MINIMIZE
                        and trial.value < self.best_trial.value)
                    or (self.direction == optuna.study.StudyDirection.MAXIMIZE
                        and trial.value > self.best_trial.value)):
                self.best_trial = trial
コード例 #3
0
ファイル: _study.py プロジェクト: xnchu/optjournal
 def _set_trial_user_attr(self, data: Dict[str, Any],
                          worker_id: str) -> None:
     number = _id.get_trial_number(data["trial_id"])
     self.trials[number].user_attrs[data["key"]] = data["value"]
コード例 #4
0
ファイル: _study.py プロジェクト: xnchu/optjournal
 def _set_trial_intermediate_value(self, data: Dict[str, Any],
                                   worker_id: str) -> None:
     number = _id.get_trial_number(data["trial_id"])
     self.trials[number].intermediate_values[data["step"]] = data["value"]
コード例 #5
0
ファイル: _study.py プロジェクト: xnchu/optjournal
 def _set_trial_value(self, data: Dict[str, Any], worker_id: str) -> None:
     number = _id.get_trial_number(data["trial_id"])
     self.trials[number].value = data["value"]
コード例 #6
0
ファイル: _storage.py プロジェクト: xnchu/optjournal
 def get_trial(self, trial_id: int) -> "FrozenTrial":
     study_id = _id.get_study_id(trial_id)
     return self._studies[study_id].trials[_id.get_trial_number(trial_id)]
コード例 #7
0
ファイル: _storage.py プロジェクト: xnchu/optjournal
 def get_trial_number_from_id(self, trial_id: int) -> int:
     return _id.get_trial_number(trial_id)