Skip to content

Commit

Permalink
Update StochasticHillClimb.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Jul 6, 2017
1 parent 3c2ccc3 commit 9cb1c8a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Solid/StochasticHillClimb.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ def run(self, verbose=True):
if self._accept_neighbor(neighbor):
self.current_state = neighbor

if self.best_objective is None or self._objective(self.current_state) > self.best_objective:
if self._objective(self.current_state) > (self.best_objective or 0):
self.best_objective = self._objective(self.current_state)
self.best_state = deepcopy(self.current_state)

if self.best_objective is not None and self.max_objective is not None and self.best_objective > self.max_objective:
if self.max_objective is not None and (self.best_objective or 0) > self.max_objective:
print("TERMINATING - REACHED MAXIMUM OBJECTIVE")
return self.best_state, self.best_objective
print("TERMINATING - REACHED MAXIMUM STEPS")
Expand Down

0 comments on commit 9cb1c8a

Please sign in to comment.