def generateRandomPrimitivePath(self, map, agent): ''' Returns an array of primitives corresponding to a path for the given agent Args: map (Map): Map to generate path on pathTIme (float): How long should travelling on the path take? agent (Agent): Agent to generate path for ''' primitivePath = [] speed = agent.currentSpeed timeLeft = self._pathTime point = map.mapToWorld(agent.position[0], agent.position[1]) count = 0 while timeLeft > 0: count += 1 if (count % 5000 == 0): return (PathPrimitive(primitivePath), False) nextPoint = map.getRandomPoint() dist = ((point[0] - nextPoint[0])**2 + (point[1] - nextPoint[1])**2)**0.5 heading = math.atan2(-(nextPoint[1] - point[1]), nextPoint[0] - point[0]) time = min(dist / speed, timeLeft) primitive = PrimitiveLine(time, speed, point, heading) timeLeft -= time point = primitive.getEndPoint() minSpeed = max(speed - agent.acceleration * time, agent.minSpeed) maxSpeed = min(speed + agent.acceleration * time, agent.maxSpeed) speed = rand.uniform(minSpeed, maxSpeed) primitivePath = np.append(primitivePath, [primitive]) return (PathPrimitive(primitivePath), True)
def generateRandomPrimitivePath(self, map, agent): ''' Returns an array of primitives corresponding to a path for the given agent Args: map (Map): Map to generate path on agent (Agent): Agent to generate path for ''' inBounds = True primitivePath = [] timeLeft = self._pathTime heading = agent.rotation speed = agent.currentSpeed point = map.mapToWorld(agent.position[0], agent.position[1]) firstPrimitive = True directions = [0, math.pi / 2, -math.pi / 2, math.pi] while timeLeft > 0: primitiveAttempts = self._primitiveTries inBounds = False primitive = None time = 0 while inBounds == False and primitiveAttempts > 0: (pathTimeMin, pathTimeMax) = self._pathLengthRange time = min(rand.uniform(pathTimeMin, pathTimeMax), timeLeft) '''if (rand.random() < self._straightChance): primitive = PrimitiveLine(time, speed, point, heading) else: (radiusMin, radiusMax) = self._radiusRange radius = rand.uniform(max(radiusMin, agent.minRadius), radiusMax) dir = 1 + ((rand.random() < 0.5) * -2) primitive = PrimitiveCurve(time, speed, point, heading, radius, dir)''' heading = rand.choice(directions) primitive = PrimitiveLine(time, speed, point, heading) inBounds = primitive.isInMapBounds(map) or ( firstPrimitive and not map.isWorldPointOutOfBounds(primitive.getEndPoint())) primitiveAttempts -= 1 if inBounds == False: break else: timeLeft -= time heading = primitive.getEndHeading() point = primitive.getEndPoint() minSpeed = max(speed - agent.acceleration * time, agent.minSpeed) maxSpeed = min(speed + agent.acceleration * time, agent.maxSpeed) speed = rand.uniform(minSpeed, maxSpeed) primitivePath = np.append(primitivePath, [primitive]) firstPrimitive = False return (PathPrimitive(primitivePath), inBounds)
def generatePrimitivePaths(self, map, splitMapAgents, tries): ''' Returns an array of primitive paths (an array of primitives) that take pathTime time for each agent. path at index i corresponds to agent i in agents array. Args: map (Map): Map to generate path on pathTime (float): time path traversal should take agents (Agent array): the agents to generate path for tries (int): how many tries should we do for the path (we pick best one using ergodicity calculation) ''' '''bestSplitMapPaths = [[],[],[]] for splitMapIndex in range(len(splitMapAgents)): minErg = -1 agentList = splitMapAgents[splitMapIndex] for trial in range(tries * len(agentList)): #print(minErg) paths = [] for i in range(len(agentList)): currentAgent = agentList[i] generator = self._generators[currentAgent.generatorIndex] inBounds = False path = PathPrimitive([]) while inBounds == False: (path, inBounds) = generator.generateRandomPrimitivePath(map, currentAgent) paths.append(path) infoMap = self.generateInfoMapFromPrimitivePaths(map, 5, agentList, paths) erg = mathlib.calcErgodicity(map, infoMap, splitMapIndex, 15) if minErg < 0 or erg < minErg: minErg = erg bestSplitMapPaths[splitMapIndex] = np.array(paths) #if (minErg != -1): # print(minErg) # printing final erg values: for i in range(len(splitMapAgents)): agentList = splitMapAgents[i] infoMap = self.generateInfoMapFromPrimitivePaths(map, 5, agentList, bestSplitMapPaths[i]) erg = mathlib.calcErgodicity(map, infoMap, i, 15) #print("Final erg " + str(erg)) if (erg > 0.0): print(erg) return np.array(bestSplitMapPaths)''' bestSplitMapPaths = [[], [], []] originalMap = Map(map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) tries = 1 lowestx, lowesty = map.getWorldSize() highestx = 0 highesty = 0 for splitMapIndex in range(len(splitMapAgents)): minErg = -1 agentList = splitMapAgents[splitMapIndex] #print("Number of agents: " + str(len(agentList))) for trial in range(tries * len(agentList)): map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) #print("Map size: " + str(len(map._distribution)) + ", " + str(len(map._distribution[0]))) #print("Map sum = " + str(map._distribution.sum())) #for i in range(len(map._distribution)): # print("Line sum = " + str(map._distribution[i].sum())) for n in range(10): #print(minErg) paths = [] for i in range(len(agentList)): currentAgent = agentList[i] generator = self._generators[ currentAgent.generatorIndex] inBounds = False count = 0 path = PathPrimitive([]) while inBounds == False: count += 1 if (count % 100000 == 0): map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) (path, inBounds) = generator.generateRandomPrimitivePath( map, currentAgent) paths.append(path) infoMap = self.generateInfoMapFromPrimitivePaths( originalMap, 5, agentList, paths) erg = mathlib.calcErgodicity(originalMap, infoMap, splitMapIndex, 15) if minErg < 0 or erg < minErg: minErg = erg bestSplitMapPaths[splitMapIndex] = np.array(paths) #lowestx = 100 #lowesty = 100 lowestx, lowesty = map.getWorldSize() highestx = 0 highesty = 0 for path in paths: for x in range(int(path.getTotalTime())): (currentx, currenty) = path.getPointAtTime(float(x)) #(currentx, currenty) = map.mapToWorld(currentx, currenty) if currentx > highestx: highestx = currentx if currentx < lowestx: lowestx = currentx if currenty > highesty: highesty = currenty if currenty < lowesty: lowesty = currenty lowestx, lowesty = map.worldToMap(lowestx, lowesty) highestx, highesty = map.worldToMap(highestx, highesty) if (len(map._distribution) <= highesty) or (len( map._distribution[0]) <= highestx): #print("flag") map = Map(map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) else: #Map stays unchanged if either dimension of new map is 0 if (len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)]) == 0): map = Map(map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) elif (len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)][0]) == 0): map = Map(map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) #else: # map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) #Map stays unchanged if sum of probabilities in new map is 0.0 elif (originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)].sum() == 0.0): map = Map(map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) #else: # map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) #elif(len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) > 0): #Map stays unchanged if new map dimensions is less than 5x5 elif ((len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)]) * len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)][0])) < 25): map = Map(map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) #else: # map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) elif (originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)].sum() == 1.0): for i in range( len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)])): if (originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)][i].sum() == 1.0): map = Map( map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) #change to original # Map stays unchanged if only one value in new map is non-zero else: flag = 0 for i in range( len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)])): if (originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)][i].sum() == 0.0): flag += 1 #figure out how to make this not hard coded if flag >= (len(originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)]) - 3): print("Number of all-zero rows" + str(flag)) map = Map( map.sizeX, map.sizeY, map.dX, map.dY, 50, map._distribution) #Change to originalMap else: map = Map( abs(int(highestx) - int(lowestx)), abs(int(highesty) - int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[ int(lowesty):int(highesty), int(lowestx):int(highestx)]) if (minErg != -1): print(minErg) if (minErg > 0.2): print(map.sizeX) #printing final erg values: for i in range(len(splitMapAgents)): agentList = splitMapAgents[i] infoMap = self.generateInfoMapFromPrimitivePaths( originalMap, 5, agentList, bestSplitMapPaths[i]) erg = mathlib.calcErgodicity(originalMap, infoMap, i, 15) #print("Final erg " + str(erg)) #if (erg > 0.0): #print(erg) return np.array(bestSplitMapPaths)
def generateRandomPrimitivePath(self, map, agent): ''' Returns an array of primitives corresponding to a path for the given agent Args: map (Map): Map to generate path on pathTIme (float): How long should travelling on the path take? agent (Agent): Agent to generate path for ''' primitivePath = [] speed = agent.currentSpeed timeLeft = self._pathTime '''Changing starting point for agent to be on suitable terrain''' if agent.terrainCode == 3: g = PathGeneratorStraight(self._pathTime) return g.generateRandomPrimitivePath(map, agent) if (map._terrainDistribution[int(agent.position[0])][int( agent.position[1])] != agent.terrainCode): if (agent.terrainCode in map._terrainDistribution[50:60, 50:60]): agent.position = agent.setStartingPointCentre(map) else: agent.position = agent.setStartingPoint(map) point = map.mapToWorld(agent.position[0], agent.position[1]) while timeLeft > 0: checkPoints = False count = 0 while checkPoints == False: count += 1 validTerrain = False while validTerrain == False: count += 1 nextPoint = map.getRandomPoint() (x, y) = nextPoint if int(map._terrainDistribution[y] [x]) == agent.terrainCode: validTerrain = True dist = ((point[0] - nextPoint[0])**2 + (point[1] - nextPoint[1])**2)**0.5 heading = math.atan2(-(nextPoint[1] - point[1]), nextPoint[0] - point[0]) time = min(dist / speed, timeLeft) primitive = PrimitiveLine(time, speed, point, heading) '''Ensuring entire path primitive is within suitable terrain''' flag = 0 for t in range(int(primitive.getTotalTime())): for dt in range(1): (i, j) = primitive.getPointAtTime((t + dt * 0.1)) if (int(map._terrainDistribution[int(j)][int(i)]) != agent.terrainCode): flag = 1 if (flag == 0): checkPoints = True timeLeft -= time point = primitive.getEndPoint() minSpeed = max(speed - agent.acceleration * time, agent.minSpeed) maxSpeed = min(speed + agent.acceleration * time, agent.maxSpeed) speed = rand.uniform(minSpeed, maxSpeed) primitivePath = np.append(primitivePath, [primitive]) return (PathPrimitive(primitivePath), True)
def generatePrimitivePaths(self, map, splitMapAgents, tries): ''' Returns an array of primitive paths (an array of primitives) that take pathTime time for each agent. path at index i corresponds to agent i in agents array. Args: map (Map): Map to generate path on pathTime (float): time path traversal should take agents (Agent array): the agents to generate path for tries (int): how many tries should we do for the path (we pick best one using ergodicity calculation) ''' '''Original planner''' bestSplitMapPaths = [[], [], []] for splitMapIndex in range(len(splitMapAgents)): minErg = -1 agentList = splitMapAgents[splitMapIndex] for trial in range(tries * len(agentList)): paths = [] #Finding fft of map map_fft = fftpack.fft2(map._distribution) #print("New trial") for i in range(len(agentList)): currentAgent = agentList[i] generator = self._generators[currentAgent.generatorIndex] inBounds = False path = PathPrimitive([]) reconstructedmap = currentAgent.distributeAgent(map_fft) reconstructedmap = Map(len(reconstructedmap), len(reconstructedmap[0]), map.dX, map.dY, 50, reconstructedmap) count = 0 while inBounds == False: count += 1 if (count > 7): (path, inBounds) = generator.generateRandomPrimitivePath( map, currentAgent) else: (path, inBounds) = generator.generateRandomPrimitivePath( reconstructedmap, currentAgent) paths.append(path) infoMap = self.generateInfoMapFromPrimitivePaths( map, 5, agentList, paths) erg = mathlib.calcErgodicity(map, infoMap, splitMapIndex, 15) if minErg < 0 or erg < minErg: minErg = erg bestSplitMapPaths[splitMapIndex] = np.array(paths) # Printing final erg values: '''for i in range(len(splitMapAgents)): agentList = splitMapAgents[i] infoMap = self.generateInfoMapFromPrimitivePaths(map, 5, agentList, bestSplitMapPaths[i]) erg = mathlib.calcErgodicity(map, infoMap, i, 15) #print("Final erg " + str(erg)) if (erg > 0.0): print(erg)''' return np.array(bestSplitMapPaths) '''Cross entropy planner''' '''bestSplitMapPaths = [[], [], []]
def generateRandomPrimitivePath(self, map, agent): ''' Returns an array of primitives corresponding to a path for the given agent Args: map (Map): Map to generate path on agent (Agent): Agent to generate path for ''' inBounds = True primitivePath = [] timeLeft = self._pathTime heading = agent.rotation speed = agent.currentSpeed if agent.terrainCode == 3: g = PathGeneratorStraight(self._pathTime) return g.generateRandomPrimitivePath(map, agent) if (map._terrainDistribution[int(agent.position[0])][int( agent.position[1])] != agent.terrainCode): print("Changing start") if (agent.terrainCode in map._terrainDistribution[50:60, 50:60]): agent.position = agent.setStartingPointCentre(map) else: agent.position = agent.setStartingPoint(map) point = map.mapToWorld(agent.position[0], agent.position[1]) firstPrimitive = True while timeLeft > 0: primitiveAttempts = self._primitiveTries inBounds = False primitive = None time = 0 while inBounds == False and primitiveAttempts > 0: (pathTimeMin, pathTimeMax) = self._pathLengthRange time = min(rand.uniform(pathTimeMin, pathTimeMax), timeLeft) if (rand.random() < self._straightChance): primitive = PrimitiveLine(time, speed, point, heading) else: #print("Gets here") validTerrain = False count = 1 while (validTerrain == False): #print(count) if (count % 1000 == 0): print("Overshoot" + str(count)) if (count % 1000 == 0): radius = 0.0000000000000000001 dir = -1 heading = heading - pi / 4 else: dir = 1 + ((rand.random() < 0.5) * -2) (radiusMin, radiusMax) = self._radiusRange radius = rand.uniform( max(radiusMin, agent.minRadius), radiusMax) primitive = PrimitiveCurve(time, speed, point, heading, radius, dir) (x, y) = primitive.getEndPoint() #validTerrain = True #if not map.isWorldPointOutOfBounds((x,y)): # if (map._terrainDistribution[int(x)][int(y)] == agent.terrainCode): #print("check") # validTerrain = True flag = 0 #print("Center of circle: "+ str(primitive.getCircleCenter())) #print("Radius: " + str(radius)) for dth in range(18): (x, y) = primitive.getPointOnCircle(20 * dth * pi / 180) #print("Point: " + str(x) + ", " + str(y)) if not map.isWorldPointOutOfBounds((y, x)): if (map._terrainDistribution[int(y)][int(x)] != agent.terrainCode): flag += 1 if flag == 0: validTerrain = True count += 1 inBounds = primitive.isInMapBounds(map) or ( firstPrimitive and not map.isWorldPointOutOfBounds(primitive.getEndPoint())) #print("Gets here") primitiveAttempts -= 1 if inBounds == False: break else: timeLeft -= time heading = primitive.getEndHeading() point = primitive.getEndPoint() minSpeed = max(speed - agent.acceleration * time, agent.minSpeed) maxSpeed = min(speed + agent.acceleration * time, agent.maxSpeed) speed = rand.uniform(minSpeed, maxSpeed) primitivePath = np.append(primitivePath, [primitive]) firstPrimitive = False return (PathPrimitive(primitivePath), inBounds)
def generateRandomPrimitivePath(self, map, agent): return (PathPrimitive([]), True)
def generatePrimitivePaths(self, map, splitMapAgents, tries): ''' Returns an array of primitive paths (an array of primitives) that take pathTime time for each agent. path at index i corresponds to agent i in agents array. Args: map (Map): Map to generate path on pathTime (float): time path traversal should take agents (Agent array): the agents to generate path for tries (int): how many tries should we do for the path (we pick best one using ergodicity calculation) ''' '''bestSplitMapPaths = [[],[],[]] for splitMapIndex in range(len(splitMapAgents)): minErg = -1 agentList = splitMapAgents[splitMapIndex] tries = 1 for trial in range(tries * len(agentList)): paths = [] for i in range(len(agentList)): currentAgent = agentList[i] generator = self._generators[currentAgent.generatorIndex] inBounds = False path = PathPrimitive([]) while inBounds == False: (path, inBounds) = generator.generateRandomPrimitivePath(map, currentAgent) paths.append(path) infoMap = self.generateInfoMapFromPrimitivePaths(map, 5, agentList, paths) erg = mathlib.calcErgodicity(map, infoMap, splitMapIndex, 15) if minErg < 0 or erg < minErg: minErg = erg bestSplitMapPaths[splitMapIndex] = np.array(paths) print(minErg) return np.array(bestSplitMapPaths)''' bestSplitMapPaths = [[],[],[]] originalMap = Map(map.sizeX,map.sizeY,map.dX,map.dY,50,map._distribution) tries = 15 for splitMapIndex in range(len(splitMapAgents)): print("Start new") minErg = -1 agentList = splitMapAgents[splitMapIndex] lowestx = 100 highestx = 0 #print("Number of trials: " + str(tries)) print("Length of agent list: " + str(len(agentList))) for trial in range(tries * len(agentList)): #print("New trial") paths = [] for i in range(len(agentList)): map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) #print("new agent " + str(i)) ''' print("Map info (x): " + str(len(map._distribution)) + ", " + str(map.sizeY)) print("Map info (y): " + str(len(map._distribution[0])) + ", " + str(map.sizeX)) print("Map slicing coordinates: " + str(lowestx) + ", " + str(highestx)) ''' currentAgent = agentList[i] generator = self._generators[currentAgent.generatorIndex] for n in range(1): inBounds = False count = 0 path = PathPrimitive([]) #print("Path finding level " + str(n)) while inBounds == False: count += 1 #print("Gets to here") if (count%500 == 0): map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) #print("Overshoot " + str(count)) #print("Before finding path" + str(n)) (path, inBounds) = generator.generateRandomPrimitivePath(map, currentAgent) #print("Found path") #if (count%1000 == 0): # print("stuck here") lowestx = 100 lowesty = 100 highestx = 0 highesty = 0 for x in range(int(path.getTotalTime())): (currentx, currenty) = path.getPointAtTime(float(x)) if currentx > highestx: highestx = currentx if currentx < lowestx: lowestx = currentx if currenty > highesty: highesty = currenty if currenty < lowesty: lowesty = currenty ''' print("Map size: " + str(map.sizeX) + ", " + str(map.sizeY)) print("Starting coordinate is: " + str(int(lowestx)) + ", " + str(int(lowesty))) print("Test value before slice: " + str(map._distribution[0][0])) print("Sum of slice: " + str(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)].sum())) print("Coordinates for slice: lowx = " + str(lowestx) + ", highx = " + str(highestx) + ", lowy = " + str(lowesty) + ", highy = " + str(highesty)) ''' #Changes map back to original map if either dimension is 0 if (len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) == 0): #print("Size of map was 0") map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) elif (len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)][0]) == 0): map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) else: map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) #Changes map back to original map if sum of probabilities in map is 0.0 if (originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)].sum() == 0.0): map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) #print("Changed to original map") #print("Slice:" + str(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)])) else: map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) #Changes map back to original map if only one value is none-zero #if (originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)].sum() >= 0.99999): flag = 0 for i in range(len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)])): if (originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)][i].sum() == 0.0): flag += 1 if flag >= (len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) - 3): #print("Only one none zero value in map") map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) else: map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) #Changes map back to original map if map dimensions goes below 5x5 if(len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) > 0): if ((len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) * len(originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)][0])) < 25): #print("Map got too small") map = Map(originalMap.sizeX, originalMap.sizeY, originalMap.dX, originalMap.dY, 50, originalMap._distribution) else: map = Map(abs(int(highestx)-int(lowestx)), abs(int(highesty)-int(lowesty)), map.dX, map.dY, 50, originalMap._distribution[int(lowesty):int(highesty), int(lowestx):int(highestx)]) #print("Test value from distribution: " + str(map._distribution[0][0])) #print(len(map._distribution)) paths.append(path) infoMap = self.generateInfoMapFromPrimitivePaths(originalMap, 5, agentList, paths) erg = mathlib.calcErgodicity(originalMap, infoMap, splitMapIndex, 15) if minErg < 0 or erg < minErg: minErg = erg bestSplitMapPaths[splitMapIndex] = np.array(paths) print(minErg) return np.array(bestSplitMapPaths)