本文整理汇总了Python中Grid.Grid.updateGridAttraction方法的典型用法代码示例。如果您正苦于以下问题:Python Grid.updateGridAttraction方法的具体用法?Python Grid.updateGridAttraction怎么用?Python Grid.updateGridAttraction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid.Grid
的用法示例。
在下文中一共展示了Grid.updateGridAttraction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mapDataToGrid
# 需要导入模块: from Grid import Grid [as 别名]
# 或者: from Grid.Grid import updateGridAttraction [as 别名]
def mapDataToGrid(self, dataInfo):
datalength = len(dataInfo)
if datalength != self.DIMENSION:
return
grid_coords = list()
data_coords = list()
data = 0.0
grid_Width = 0.0
dim_index = 0
i = 0
while i < datalength:
data = float(dataInfo[i])
data_coords.append(data)
if data >= self.DIMENSION_UPPER_RANGE[i] or data < self.DIMENSION_LOWER_RANGE[i]:
return
grid_Width = float(self.DIMENSION_UPPER_RANGE[i] - self.DIMENSION_LOWER_RANGE[i]) / float(self.DIMENSION_PARTITION[i])
dim_index = int(math.floor((data - self.DIMENSION_LOWER_RANGE[i]) / grid_Width))
grid_coords.append(dim_index)
i += 1
gridCoords = Coordinates(grid_coords)
# check if the grid object is already created or not.
if not gridCoords in self.gridList:
g = Grid(False,0,self.time,1,ATTRIBUTE.SPARSE, self.DIMENSION, self.DIMENSION_UPPER_RANGE, self.DIMENSION_LOWER_RANGE, self.DIMENSION_PARTITION, self.TOTAL_GRIDS, self.decay_factor, self.dense_threshold, self.sparse_threshold, self.correlation_threshold)
attrL = g.getAttraction(data_coords, grid_coords)
g.setInitialAttraction(attrL)
self.gridList[gridCoords] = g
else:
g = self.gridList[gridCoords]
gridCoords = None
g.updateGridDensity(self.time)
g.updateGridAttribute()
attrL = g.getAttraction(data_coords, grid_coords)
g.updateGridAttraction(attrL, self.time)
g.setLastTimeUpdated(self.time)