ljvmiranda921 / pyswarms

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

Having Issue in optimizer #512

Open Shrey261 opened 1 year ago

Shrey261 commented 1 year ago

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):

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.

scimax commented 1 year ago

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.