From 9cb1c8a2107fb50baab7d8db4619cd4c2642da05 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 6 Jul 2017 20:40:10 +0200 Subject: [PATCH] Update StochasticHillClimb.py --- Solid/StochasticHillClimb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Solid/StochasticHillClimb.py b/Solid/StochasticHillClimb.py index 9bc77df..345e68c 100644 --- a/Solid/StochasticHillClimb.py +++ b/Solid/StochasticHillClimb.py @@ -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")