Conditions | 1 |
Total Lines | 15 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # Author: Simon Blanke |
||
39 | @HillClimbingOptimizer.track_new_pos |
||
40 | @HillClimbingOptimizer.random_iteration |
||
41 | def move_linear(self): |
||
42 | r1, r2 = random.random(), random.random() |
||
43 | |||
44 | A = self.inertia * self.velo |
||
45 | B = self.cognitive_weight * r1 * np.subtract(self.pos_best, self.pos_current) |
||
46 | C = ( |
||
47 | self.social_weight |
||
48 | * r2 |
||
49 | * np.subtract(self.global_pos_best, self.pos_current) |
||
50 | ) |
||
51 | |||
52 | new_velocity = A + B + C |
||
53 | return self._move_part(self.pos_current, new_velocity) |
||
54 |