Hi, I'm working on a slightly modified version of 8 queens and my simulated annealing failures to find any answers the temperature is decreasing I've checked the neighbours and acceptance probability functions many times and checked quite a bit if you need to see more of the code I can message you any functions you need.
def simulated_annealing(self):
solution = self.queens.copy()
energy = self.cost()
static_queen = self.static_queen.copy()
iterations = 0
while self.temperature > 1.0:
new_solution = random.choice(self.neighbours(solution))
new_energy = self.cost()
if self.acceptance_probability(energy, new_energy):
solution = new_solution
energy = new_energy
static_queen = self.update_queens(solution)
self.temperature *= self.energy_consumption
print(self.temperature)
iterations += 1
return solution, energy, static_queen, iterations
def update_queens(self, board_state):
for column in board_state:
if column not in self.static_queen:
self.static_queen[column] = board_state[column]