ljvmiranda921 / pyswarms

A research toolkit for particle swarm optimization in Python

Home Page:https://pyswarms.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Having Issue in optimizer

Shrey261 opened this issue · comments

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • OS: [e.g. Linux]
  • Version [e.g. Ubuntu 16.04]
  • PySwarms Version [e.g. v.0.2.0]
  • Python Version [e.g. 3.6.X]

Additional context
Add any other context about the problem here.
File "c:\Users\Shrey Chauhan\Documents\Project\Optimization of PLS using PSO.py", line 27, in
optimizer = ps.single.GlobalBestPSO(n_particles=n_particles, dimensions=dimensions, options=options, bounds=bounds)
File "C:\Users\Shrey Chauhan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyswarms\single\global_best.py", line 124, in init
super(GlobalBestPSO, self).init(
File "C:\Users\Shrey Chauhan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyswarms\base\base_single.py", line 110, in init
self.reset()
File "C:\Users\Shrey Chauhan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyswarms\base\base_single.py", line 190, in reset
self.swarm = create_swarm(
File "C:\Users\Shrey Chauhan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyswarms\backend\generators.py", line 236, in create_swarm
position = generate_swarm(
File "C:\Users\Shrey Chauhan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyswarms\backend\generators.py", line 76, in generate_swarm
np.array(lb)[np.newaxis, :], n_particles, axis=0
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
How Can I resolve this error?
Can you please help me with this.

commented

Hi Shreay261,

I'm not an expert on the PSO module, but at least just from looking at your issue I would say your issue cannot be addressed without any minimum working example which results in this traceback. Without any code there is no chance to say whether the input parameters are wrong or there is a bug in the module.