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

Prepare v.0.2.0 Release #125

Merged
merged 68 commits into from
Jun 11, 2018
Merged

Prepare v.0.2.0 Release #125

merged 68 commits into from
Jun 11, 2018

Conversation

ljvmiranda921
Copy link
Owner

@ljvmiranda921 ljvmiranda921 commented Jun 10, 2018

This is PySwarms development branch merging into master branch for v.0.2.0 release.

Major updates

The PySwarms Backend module

The new backend module exposes some swarm optimization primitives so that users can create their custom swarm implementations without relying too much from our base classes. There are two main components for backend, the Swarm class and the Topology base class. Using these classes, you can construct your own optimization loop like the one below:

optimization_loop

The Swarm class

This class acts as a data class that holds all necessary attributes in a given swarm. The idea is to continually update the attributes located there. You can easily initialize this class by providing the initial position and velocity matrices.

The Topology class

The topology class abstracts away common operations in swarm optimization: (1) determining the best particle in the swarm, (2) computing the next position, and (3) computing the velocity matrix. As of now, we only have the Ring and Star topologies implemented. Hopefully we can add more in the future.

pyswarms_api

ljvmiranda921 and others added 30 commits May 17, 2018 12:42
This commit updates the requirements and removes support for py27.

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, the test_singleobj was now
reimplemented using the pytest module.

Signed-off by: Lester James V. Miranda <[email protected]>
All tests for GlobalBestPSO, LocalBestPSO, and
BinaryPSO are now updated into pytest. In addition,
we also have conftest.py to provide test fixtures.

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit adds some descriptive information for most pytest fixtures
that were defined in the docstring.

Signed-off-by: Lester James V. Miranda <[email protected]>
Resolves #101 
Port units tests into pytest

Reference: #113
Reference: #111

This commit adds a backend module consisting of various abstractions
to common PSO operations. There are two files for this:
  - generators: for generating swarm positions, velocities, etc.
  - operators: for various swarm operations (update velocity, etc.)

As of now, one gripe I have with my current implementation is that
it consists of methods with a lot of parameters (it doesn't look
pleasing or concise). My idea is to add a Swarm class that contains
the position, velocity, c1, c2, w, etc. And just put them inside
the optimizer. We'll see how it goes

Signed-off-by: ljvmiranda921 <[email protected]>
Using default as None is not really helpful and adds another boilerplate of
checking if init_pos is None. Instead, we just multiply by 1.00, which gives us
the indentity of the matrix.

Signed-off-by: Lester James V. Miranda <[email protected]>
Reference: #111

This commit replaces SwarmBase with backend operations for generating
the swarm.
There's really no reason to restrict v_clamp to a certain type. As long
as it is an iterable, you are fine.

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit updates global best with backend operations
from the new module

Signed-off-by: Lester James V. Miranda <[email protected]>
Until they're not implemented yet, let's remove the __init__
files for these functionalities. It may confuse the user of
what we can actually do.

Signed-off-by: ljvmiranda921 <[email protected]>
This commit adds new methods to the update that interfaces well
with the Swarm class: create_swarm() as an easy abstraction for
generating new swarms and update_gbest_neighborhood() for LocaBestPSO

Signed-off-by: Lester James V. Miranda <[email protected]>
This class creates a DataClass-like interface for building swarms.
It holds all special attributes in swarm optimization that you can
reuse in case the user wants to build their own evolutionary loop.

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, the SwarmBase, LocalBestPSO, and GlobalBestPSO
are now using the Swarm class interface as its backend. The user-facing
API is still the same though.

If you will inspect the optimize() method and compare it with previous
commits, the structure is much cleaner and concise.

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, we are now comparing the set() of the reset
method rather than checking if the value is None. New tests
were also added to accommodate the swarm class.

Signed-off-by: ljvmiranda921 <[email protected]>
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 <[email protected]>
ljvmiranda921 added 24 commits June 7, 2018 13:29
In this commit, we revert the name behavior back into
the word options. This is so a more general term and will
not semantically lock us when implementing new swarm
algorithms.

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, we add a set of binary generators to
generate discrete/binary versions of the swarm.

Signed-off-by: Lester James V. Miranda <[email protected]>
Reference: #119

This commit exposes the init_pos option for user-defined initial
positions in the SwarmOptimizer base class and gbest and lbest
implementations.

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit ports base_discrete to use the backend module.
We also renamed the DiscreteSwarmBase into DiscreteSwarmOptimizer
for better semantic meaning.

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit ports the BinaryPSO to use the backend module. Python 2.7
dependencies were also removed.

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit fixes the reset() test in test_binary. Now, we call on the
attributes from the Swarm class, not in the DiscreteSwarmOptimizer
class.

Signed-off-by: Lester James V. Miranda <[email protected]>
Port discrete PSO (and other Swarm fixes)
Add pyswarms.backend module

This commit adds the `backend` module for PySwarms. It enables users to define
their own optimization loop using primitives provided by this module
(white-box approach). In addition, this commit also updates the existing
implementations of GlobalBestPSO, LocalBestPSO, and BinaryPSO to use
these backend primitives.

Some major updates:
1. Topologies are introduced to segregate computation of best_cost/pos and velocity
or position updates.
2. A Swarms class is implemented to serve as a DataClass for data storage.
3. SwarmBase is now called SwarmOptimizer (more semantically meaningful)
4. The user can now set his/her initial positions.
5. Remove py27 compatibility

Additional tasks:
1. Documentation and new notebook examples
2. Check feature selection example (#110 )

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, we'll use the Markdown file going forward. Turns
out the PyPI is now more accommodating of .md files so we'll follow
them from now on.

In the same vein, we also updated the references found in the setup.py
and MANIFEST.in of our module. In py34, there are some problems when
we're not referencing properly in MANIFEST.in, and I wonder why.

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, we do a documentation cleanup for the previous
documentation. Specifically, we updated the following:
  - Better grammar on some sentences/paragraphs.
  - Clearer docstring in some old methods
  - Add PlotEnvironment docs (wonder why it's not been added before)
  - Overall cleaner code and organization

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit adds a documentation for the backend module.
I also updated some docstrings for clearer explanations

Signed-off-by: Lester James V. Miranda <[email protected]>
In this commit, we add an assets directory to contain all images for our
documentation. The images were generated using the TiKz package
in LaTeX.

Signed-off-by: Lester James V. Miranda <[email protected]>
Add some explanation about the PySwarms API and on how to use
the backend module.

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit updates the default parameters in create_swarm
(options, by default, is now an empty dict), and in the update_velocity
of the ring and star topologies (clamp, by default, is now None)

Signed-off-by: Lester James V. Miranda <[email protected]>
This commit should update all Jupyter notebook examples
to the dev version. Hopefully everything is okay after this.
This also adds a new notebook for demonstrating the custom
optimization loop.

Signed-off-by: Lester James V. Miranda <[email protected]>
@ljvmiranda921 ljvmiranda921 requested a review from SioKCronin June 10, 2018 11:36
ljvmiranda921 added 3 commits June 10, 2018 21:48
This commit adds a branch matrix in both README and
index.rst. This gives a better overview of the doc and build
status of both master and development branches.

Signed-off-by: Lester James V. Miranda <[email protected]>
@ljvmiranda921 ljvmiranda921 merged commit cc58c7c into master Jun 11, 2018
@SioKCronin
Copy link
Collaborator

SioKCronin commented Jun 12, 2018

Congrats on this @ljvmiranda921 ! This is a great idea.

I spent the past few weeks running into a similar challenge on SwarmOpt, and decided it best to have modules of core functions for replicating algorithms and experimentation, and then classes for any implementation I decide to optimize towards efficient runtime and ability to handle large spaces. I'll definitely be reaching out in the coming weeks to compare notes as I get my first overhaul in this direction completed.

Thanks for continuing to provide consistent inspiration on what a thoughtful, well-documented project can be! 👏 👏 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants