Created
January 16, 2020 10:45
-
-
Save tarlanahad/f57976843080678eba8a7d0fd535b9cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Particle: | |
def __init__(self, dim, minx, maxx): | |
self.position = np.random.uniform(low=minx, high=maxx, size=dim) | |
self.velocity = np.random.uniform(low=minx, high=maxx, size=dim) | |
self.best_part_pos = self.position.copy() | |
self.error = error(self.position) | |
self.best_part_err = self.error.copy() | |
def setPos(self, pos): | |
self.position = pos | |
self.error = error(pos) | |
if self.error < self.best_part_err: | |
self.best_part_err = self.error | |
self.best_part_pos = pos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment