From b41c1f3a25646457c3821e2401aa9f768ad90f17 Mon Sep 17 00:00:00 2001 From: Daniel Correia Date: Fri, 15 Feb 2019 12:45:18 +0000 Subject: [PATCH] BinaryPSO should return final best position instead of final swarm Resolves #292 --- pyswarms/discrete/binary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyswarms/discrete/binary.py b/pyswarms/discrete/binary.py index d32cdac1..857b4ac4 100644 --- a/pyswarms/discrete/binary.py +++ b/pyswarms/discrete/binary.py @@ -207,7 +207,7 @@ def optimize(self, objective_func, iters, fast=False, **kwargs): self.swarm.position = self._compute_position(self.swarm) # Obtain the final best_cost and the final best_position final_best_cost = self.swarm.best_cost.copy() - final_best_pos = self.swarm.best_pos.copy() + final_best_pos = self.swarm.position[self.swarm.pbest_cost.argmin(axis=0)].copy() self.rep.log( "Optimization finished | best cost: {}, best pos: {}".format( final_best_cost, final_best_pos