def __init__(self, dims, ranges, seed=None, dtype=np.float64): self._dims = np.array(dims) if len(self._dims) != len(ranges): raise ValueError(f"dims (length {len(self._dims)}) and ranges " f"(length {len(ranges)}) must be the same length") ArchiveBase.__init__( self, storage_dims=tuple(self._dims), behavior_dim=len(self._dims), seed=seed, dtype=dtype, ) ranges = list(zip(*ranges)) self._lower_bounds = np.array(ranges[0], dtype=self.dtype) self._upper_bounds = np.array(ranges[1], dtype=self.dtype) self._interval_size = self._upper_bounds - self._lower_bounds self._boundaries = [] for dim, lower_bound, upper_bound in zip(self._dims, self._lower_bounds, self._upper_bounds): self._boundaries.append( np.linspace(lower_bound, upper_bound, dim + 1))
def __init__(self, dims, ranges, seed=None, dtype=np.float64, remap_frequency=100, buffer_capacity=1000): self._dims = np.array(dims) if len(self._dims) != len(ranges): raise ValueError(f"dims (length {len(self._dims)}) and ranges " f"(length {len(ranges)}) must be the same length") ArchiveBase.__init__( self, storage_dims=tuple(self._dims), behavior_dim=len(self._dims), seed=seed, dtype=dtype, ) ranges = list(zip(*ranges)) self._lower_bounds = np.array(ranges[0], dtype=self.dtype) self._upper_bounds = np.array(ranges[1], dtype=self.dtype) self._interval_size = self._upper_bounds - self._lower_bounds # Specifics for sliding boundaries. self._remap_frequency = remap_frequency # Allocate an extra entry in each row so we can put the upper bound at # the end. self._boundaries = np.full( (self._behavior_dim, np.max(self._dims) + 1), np.nan, dtype=self.dtype) # Initialize the boundaries. for i, (dim, lower_bound, upper_bound) in enumerate( zip(self._dims, self._lower_bounds, self._upper_bounds)): self._boundaries[i, :dim + 1] = np.linspace( lower_bound, upper_bound, dim + 1) # Create buffer. self._buffer = SolutionBuffer(buffer_capacity, self._behavior_dim) # Total number of solutions encountered. self._total_num_sol = 0
the wrong shape. """ def __init__(self, bins, ranges, seed=None, dtype=np.float64, samples=100_000, custom_centroids=None, k_means_kwargs=None, use_kd_tree=False, ckdtree_kwargs=None): ArchiveBase.__init__( self, storage_dims=(bins, ), behavior_dim=len(ranges), seed=seed, dtype=dtype, ) ranges = list(zip(*ranges)) self._lower_bounds = np.array(ranges[0], dtype=self.dtype) self._upper_bounds = np.array(ranges[1], dtype=self.dtype) self._bins = bins # Apply default args for k-means. Users can easily override these, # particularly if they want higher quality clusters. self._k_means_kwargs = ({} if k_means_kwargs is None else k_means_kwargs.copy()) if "n_init" not in self._k_means_kwargs: