\n \n \n

\n\n### With control\nIf we apply data-driven real-time closed loop control, it can be stabilized at an unstable fixed point (near the center of the butterfly wing).\n\n\n \n \n

\n\n## Highlights\nHere are some hightlights about this algorithm, and for more detail refer to this [paper](https://epubs.siam.org/doi/pdf/10.1137/18M1192329)\n\n- Efficient data-driven online linear/nonlinear model learning (system identification). Any nonlinear and/or time-varying system is locally linear, as long as the model is updated in real-time wrt to new measurements.\n- It finds the exact optimal solution (in the sense of least square error), without any approximation (unlike stochastic gradient descent). \n- It achieves theoretical optimal time and space complexity. \n- The time complexity (flops for one iteration) is O(n^2), where n is state dimension. This is much faster than standard algorithm O(n^2 * t), where t is the current time step (number of measurements). In online applications, t >> n and essentially will go to infinity.\n- The space complexity is O(n^2), which is far more efficient than standard algorithm O(n * t) (t >> n).\n- A weighting factor (in (0, 1]) can be used to place more weight on recent data, thus making the model more adaptive.\n- This local model can be used for short-horizon prediction and data-driven real-time closed loop control.\n- It has been successfully applied to flow separation control problem, and achived real-time closed loop control. See this [paper](https://doi.org/10.1017/jfm.2020.546) for details.\n\n## Online model learning algorithm description\nThis is a brief introduction to the algorithm. For full technical details, see this [paper](https://epubs.siam.org/doi/pdf/10.1137/18M1192329), and chapter 3 and chapter 7 of this [PhD thesis](http://arks.princeton.edu/ark:/88435/dsp0108612r49q).\n\n### Unknown dynamical system\nSuppose we have a (discrete) nonlinear and/or time-varying [dynamical system](https://en.wikipedia.org/wiki/State-space_representation), and the state space representation is\n- x(t+1) = f(t, x(t), u(t))\n- y(t) = g(t, x(t), u(t))\n\nwhere t is (discrete) time, x(t) is state vector, u(t) is control (input) vector, y(t) is observation (output) vector. f(~, ~, ~) and g(~, ~, ~) are unknown vector-valued nonlinear functions.\n\n- It is assumed that we have measurements x(i), u(i), y(i) for i = 0,1,...t. \n- However, we do not know functions f and g. \n- We aim to learn a model for the unknown dynamical system from measurement data up to time t.\n- We want to the model to be updated efficiently in real-time as new measurement data becomes available.\n\n### Online linear model learning\nWe would like to learn an adaptive [linear model](https://en.wikipedia.org/wiki/State-space_representation)\n- x(t+1) = A x(t) + B u(t)\n- y(t) = C x(t) + D u(t)\n\nthat fits/explains the observation optimally. By Taylor expansion approximation, any nonlinear and/or time-varying system is linear locally. There are many powerful tools for linear control, e.g, [Linear Quadratic Regulator](https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator), [Kalman filter](https://en.wikipedia.org/wiki/Kalman_filter). However, to accurately approximate the original (unknown) dynamical system, we need to update this linear model efficiently in real-time whenever new measurement becomes available.\n\nThis problem can be formulated as an optimization problem, and at each time step t we need to solve a related but slightly different optimization problem. The optimal algorithm is achived through efficient reformulation of the problem. \n\n- `oml.OnlineLinearModel` class implements the optimal algorithm.\n\n### Online nonlinear model learning\nIf we need to fit a nonlinear model to the observed data, this algorithm also applies in this case. Keep in mind that linear adaptive model is good approximation as long as it is updated in real-time. Also, the choice of nonlinear form can be tricky. Based on Taylor expansion, if we add higher order nonlinearity (e.g., quadratic, cubic), the approximation can be more accurate. However, given the learned nonlinear model, it is still not easy to apply control.\n\nIn particular, we want to fit a nonlinear model of this form\n- x(t+1) = F * phi(x(t), u(t))\n- y(t) = G * psi(x(t), u(t))\n\nwhere phi(~, ~) and psi(~, ~) are known vector-valued nonlinear functions (e.g, quadratic) that we specify, F and G are unknown matrices of proper size. \n\n- We aim to learn F and G from measurement data. \n- Notice that this model form is general, and encompass many systems such as Lorenze attractor, Logistic map, Auto-regressive model, polynomial systems.\n- F and G can be updated efficiently in real-time when new data comes in.\n\nThis can also be formulated as the same optimization problem, and the same efficient algorithm works in this case.\n\n- `oml.OnlineModel` class implements the optimal algorithm.\n\n## Use\n### Install\nFrom PyPi\n```\npip install ai4s.oml --upgrade\n```\n\nFrom source\n```\ngit clone https://github.com/haozhg/oml.git\ncd oml/\npip install -e .\n```\n\n### Tests\n```\ncd oml/\npython -m pytest .\n```\n\n### Demo\nSee `./demo` for python notebook to demo the algorithm for data-driven real-time closed loop control.\n- `demo_lorenz.ipynb` shows control of [Lorenz attractor](https://en.wikipedia.org/wiki/Lorenz_system).\n- `demo_online_linear_model.ipynb` shows control of an unstable linear time-varying system.\n\n## Authors:\nHao Zhang \n\n## Reference\nIf you you used these algorithms or this python package in your work, please consider citing\n\n```\nZhang, Hao, Clarence W. Rowley, Eric A. Deem, and Louis N. Cattafesta. \n\"Online dynamic mode decomposition for time-varying systems.\" \nSIAM Journal on Applied Dynamical Systems 18, no. 3 (2019): 1586-1609.\n```\n\nBibTeX\n```\n@article{zhang2019online,\n title={Online dynamic mode decomposition for time-varying systems},\n author={Zhang, Hao and Rowley, Clarence W and Deem, Eric A and Cattafesta, Louis N},\n journal={SIAM Journal on Applied Dynamical Systems},\n volume={18},\n number={3},\n pages={1586--1609},\n year={2019},\n publisher={SIAM}\n}\n```\n\n## Date created\nApril 2017\n\n## License\nMIT\n\nIf you want to use this package, but find license permission an issue, pls contact me at `haozhang at alumni dot princeton dot edu`.\n\n## Issues\nIf there is any comment/suggestion, or if you find any bug, feel free to \n- create an issue [here](https://github.com/haozhg/oml/issues), and/or\n- fork this repo, make suggested changes, and create a pull request (merge from your fork to this repo). See [this](https://numpy.org/devdocs/dev/index.html#development-process-summary) as an example guidance for contribution and PRs.\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/haozhg/oml", "keywords": "machine-learning,AI for Science,data-driven modeling,reduced-order-modeling,dynamical systems,control theory,system identification,online model learning", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ai4s.oml", "package_url": "https://pypi.org/project/ai4s.oml/", "platform": null, "project_url": "https://pypi.org/project/ai4s.oml/", "project_urls": { "Homepage": "https://github.com/haozhg/oml" }, "release_url": "https://pypi.org/project/ai4s.oml/0.2.1/", "requires_dist": [ "numpy" ], "requires_python": ">=3.7", "summary": "Efficient data-driven Online Model Learning (OML) / system identification and control", "version": "0.2.1", "yanked": false, "yanked_reason": null }, "last_serial": 15477373, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "f6a091f087d269921c28989fc85d341e", "sha256": "28105ac2f9e193ad6c5814e66a16160b97a5e5d6e517025ba1c36c6ca44ce306" }, "downloads": -1, "filename": "ai4s.oml-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f6a091f087d269921c28989fc85d341e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10407, "upload_time": "2022-10-20T17:13:54", "upload_time_iso_8601": "2022-10-20T17:13:54.047334Z", "url": "https://files.pythonhosted.org/packages/82/b5/43b92c32be7b1b0c7fdc824c2e8c14c2773c6b05cd4e7405115caf9e9191/ai4s.oml-0.2.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "b942dad52c7d2b9b71193a316c93d50b", "sha256": "edd7306f300e628220d79311e5608cc44b7d6d1d659a2083f376273e34a928ef" }, "downloads": -1, "filename": "ai4s.oml-0.2.0.tar.gz", "has_sig": false, "md5_digest": "b942dad52c7d2b9b71193a316c93d50b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 8888, "upload_time": "2022-10-20T17:13:56", "upload_time_iso_8601": "2022-10-20T17:13:56.019191Z", "url": "https://files.pythonhosted.org/packages/0f/7a/f7189072cb6b9d079dae2175c8234a968fae75b2bbff00dd2408138508d2/ai4s.oml-0.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9399481f46abe4277592f4ad9578a6a3", "sha256": "ac303dff3623f001486486082ad62d5e9d3c3d19ed37eeeca2b6de32d74ba21d" }, "downloads": -1, "filename": "ai4s.oml-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9399481f46abe4277592f4ad9578a6a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10430, "upload_time": "2022-10-20T17:44:34", "upload_time_iso_8601": "2022-10-20T17:44:34.828582Z", "url": "https://files.pythonhosted.org/packages/21/63/0b045bd46a7190b318c18730cb08249448273e6833e221efa554742e1b45/ai4s.oml-0.2.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "b8a7ac651c560fac129945c7d64678db", "sha256": "245df5bd7122308d0132512af11aa12e459553448a3a16b1ee27b681d3a264ab" }, "downloads": -1, "filename": "ai4s.oml-0.2.1.tar.gz", "has_sig": false, "md5_digest": "b8a7ac651c560fac129945c7d64678db", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 8930, "upload_time": "2022-10-20T17:44:36", "upload_time_iso_8601": "2022-10-20T17:44:36.781583Z", "url": "https://files.pythonhosted.org/packages/e1/47/bab97aa016528052d52e4b10c86c9549b08ffe8f17d1feb88fab7f09cfc6/ai4s.oml-0.2.1.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9399481f46abe4277592f4ad9578a6a3", "sha256": "ac303dff3623f001486486082ad62d5e9d3c3d19ed37eeeca2b6de32d74ba21d" }, "downloads": -1, "filename": "ai4s.oml-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9399481f46abe4277592f4ad9578a6a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10430, "upload_time": "2022-10-20T17:44:34", "upload_time_iso_8601": "2022-10-20T17:44:34.828582Z", "url": "https://files.pythonhosted.org/packages/21/63/0b045bd46a7190b318c18730cb08249448273e6833e221efa554742e1b45/ai4s.oml-0.2.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "b8a7ac651c560fac129945c7d64678db", "sha256": "245df5bd7122308d0132512af11aa12e459553448a3a16b1ee27b681d3a264ab" }, "downloads": -1, "filename": "ai4s.oml-0.2.1.tar.gz", "has_sig": false, "md5_digest": "b8a7ac651c560fac129945c7d64678db", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 8930, "upload_time": "2022-10-20T17:44:36", "upload_time_iso_8601": "2022-10-20T17:44:36.781583Z", "url": "https://files.pythonhosted.org/packages/e1/47/bab97aa016528052d52e4b10c86c9549b08ffe8f17d1feb88fab7f09cfc6/ai4s.oml-0.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }