sme_contrib.optimize.minimize
- sme_contrib.optimize.minimize(f, lowerbounds, upperbounds, particles=20, iterations=20, processes=None, ps_options=None)
Minimize function
f
using particle swarmThe function
f
should take an array or list of parametersx
, and return a value: parameters will be found using particle swarm that minimize this value.Each parameter should have a specified lower and upper bound.
The evaluations of
f
are done in parallel, sof
must be a thread-safe function that can safely be called from multiple threads at the same time. The evaluations are parallelized over the particles for each iteration, so for good performance the number of particles should be larger than the number of processes.- Parameters
f – The function to evaluate, it should be callable as f(x) and return a scalar
lowerbounds – The lower bound for each element of x.
upperbounds – The upper bound for each element of x.
particles – The number of particles to use in the swarm
iterations – The number of iterations to do
processes – The number of processes to use (the default
None
means use all available cpu cores)ps_options – A map of the particle swarm hyper parameters to use
- Returns
The lowest cost ps_res: The parameters that gave this lowest cost optimizer: The PySwarms optimizer object
- Return type
ps_cost