Bases: optunity.solvers.util.Solver
Please refer to Particle Swarm Optimization for details on this algorithm.
Initializes a PSO solver.
Parameters: |
|
---|
The number of function evaluations it will perform is num_particles`*`num_generations. The search space is rescaled to the unit hypercube before the solving process begins.
>>> solver = ParticleSwarm(num_particles=10, num_generations=5, x=[-1, 1], y=[0, 2])
>>> solver.bounds['x']
[-1, 1]
>>> solver.bounds['y']
[0, 2]
>>> solver.num_particles
10
>>> solver.num_generations
5
Warning
This solver is not explicitly constrained. The box constraints that are given are used for initialization, but solver may leave the specified region during iterations. If this is unacceptable, you must manually constrain the domain of the objective function prior to using this solver (cfr. Domain constraints).
Maximizes f.
Parameters: |
|
---|---|
Returns: |
|
Minimizes f.
Parameters: |
|
---|---|
Returns: |
|
Optimizes f.
Parameters: |
|
---|---|
Returns: |
|
Create a configuration for a ParticleSwarm solver.
Parameters: |
|
---|
>>> config = ParticleSwarm.suggest_from_box(200, x=[-1, 1], y=[0, 1])
>>> config['x']
[-1, 1]
>>> config['y']
[0, 1]
>>> config['num_particles'] > 0
True
>>> config['num_generations'] > 0
True
>>> solver = ParticleSwarm(**config)
>>> solver.bounds['x']
[-1, 1]
>>> solver.bounds['y']
[0, 1]