def test_hill_climbing(self): # run hill climbing result = hill_climbing(self.config) # assert self.assertEquals(result[0], self.solution) self.assertEquals(result[1], 1000)
def int_cmp(num_1, num_2): if num_1 > num_2: return 1 elif num_1 < num_2: return -1 else: return 0 if __name__ == "__main__": candidate = "abcdefghij" details = { "debug": True, "tweak_function": tweak_function, "eval_function": eval_function, "stop_function": stop_function, "candidate": candidate, "max_iterations": 1000, "target_score": 1000, "comparator": int_cmp } result = hill_climbing(details) print "\nSOLUTION -->", result[0]