def search(self, problem): self.clear_instrumentation() self.failure = True self.last_state = None # current <- MAKE-NODE(problem.INITIAL-STATE) current_node = Node(problem.get_initial_state()) # for t = 1 to INFINITY do time_step = 0 while True: # temperature <- schedule(t) temperature = self.scheduler.get_temp(time_step) time_step += 1 # if temperature = 0 then return current if temperature == 0: if search.utils.is_goal_state(problem, current_node): self.failure = False self.last_state = current_node.get_state() return search.utils.actions_from_nodes(current_node.get_path_from_root()) children = self.expand_node(current_node, problem) number_of_children = len(children) if number_of_children != 0: # next <- a randomly selected successor of current next = children[randint(0, number_of_children - 1)] # /\E <- next.VALUE - current.value delta_e = self._get_value(current_node) - self._get_value(next) if self._should_accept(temperature, delta_e): current_node = next
def search(self, problem): self.clear_instrumentation() self.failure = True self.last_state = None # current <- MAKE-NODE(problem.INITIAL-STATE) current_node = Node(problem.get_initial_state()) while True: children = self.expand_node(current_node, problem) # neighbor <- a highest-valued successor of current neighbor = self._get_lowest_valued_node(children) # if neighbor.VALUE <= current.VALUE then return current.STATE if neighbor == None or self._get_value(current_node) <= self._get_value(neighbor): if search.utils.is_goal_state(problem, current_node): self.failure = False self.last_state = current_node.get_state() return search.utils.actions_from_nodes(current_node.get_path_from_root()) # current <- neighbor current_node = neighbor
def search(self, problem): self.clear_instrumentation() self.failure = True self.last_state = None # current <- MAKE-NODE(problem.INITIAL-STATE) current_node = Node(problem.get_initial_state()) while True: children = self.expand_node(current_node, problem) # neighbor <- a highest-valued successor of current neighbor = self._get_lowest_valued_node(children) # if neighbor.VALUE <= current.VALUE then return current.STATE if neighbor == None or self._get_value( current_node) <= self._get_value(neighbor): if search.utils.is_goal_state(problem, current_node): self.failure = False self.last_state = current_node.get_state() return search.utils.actions_from_nodes( current_node.get_path_from_root()) # current <- neighbor current_node = neighbor