{"id":20354811,"url":"https://github.com/jakutis/mathopt","last_synced_at":"2026-06-07T00:32:10.494Z","repository":{"id":12236670,"uuid":"14848151","full_name":"jakutis/mathopt","owner":"jakutis","description":"Mathematical optimization methods.","archived":false,"fork":false,"pushed_at":"2014-02-18T19:28:57.000Z","size":176,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T05:16:40.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.org/package/mathopt","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakutis.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-01T23:14:15.000Z","updated_at":"2022-08-01T02:47:39.000Z","dependencies_parsed_at":"2022-09-26T18:21:24.387Z","dependency_job_id":null,"html_url":"https://github.com/jakutis/mathopt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakutis%2Fmathopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakutis%2Fmathopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakutis%2Fmathopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakutis%2Fmathopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakutis","download_url":"https://codeload.github.com/jakutis/mathopt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241886267,"owners_count":20036959,"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":[],"created_at":"2024-11-14T23:09:46.957Z","updated_at":"2026-06-07T00:32:10.435Z","avatar_url":"https://github.com/jakutis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mathopt\n\nA JavaScript library of mathematical optimization methods.\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [API](#api)\n- [Development](#development)\n\n## Overview\n\n* Works on browsers and NodeJS.\n* Tested on these browsers:\n  * TODO\n\n## Installation\n\n  Install manually by adding to your HTML file:\n\n    \u003cscript src=\"/path/to/mathopt/index.js\"\u003e\u003c/script\u003e\n\n  Install with [npm](https://www.npmjs.org/package/mathopt):\n\n    $ npm install --save mathopt\n\n  Install with [component](http://component.io/jakutis/mathopt):\n\n    $ component install jakutis/mathopt\n\n  Install with [bower](http://bower.io):\n\n    $ bower install --save mathopt\n\n## API\n\nSee [a demonstration of examples](https://jakut.is/mathopt/examples/) (source code in \"examples\" subfolder).\n\n### .basicPSO\n\nBasic Particle Swarm Optimization method finds the global minimum of a given numerical function using particle swarm paradigm.\n\nImplements the algorithm that is described in an article [\"Particle swarm optimization\" by James Kennedy and Russel Eberhart that is published in proceedings of IEEE International Conference on Neural Networks, 1995](http://dx.doi.org/10.1109/ICNN.1995.488968).\n\nThe default parameters are taken from an article [\"The Particle Swarm - Explosion, Stability, and Convergence in a Multidimensional Complex Space\" by Maurice Clerck and James Kennedy that is published in IEEE Transactions on Evolutionary Computation (2002, issue #1 of volume #6)](http://dx.doi.org/10.1109/4235.985692).\n\nAll particles are initialized with the position specified in `initialPosition` option.\nInitial velocities are sampled from `U(0, 2)`.\n\n```javascript\nvar cornfield = function(x, y) {\n    return Math.abs(x - 100) + Math.abs(y - 100);\n};\n\n// basic usage\n// prints \"Minimum found at TODO\"\nconsole.log('Minimum found at ', mathopt.basicPSO(cornfield));\n\n// demonstration of all the options\nmathopt.basicPSO(function(x) {\n    return cornfield(x[0], x[1]);\n}, {\n    // default: 21\n    particles: 50,\n\n    // default: inferred from the given function; when specified - the given function must accept a vector\n    dimensions: 2,\n\n    // default: [0, 0]\n    initialPosition: [5, 5],\n\n    // default: 0.01\n    idleSpeed: 0.1,\n\n    // default: 0.7298\n    inertia: 0.7,\n\n    // default: 2.9922/2\n    localAcceleration: 1.5,\n\n    // default: 2.9922/2\n    globalAcceleration: 1.5,\n\n    // default: `function(i, p, v, pbest, best, cb) { cb \u0026\u0026 setTimeout(cb, 0); }`\n    // when onstop is null, cb argument is not passed\n    oniteration: function(iteration, positions, velocities, bestpositions, bestparticle, cb) {\n        console.log(iteration, bestpositions);\n        cb \u0026\u0026 setTimeout(cb, 0);\n    },\n\n    // default: null\n    // when set, switches to asynchronous behavior:\n    // - .basicPSO does not return anything\n    // - oniteration receives a `cb` callback\n    onstop: function(min) {\n        // prints \"Minimum found at x=TODO, y=TODO, after TODO iterations\"\n        console.log('Minimum found at x=' + min[0] + ', y=' + min[1] + ' after ' + min.iterations + ' iterations');\n    }\n});\n```\n\n## Development\n\n    TODO\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakutis%2Fmathopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakutis%2Fmathopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakutis%2Fmathopt/lists"}