Skip to content

Commit

Permalink
fix comparison errors between NoneType and floats (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
emre-e authored and cclauss committed Jul 6, 2017
1 parent b21f0f7 commit 3c2ccc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Solid/ParticleSwarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def run(self, verbose=True):
self.scores = self._score(self.pos)
self._global_best()

if self._objective(self.global_best[0]) < self.min_objective:
if self.min_objective is not None and self._objective(self.global_best[0]) < self.min_objective:
print("TERMINATING - REACHED MINIMUM OBJECTIVE")
return self.global_best[0], self._objective(self.global_best[0])
print("TERMINATING - REACHED MAXIMUM STEPS")
Expand Down
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._objective(self.current_state) > self.best_objective:
if self.best_objective is None or self._objective(self.current_state) > self.best_objective:
self.best_objective = self._objective(self.current_state)
self.best_state = deepcopy(self.current_state)

if self.max_objective is not None and self.best_objective > self.max_objective:
if self.best_objective is not None and self.max_objective is not None and self.best_objective > 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 3c2ccc3

Please sign in to comment.