Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handlers #286

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pyswarms/backend/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,14 @@ def reflective(self, position, bounds, **kwargs):
:nowrap:

\begin{gather*}
\text{while } x_{i, t, d} \not\in \left[lb_d,\,ub_d\right] \text{ do the
following:}
\text{while } x_{i, t, d} \not\in \left[lb_d,\,ub_d\right] \\
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I didn't see this. Can you give me visual confirmation if this will render properly once generated?
(Just generate the docs and screenshot what this will look like)

\text{ do the following:}\\
\\
x_{i, t, d} = \begin{cases}
2\cdot lb_d - x_{i, t, d} & \quad \text{if } x_{i,
t, d} < lb_d
t, d} < lb_d \\
2\cdot ub_d - x_{i, t, d} & \quad \text{if } x_{i,
t, d} > ub_d
t, d} > ub_d \\
x_{i, t, d} & \quad \text{otherwise}
\end{cases}
\end{gather*}
Expand Down
2 changes: 2 additions & 0 deletions pyswarms/discrete/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ def optimize(self, objective_func, iters, fast=False, **kwargs):
"Optimize for {} iters with {}".format(iters, self.options),
lvl=logging.INFO,
)
# Populate memory of the handlers
self.vh.memory = self.swarm.position

self.swarm.pbest_cost = np.full(self.swarm_size[0], np.inf)
for i in self.rep.pbar(iters, self.name):
Expand Down
5 changes: 5 additions & 0 deletions pyswarms/single/general_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ def optimize(self, objective_func, iters, fast=False, **kwargs):
"Optimize for {} iters with {}".format(iters, self.options),
lvl=logging.INFO,
)

# Populate memory of the handlers
self.bh.memory = self.swarm.position
self.vh.memory = self.swarm.position

self.swarm.pbest_cost = np.full(self.swarm_size[0], np.inf)
for i in self.rep.pbar(iters, self.name):
# Compute cost for current position and personal best
Expand Down
3 changes: 3 additions & 0 deletions pyswarms/single/global_best.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def optimize(self, objective_func, iters, fast=False, **kwargs):
"Optimize for {} iters with {}".format(iters, self.options),
lvl=logging.INFO,
)
# Populate memory of the handlers
self.bh.memory = self.swarm.position
self.vh.memory = self.swarm.position

self.swarm.pbest_cost = np.full(self.swarm_size[0], np.inf)
for i in self.rep.pbar(iters, self.name):
Expand Down
3 changes: 3 additions & 0 deletions pyswarms/single/local_best.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def optimize(self, objective_func, iters, fast=False, **kwargs):
"Optimize for {} iters with {}".format(iters, self.options),
lvl=logging.INFO,
)
# Populate memory of the handlers
self.bh.memory = self.swarm.position
self.vh.memory = self.swarm.position

self.swarm.pbest_cost = np.full(self.swarm_size[0], np.inf)
for i in self.rep.pbar(iters, self.name):
Expand Down