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

Add Topologies #117

Merged
merged 8 commits into from
Jun 6, 2018
Merged

Add Topologies #117

merged 8 commits into from
Jun 6, 2018

Conversation

ljvmiranda921
Copy link
Owner

@ljvmiranda921 ljvmiranda921 commented May 24, 2018

The next few commits should fail, I don't have tests for it yet.

@ljvmiranda921 ljvmiranda921 added the enhancement Feature requests label May 24, 2018
@ljvmiranda921
Copy link
Owner Author

ljvmiranda921 commented Jun 6, 2018

TODO

  • Write out the Ring topology for LocalBestPSO. The reason why your tests are failing is because it's trying to import LocalBestPSO, but that class also imports the operator methods that does not exist. Write out the Ring topology first.
  • After writing out Ring, you can proceed updating the implementations in GlobalBestPSO and LocalBestPSO. The idea is that in your init method, you call the topology needed, then use the class as you would you the others
from backend.topology import Star

# ... inside the GlobalBestPSO class
def __init__():
    topology = Star()

def optimize():
    topology.compute_global_best()
  • Then update your tests

@ljvmiranda921
Copy link
Owner Author

Wow I solved it. 😮

ljvmiranda921 added 8 commits June 6, 2018 21:15
This commit adds the Topology module's __init__ file. The concept
behind this module is that if we can add topologies in a modular
fashion, we can easily explore different PSO behaviour.

Signed-off-by: Lester James V. Miranda <ljvmiranda@gmail.com>
This commit adds the base Topology class that must be inherited
by any topology implementation. It raises a NotImplementedError
whenever the compute_gbest(), compute_position(), and compute_velocity()
are not called.

I decided to put the compute_position() and compute_velocity() methods
here because there may be cases where these operations are controlled
by the Topology itself. In case, standard implementations are required,
pyswarms.backend.operators should suffice.

Signed-off-by: Lester James V. Miranda <ljvmiranda@gmail.com>
This commit adds the Star class topology for the GlobalBestPSO
implementation.

Signed-off-by: Lester James V. Miranda <ljvmiranda@gmail.com>
In this commit, we move the global best computation to the Topology
classes themselves, but keep the compute_pbest(), compute_position() and
compute_velocity() so that people can reuse it.  The position and
velocity computations are standard implementations, so this is just
imported by the Ring and Star topology classes in their own methods

Signed-off-by: Lester James V. Miranda <ljvmiranda@gmail.com>
This commit adds the Ring class topology for the LocalBestPSO
implementation. In the next iteration, we should start considering
having a strict number of neighbors (static and dynamic). But let's
solve the BinaryPSO first before going there.

Signed-off-by: Lester James V. Miranda <ljvmiranda@gmail.com>
Both GlobalBestPSO and LocalBestPSO now uses the Topology backend.
Hooray!

Signed-off-by: Lester James V. Miranda <ljvmiranda@gmail.com>
@ljvmiranda921 ljvmiranda921 merged commit 948e727 into add-backend-module Jun 6, 2018
@ljvmiranda921 ljvmiranda921 deleted the add-topologies branch June 6, 2018 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant