Esempio n. 1
0
 def allStates(self):
     if self.continuous_dims == []:
         # Recall that discrete dimensions are assumed to be integer
         return (
             perms(
                 self.discrete_statespace_limits[:,
                                                 1] - self.discrete_statespace_limits[:,
                                                                                      0] + 1) + self.discrete_statespace_limits[
                 :,
                 0]
         )
Esempio n. 2
0
 def allStates(self):
     if self.continuous_dims == []:
         # Recall that discrete dimensions are assumed to be integer
         return (
             perms(
                 self.discrete_statespace_limits[:,
                                                 1] - self.discrete_statespace_limits[:,
                                                                                      0] + 1) + self.discrete_statespace_limits[
                 :,
                 0]
         )
Esempio n. 3
0
 def uniformRBFs(self, bins_per_dimension, includeBorders=False):
     """
     :param bins_per_dimension: Determines the number of RBFs to place 
         uniformly in each dimension, see example below.
     :param includeBorders: (Boolean) If true, adds an extra RBF to include 
         the domain boundaries.
         
     Positions RBF Centers uniformly across the state space.\n
     Returns the centers as RBFs-by-dims matrix and number of rbfs. 
     Each row is a center of an RBF. \n
     Example: 2D domain where each dimension is in [0,3]
     with bins = [2,3], False => we get 1 center in the first dimension and 
     2 centers in the second dimension, hence the combination is:\n
     1.5    1 \n
     1.5    2 \n
     with parameter [2,3], True => we get 3 center in the first dimension 
     and 5 centers in the second dimension, hence the combination is: \n
     0      0 \n
     0      1 \n
     0      2 \n
     0      3 \n
     1.5    0 \n
     1.5    1 \n
     1.5    2 \n
     1.5    3 \n
     3      0 \n
     3      1 \n
     3      2 \n
     3      3 \n
     
     """
     domain = self.domain
     dims = domain.state_space_dims
     if includeBorders:
         rbfs_num = np.prod(bins_per_dimension[:] + 1)
     else:
         rbfs_num = np.prod(bins_per_dimension[:] - 1)
     all_centers = []
     for d in xrange(dims):
         centers = np.linspace(domain.statespace_limits[d, 0],
                               domain.statespace_limits[d, 1],
                               bins_per_dimension[d] + 1)
         if not includeBorders:
             centers = centers[1:-1]  # Exclude the beginning and ending
         all_centers.append(centers.tolist())
     # print all_centers
     # Find all pair combinations of them:
     result = perms(all_centers)
     # print result.shape
     return result, rbfs_num
Esempio n. 4
0
 def uniformRBFs(self, bins_per_dimension, includeBorders=False):
     """
     :param bins_per_dimension: Determines the number of RBFs to place 
         uniformly in each dimension, see example below.
     :param includeBorders: (Boolean) If true, adds an extra RBF to include 
         the domain boundaries.
         
     Positions RBF Centers uniformly across the state space.\n
     Returns the centers as RBFs-by-dims matrix and number of rbfs. 
     Each row is a center of an RBF. \n
     Example: 2D domain where each dimension is in [0,3]
     with bins = [2,3], False => we get 1 center in the first dimension and 
     2 centers in the second dimension, hence the combination is:\n
     1.5    1 \n
     1.5    2 \n
     with parameter [2,3], True => we get 3 center in the first dimension 
     and 5 centers in the second dimension, hence the combination is: \n
     0      0 \n
     0      1 \n
     0      2 \n
     0      3 \n
     1.5    0 \n
     1.5    1 \n
     1.5    2 \n
     1.5    3 \n
     3      0 \n
     3      1 \n
     3      2 \n
     3      3 \n
     
     """
     domain = self.domain
     dims = domain.state_space_dims
     if includeBorders:
         rbfs_num = np.prod(bins_per_dimension[:] + 1)
     else:
         rbfs_num = np.prod(bins_per_dimension[:] - 1)
     all_centers = []
     for d in xrange(dims):
         centers = np.linspace(domain.statespace_limits[d, 0],
                               domain.statespace_limits[d, 1],
                               bins_per_dimension[d] + 1)
         if not includeBorders:
             centers = centers[1:-1]  # Exclude the beginning and ending
         all_centers.append(centers.tolist())
     # print all_centers
     # Find all pair combinations of them:
     result = perms(all_centers)
     # print result.shape
     return result, rbfs_num