def choose_location(self):
# initialize variables
S = len(self.location2visits) # number of already visited locations
if S == 0:
self.home = self.__preferential_exploration(self.home)
return self.home
## choose a probability to return o explore
p_new = uniform(0, 1)
if p_new <= self.rho * pow(S, -self.gamma): # choose to return or explore
# PREFERENTIAL EXPLORATION
current_location = self.trajectory[-1] # the last visited location
return self.__preferential_exploration(current_location)
else:
# PREFERENTIAL RETURN
return self.__preferential_return()
评论列表
文章目录