def __call__(self): if self.seed is not None: np.random.seed(self.seed) self.seed = self.seed + 1 xMin, xMax = self.xBoundary yMin, yMax = self.yBoundary initialAgentState = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) targetPosition = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) initialDistance = computeVectorNorm(targetPosition - initialAgentState) while not ( (self.checkBound(initialAgentState) == initialAgentState).all() and (self.checkBound(targetPosition) == targetPosition).all() and initialDistance <= self.maxInitDist): initialAgentState = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) targetPosition = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) initialDistance = computeVectorNorm(targetPosition - initialAgentState) return np.concatenate([initialAgentState, targetPosition])
def __call__(self): point = dataTools.sampleData(self.dataSet, 1) state, action, value = point sheep, wolf = getEachState(state[0]) distance = computeVectorNorm(np.array(sheep) - np.array(wolf)) while not (distance >= self.minInitDist): point = dataTools.sampleData(self.dataSet, 1) state, action, value = point sheep, wolf = getEachState(state[0]) distance = computeVectorNorm(np.array(sheep) - np.array(wolf)) return state[0]
def __call__(self, state): agentState, targetPosition = getEachState(state) relativeVector = np.array(agentState) - np.array(targetPosition) relativeDistance = computeVectorNorm(relativeVector) if relativeDistance <= self.minDistance: return True return False
def __call__(self, state): sheepState, wolfState = getEachState(state) relativeVector = np.array(sheepState) - np.array(wolfState) relativeDistance = computeVectorNorm(relativeVector) if relativeDistance <= self.minDistance: return True return False
def __call__(self, state, action): oldSheepPos, oldWolfPos = getEachState(state) # wolf wolfAction = self.wolfPolicy(state) wolfActionMagnitude = computeVectorNorm(np.array(wolfAction)) modifiedWolfAction = np.array( wolfAction) * 0.95 * self.velocity / wolfActionMagnitude newWolfPos = np.array(oldWolfPos) + modifiedWolfAction # sheep sheepActionMagnitude = computeVectorNorm(np.array(action)) modifiedSheepAction = np.array( action) * self.velocity / sheepActionMagnitude newSheepPos = np.array(oldSheepPos) + modifiedSheepAction sheepPos = self.checkBound(newSheepPos) wolfPos = self.checkBound(newWolfPos) return np.concatenate([sheepPos, wolfPos])
def __call__(self, state, action): agentState, targetPosition = getEachState(state) actionMagnitude = computeVectorNorm(np.array(action)) modifiedAction = np.array(action) * self.velocity / actionMagnitude newAgentState = np.array(agentState) + modifiedAction if checkBound(newAgentState, self.xBoundary, self.yBoundary): return np.concatenate([newAgentState, targetPosition]) return np.concatenate([agentState, targetPosition])
def __call__(self): xMin, xMax = self.xBoundary yMin, yMax = self.yBoundary initialAgentState = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) targetPosition = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) initialDistance = computeVectorNorm(targetPosition - initialAgentState) while not ( checkBound(initialAgentState, self.xBoundary, self.yBoundary) and checkBound(targetPosition, self.xBoundary, self.yBoundary) and initialDistance >= 20): initialAgentState = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) targetPosition = np.array( [np.random.uniform(xMin, xMax), np.random.uniform(yMin, yMax)]) initialDistance = computeVectorNorm(targetPosition - initialAgentState) return np.concatenate([initialAgentState, targetPosition])