question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add boundary handlers for stuck particles

See original GitHub issue

Is your feature request related to a problem? Please describe. There are some stuck particles as reported in #234 and #150 . This is related to compute_position waiving position updates whenever a particle will potentially end up out-of-bounds. There are standard ways to avoid this problem. The reflective bounds is one option, but the related PR is currently stale, so it may be important to create a general framework for handling the boundary problem.

Describe the solution you’d like Create a set of handlers, such as a BoundaryHandler. Usage example:

Usage outside of the class

# Usage outside of the class
from pyswarms.backend import operators as ops
from pyswarms.backend.handlers import BoundaryHandler

bh = BoundaryHandler(strategy="reflective") # And other arguments here if it's parameterized
ops.compute_position(swarm, bounds, handler=bh) 

Inside BoundaryHandler

# Inside BoundaryHandler
class BoundaryHandler(object):
    def __call__(self, position, bounds, *args, **kwargs): # parameterized
        # Some logic here depending on the type of handler, for example:
        # (might be better as a dictionary with a string as key and callable as
        # its value)
        if self.strategy == "reflective":
            new_positions = self.reflective(position, bounds) # parameterized

    def reflective(self, position, bounds):
        """Some docstring here"""
        pass

How it will work in the backend:

if handler:
    new_position = handler(swarm.positions, bounds)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
whzupcommented, Aug 27, 2018

Yes maybe we can work on the same PR branch?

Yes! I have never done that, might be a nice experience 😄

There’s also the need to use handlers for Velocity

I wonder if it might suffice to use a VelocityHandler. If the particles don’t even leave the bounds there is no reason to fix the position 🤔 Maybe we can try it out like that?

0reactions
whzupcommented, Aug 27, 2018

Ok 👍 Let’s do this one!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boundary Handling and Adaptive Time-stepping for PCISPH
We present a novel boundary handling scheme for incompressible fluids based on Smoothed Particle Hydrodynamics (SPH).
Read more >
A generic smoothed wall boundary in multi-resolution ...
One of the challenges for wall boundary models is how to deal with moving or deforming complex geometry boundaries. For the boundary models ......
Read more >
Analyzing particles on a stick boundary using ...
In this week's blog post we will investigate Lagrangian post-processing and more specifically the function of boundary sampling.
Read more >
Liquid Boundaries for Implicit Incompressible SPH
fluid and boundary representation adds flexibility to IISPH which enables versatile effects. In particular, particles can now dynami-.
Read more >
Moving Least Squares Boundaries for SPH Fluids
The paper shows that the SPH boundary handling of Akinci et al. [AIA ... Particle-based boundary representations in fluid simulations are.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found