Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def simulated(self):
- self.number_of_bytes()
- candidate = self.solution_bitstring()
- candidate_value = self.func(self.solution_decimal(candidate))
- generation = 0
- while self.temperature>0.001:
- for i in range(self.bytes_number*2):
- current = choice(self.neighbours(candidate))
- current_value = self.func(self.solution_decimal(current))
- if current_value < candidate_value:
- candidate = current
- candidate_value = current_value
- elif uniform(0,1)< np.exp(-abs(candidate_value-current_value)/self.temperature):
- candidate = current
- candidate_value = current_value
- self.update_temperature(generation)
- generation = generation + 1
- return candidate_value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement