Level Sum Heuristic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def h_levelsum(self) -> int: | |
'''The sum of the level costs of the individual goals (admissible if goals independent) | |
:return: int | |
''' | |
level_sum = 0 | |
# TODO implement | |
# for each goal in the problem, determine the level cost, then add them together | |
for goal in self.problem.goal: | |
levels = [level for level in range(len(self.s_levels)) for state in self.s_levels[level] if goal == state.literal] | |
level_sum = reduce(operator.add, levels, level_sum) | |
return level_sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment