{"id":14989256,"url":"https://github.com/jerrytheo/psopy","last_synced_at":"2025-04-12T00:31:57.460Z","repository":{"id":55052214,"uuid":"121534098","full_name":"jerrytheo/psopy","owner":"jerrytheo","description":"A SciPy compatible super fast Python implementation for Particle Swarm Optimization.","archived":false,"fork":false,"pushed_at":"2020-04-19T19:21:42.000Z","size":1068,"stargazers_count":36,"open_issues_count":3,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T08:42:07.987Z","etag":null,"topics":["constrained-optimization","optimization-algorithms","particle-swarm-optimization","scipy"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerrytheo.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-14T16:34:51.000Z","updated_at":"2024-08-23T09:46:36.000Z","dependencies_parsed_at":"2022-08-14T10:10:40.981Z","dependency_job_id":null,"html_url":"https://github.com/jerrytheo/psopy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerrytheo%2Fpsopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerrytheo%2Fpsopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerrytheo%2Fpsopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerrytheo%2Fpsopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerrytheo","download_url":"https://codeload.github.com/jerrytheo/psopy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223486880,"owners_count":17153241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constrained-optimization","optimization-algorithms","particle-swarm-optimization","scipy"],"created_at":"2024-09-24T14:17:57.005Z","updated_at":"2024-11-07T09:03:34.997Z","avatar_url":"https://github.com/jerrytheo.png","language":"Python","readme":"===============================================================================\nPSOPy\n===============================================================================\n\n    A python implementation of Particle Swarm Optimization.\n\n-------------------------------------------------------------------------------\nIntroduction\n-------------------------------------------------------------------------------\n\nPSOPy (pronounced \"Soapy\") is a SciPy compatible super fast Python\nimplementation for Particle Swarm Optimization. The codes are tested for\nstandard optimization test functions (both constrained and unconstrained).\n\nThe library provides two implementations, one that mimics the interface to\n``scipy.optimize.minimize`` and one that directly runs PSO. The SciPy\ncompatible function is a wrapper over the direct implementation, and therefore\nmay be slower in execution time, as the constraint and fitness functions are\nwrapped.\n\n-------------------------------------------------------------------------------\nInstallation\n-------------------------------------------------------------------------------\n\nGitHub\n======\n\nTo install this library from GitHub,\n\n.. code-block:: bash\n\n    $ git clone https://github.com/jerrytheo/psopy.git\n    $ cd psopy\n    $ python setup.py install\n\nIn order to run the tests,\n\n.. code-block:: bash\n\n    $ python setup.py test\n\nPyPI\n====\n\nThis library is available on the PyPI as psopy. If you have pip installed run,\n\n.. code-block:: bash\n\n    $ pip install psopy\n\n-------------------------------------------------------------------------------\nExamples\n-------------------------------------------------------------------------------\n\nUnconstrained Optimization\n==========================\n\nConsider the problem of minimizing the Rosenbrock function, implemented as\n``scipy.optimize.rosen`` using a swarm of 1000 particles.\n\n\u003e\u003e\u003e import numpy as np\n\u003e\u003e\u003e from psopy import minimize\n\u003e\u003e\u003e from scipy.optimize import rosen\n\u003e\u003e\u003e x0 = np.random.uniform(0, 2, (1000, 5))\n\u003e\u003e\u003e res = minimize(rosen, x0, options={'stable_iter': 50})\n\u003e\u003e\u003e res.x\narray([1.00000003, 1.00000017, 1.00000034, 1.0000006 , 1.00000135])\n\nConstrained Optimization\n========================\n\nNext, we consider a minimization problem with several constraints. The intial\npositions for constrained optimization must adhere to the constraints imposed\nby the problem. This can be ensured using the provided function\n``psopy.init_feasible``. Note, there are several caveats regarding the use of\nthis function. Consult its documentation for more information.\n\n\u003e\u003e\u003e # The objective function.\n\u003e\u003e\u003e fun = lambda x: (x[0] - 1)**2 + (x[1] - 2.5)**2\n\u003e\u003e\u003e # The constraints.\n\u003e\u003e\u003e cons = ({'type': 'ineq', 'fun': lambda x:  x[0] - 2 * x[1] + 2},\n...         {'type': 'ineq', 'fun': lambda x: -x[0] - 2 * x[1] + 6},\n...         {'type': 'ineq', 'fun': lambda x: -x[0] + 2 * x[1] + 2},\n...         {'type': 'ineq', 'fun': lambda x: x[0]},\n...         {'type': 'ineq', 'fun': lambda x: x[1]})\n\u003e\u003e\u003e from psopy import init_feasible\n\u003e\u003e\u003e x0 = init_feasible(cons, low=0., high=2., shape=(1000, 2))\n\u003e\u003e\u003e res = minimize(fun, x0, constrainsts=cons, options={\n...     'g_rate': 1., 'l_rate': 1., 'max_velocity': 4., 'stable_iter': 50})\n\u003e\u003e\u003e res.x\narray([ 1.39985398,  1.69992748])\n\n-------------------------------------------------------------------------------\nAuthors\n-------------------------------------------------------------------------------\n\n- Abhijit Theophilus (abhijit.theo@gmail.com)\n- Dr\\. Snehanshu Saha (snehanshusaha@pes.edu)\n- Suryoday Basak (suryodaybasak@gmail.com)\n\n-------------------------------------------------------------------------------\nLicense\n-------------------------------------------------------------------------------\n\n| Licensed under the BSD 3-Clause License.\n| Copyright 2018 Abhijit Theophilus, Snehanshu Saha, Suryoday Basak\n\n-------------------------------------------------------------------------------\nReferences\n-------------------------------------------------------------------------------\n.. [1] Theophilus, A., Saha, S., Basak, S. and Murthy, J., 2018. A Novel\n    Exoplanetary Habitability Score via Particle Swarm Optimization of CES\n    Production Functions. arXiv preprint arXiv:1805.08858.\n.. [2] Ray, T. and Liew, K.M., 2001. A swarm with an effective information\n    sharing mechanism for unconstrained and constrained single objective\n    optimisation problems. In Evolutionary Computation, 2001. Proceedings of\n    the 2001 Congress on (Vol. 1, pp. 75-80). IEEE.\n.. [3] Eberhart, R. and Kennedy, J., 1995, October. A new optimizer using\n    particle swarm theory. In Micro Machine and Human Science, 1995. MHS'95.,\n    Proceedings of the Sixth International Symposium on (pp. 39-43). IEEE.\n.. [4] Shi, Y. and Eberhart, R., 1998, May. A modified particle swarm\n    optimizer. In Evolutionary Computation Proceedings, 1998. IEEE World\n    Congress on Computational Intelligence., The 1998 IEEE International\n    Conference on (pp. 69-73). IEEE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerrytheo%2Fpsopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerrytheo%2Fpsopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerrytheo%2Fpsopy/lists"}