예제 #1
0
파일: wfg.py 프로젝트: upura/optuna
    def _compute_rec(self, solution_set: np.ndarray) -> float:
        assert self._reference_point is not None
        n_points = solution_set.shape[0]

        if self._reference_point.shape[0] == 2:
            return _compute_2d(solution_set, self._reference_point)

        if n_points == 1:
            return _compute_2points_volume(solution_set[0],
                                           self._reference_point)
        elif n_points == 2:
            volume = 0.0
            volume += _compute_2points_volume(solution_set[0],
                                              self._reference_point)
            volume += _compute_2points_volume(solution_set[1],
                                              self._reference_point)
            intersection = self._reference_point - np.maximum(
                solution_set[0], solution_set[1])
            volume -= np.prod(intersection)

            return volume

        solution_set = solution_set[solution_set[:, 0].argsort()]

        # n_points >= 3
        volume = 0.0
        for i in range(n_points):
            volume += self._compute_exclusive_hv(solution_set[i],
                                                 solution_set[i + 1:])
        return volume
예제 #2
0
 def _compute_exclusive_hv(self, point: np.ndarray, solution_set: np.ndarray) -> float:
     assert self._reference_point is not None
     volume = _compute_2points_volume(point, self._reference_point)
     limited_solution_set = self._limit(point, solution_set)
     n_points_of_s = limited_solution_set.shape[0]
     if n_points_of_s == 1:
         volume -= _compute_2points_volume(limited_solution_set[0], self._reference_point)
     elif n_points_of_s > 1:
         volume -= self._compute_rec(limited_solution_set)
     return volume