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

Implemented options to hotstart training #499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LucasWaelti
Copy link

@LucasWaelti LucasWaelti commented Aug 11, 2022

Description

This PR implements an option to provide the swarm position, velocity and global best (or any particle) to the optimizer. This was performed by adding the following optional arguments to the optimizer class:

  • init_vel
  • init_best

The arguments were added to GlobalBestPSO, GeneralOptimizerPSO and LocalBestPSO as well as to the abstract base classes SwarmOptimizer and DiscreteSwarmOptimizer.

The optimizer can now be called as follows:

# Call instance of PSO 
optimizer = pyswarms.single.GlobalBestPSO(
                    n_particles=100, dimensions=dim, options=options, bounds=bounds, 
                    init_pos=init_pos,init_vel=init_vel,init_best=init_best)

Related Issue

Motivation and Context

The current implementation does not allow to properly resume a previous optimization process. This PR makes it possible while maintaining full compatibility with previous versions.

How Has This Been Tested?

This has been tested in a limited manner so far. Only using GlobalBestPSO on Ubuntu 18.04, python 3.6.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly (modified docstrings in the code).
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Sorry, something went wrong.

Unverified

This user has not yet uploaded their public signing key.
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.

None yet

1 participant