ljvmiranda921 / pyswarms

A research toolkit for particle swarm optimization in Python
https://pyswarms.readthedocs.io/en/latest/
MIT License
1.27k stars 333 forks source link

Pyswarms changes dtype from pyten.mp.MPS() to np.ndarray() #528

Open kmos-s opened 4 months ago

kmos-s commented 4 months ago

Description

I am trying to minimize the entropy of a pyten.mp.MPS(). When I use the pyswarms optimizer with the entropy function, as soon, as I multiply the pyten.mp.MPS() with a number (float) the data type of the MPS is changed to a np.dnarray(). Is there a way to avoid this datatype change?

What I Did

optimizer = ps.single.GlobalBestPSO(n_particles=10, dimensions=1, options={'c1': 0.5, 'c2': 0.3, 'w':0.9}, bounds=(np.array([-1.]), np.array([1.])))
res, b = optimizer.optimize(Entropy, 10, **kwargs)