Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def hill_climbing(self):
- self.number_of_bytes()
- candidate_solution = []
- current_solution = []
- solution = self.solution_bitstring()
- best = self.func(self.solution_decimal(solution))
- print(best)
- for i in range(10**3):
- local=False
- candidate_solution = self.solution_bitstring()
- candidate_best = self.func(self.solution_decimal(candidate_solution))
- while local is False:
- list_of_neighbours = self.neighbours(candidate_solution,doShuffle=True)
- for neighbour in list_of_neighbours:
- local=True
- if self.func(self.solution_decimal(neighbour))<candidate_best:
- candidate_best = self.func(self.solution_decimal(neighbour))
- candidate_solution = neighbour
- local=False
- break
- if candidate_best < best:
- best = candidate_best
- return best
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement