def nextIteration(self, preference = None): ''' Return next iteration bounds ''' points = np.array(self.problem.points) # Reduce point set if starting from DM specified sol if preference is not None: self.problem.points = points = reachable_points(self.problem.points, preference[1], preference[0]) self.zh_prev = list(preference[0]) self.fh_lo = list(preference[1]) self.fh_lo_prev = self.fh_lo self.nsPoint_prev = list(self.NsPoints[self.zhs.index(self.zh_prev)]) if len(points) <= self.Ns: print(("Only %s points can be reached from selected iteration point" % len(points))) self.NsPoints = self.problem.points else: # k-mean cluster Ns solutions k_means = KMeans(n_clusters = self.Ns) k_means.fit(points) closest, _ = pairwise_distances_argmin_min(k_means.cluster_centers_, points) self.NsPoints = list(map(list, points[closest])) for p in self.NsPoints: logging.debug(p) for point in self.NsPoints: self.zhs.append(self._update_zh(self.zh_prev, point)) # self.fh=point self.fh_lo = list(self.bounds_factory.result(self.zhs[-1])) self.zh_los.append(self.fh_lo) self.zh_reach.append(len(reachable_points(self.problem.points, self.zh_los[-1], self.zhs[-1]))) self.current_iter -= 1 return list(zip(self.zh_los, self.zhs))
def next_iteration(self, *args, preference=None, **kwargs): if preference and preference[0]: self.zh_prev = list(preference[0]) else: self.zh_prev = self.problem.nadir[:] if preference and preference[1]: self.fh_lo = list(preference[1]) else: self.fh_lo = self.problem.ideal[:] # TODO Create weights if not given, e.g., using # Steuer RE, Choo EU. An interactive weighted Tchebycheff procedure for # multiple objective programming. # Mathematical programming. 1983; 26(3):326-44. points = misc.new_points(self.fh_factory, self.zh) # Find centroids if len(points) <= self.Ns: print(( "Only %s points can be reached from selected iteration point" % len(points))) self.NsPoints = points else: # k-mean cluster Ns solutions k_means = KMeans(n_clusters=self.Ns) solution_points = [points[1] for point in points] k_means.fit(solution_points) closest = set( pairwise_distances_argmin_min(k_means.cluster_centers_, solution_points)[0]) self.NsPoints = [] for point_idx in closest: self.NsPoints.append(points[point_idx]) # Find iteration point for each centroid for _, point in self.NsPoints: self.zhs.append(self._update_zh(self.zh_prev, point)) self.fh_lo = list(self.lower_bounds_factory.result(self.zh_prev)) self.zh_los.append(self.fh_lo) if not self.problem.points: self.zh_reach = [] else: self.zh_reach.append( len( reachable_points(self.NsPoints, self.zh_los[-1], self.zhs[-1]))) self.current_iter -= 1 return list(zip(self.zh_los, self.zhs))
def next_iteration(self, ref_point, bounds=None): """ Calculate the next iteration point to be shown to the DM Parameters ---------- ref_point : list of float Reference point given by the DM """ if bounds: self.problem.points = reachable_points(self.problem.points, self.problem.ideal, bounds) if not utils.isin(self.fh, self.problem.points) or ref_point != self.ref_point: self.ref_point = list(ref_point) self._update_fh() self._update_zh(self.zh, self.fh) self.fh_lo = list(self.lower_bounds_factory.result(self.zh)) self.fh_up = list(self.upper_bounds_factory.result(self.zh)) logging.debug(f"Updated upper boundary: {self.fh_up}") logging.debug(f"Uppadet lower boundary: {self.fh_lo}") if not np.all(np.array(self.fh_up) > np.array(self.fh_lo)): warn(self.NegativeIntervalWarning()) assert utils.isin(self.fh_up, self.problem.points) assert utils.isin(self.fh_lo, self.problem.points) dist = self.distance(self.zh, self.fh) # Reachable points self.update_points() lP = len(self.problem.points) self.current_iter -= 1 return dist, self.fh, self.zh, self.fh_lo, self.fh_up, lP
def nextIteration(self, ref_point, bounds = None): ''' Calculate the next iteration point to be shown to the DM Attributes ---------- ref_point : list of float Reference point given by the DM ''' if bounds: self.problem.points = reachable_points(self.problem.points, self.problem.ideal, bounds) if not utils.isin(self.fh, self.problem.points) or ref_point != self.ref_point: self.ref_point = list(ref_point) self._update_fh() self._update_zh(self.zh, self.fh) self.fh_lo = list(self.bounds_factory.result(self.zh)) self.fh_up = list(self.bounds_factory.result(self.zh, max = True)) if np.all(np.array(self.fh_up) > np.array(self.fh_lo)): logging.debug("Upper boundary is smaller than lower boundary") assert utils.isin(self.fh_up, self.problem.points) assert utils.isin(self.fh_lo, self.problem.points) dist = self.distance(self.zh, self.fh) # Reachable points self.update_points() lP = len(self.problem.points) self.current_iter -= 1 return dist, self.fh, self.zh, self.fh_lo, self.fh_up, lP
def update_points(self): self.problem.points = reachable_points(self.problem.points, self.fh_lo, self.fh_up)