\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- `ai4sci.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- `ai4sci.oml.OnlineModel` class implements the optimal algorithm.\n\n## Use\n### Install\nFrom PyPi\n```\npip install ai4sci.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 tests/\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": "ai4sci.oml", "package_url": "https://pypi.org/project/ai4sci.oml/", "platform": null, "project_url": "https://pypi.org/project/ai4sci.oml/", "project_urls": { "Homepage": "https://github.com/haozhg/oml" }, "release_url": "https://pypi.org/project/ai4sci.oml/0.2.2/", "requires_dist": [ "numpy" ], "requires_python": ">=3.7", "summary": "AI4Science: Efficient data-driven Online Model Learning (OML) / system identification and control", "version": "0.2.2", "yanked": false, "yanked_reason": null }, "last_serial": 15480258, "releases": { "0.2.2": [ { "comment_text": "", "digests": { "md5": "9d77f8638ddfb261465e10c420818171", "sha256": "3a3ae09560cef14338c62774466ad0027bcc43d691486be1623cd260ca00a945" }, "downloads": -1, "filename": "ai4sci.oml-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9d77f8638ddfb261465e10c420818171", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10532, "upload_time": "2022-10-20T22:39:14", "upload_time_iso_8601": "2022-10-20T22:39:14.112482Z", "url": "https://files.pythonhosted.org/packages/d9/f2/b0a7063393eb32485cf4e978f7bad0a23c4e85b34d007fe9bfc3de698545/ai4sci.oml-0.2.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "4c10062ba41db0fd0683658984a2bd19", "sha256": "a8a233dfdb15a13433b3e0ce988b16594d53b609c4b6de6b84cb3b2a4c86edb3" }, "downloads": -1, "filename": "ai4sci.oml-0.2.2.tar.gz", "has_sig": false, "md5_digest": "4c10062ba41db0fd0683658984a2bd19", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 11491, "upload_time": "2022-10-20T22:39:16", "upload_time_iso_8601": "2022-10-20T22:39:16.382483Z", "url": "https://files.pythonhosted.org/packages/28/1c/7e112bcfbf383d7a78a9699369fb1aa47888af7e6060b362e42277c450d1/ai4sci.oml-0.2.2.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9d77f8638ddfb261465e10c420818171", "sha256": "3a3ae09560cef14338c62774466ad0027bcc43d691486be1623cd260ca00a945" }, "downloads": -1, "filename": "ai4sci.oml-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9d77f8638ddfb261465e10c420818171", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 10532, "upload_time": "2022-10-20T22:39:14", "upload_time_iso_8601": "2022-10-20T22:39:14.112482Z", "url": "https://files.pythonhosted.org/packages/d9/f2/b0a7063393eb32485cf4e978f7bad0a23c4e85b34d007fe9bfc3de698545/ai4sci.oml-0.2.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "4c10062ba41db0fd0683658984a2bd19", "sha256": "a8a233dfdb15a13433b3e0ce988b16594d53b609c4b6de6b84cb3b2a4c86edb3" }, "downloads": -1, "filename": "ai4sci.oml-0.2.2.tar.gz", "has_sig": false, "md5_digest": "4c10062ba41db0fd0683658984a2bd19", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 11491, "upload_time": "2022-10-20T22:39:16", "upload_time_iso_8601": "2022-10-20T22:39:16.382483Z", "url": "https://files.pythonhosted.org/packages/28/1c/7e112bcfbf383d7a78a9699369fb1aa47888af7e6060b362e42277c450d1/ai4sci.oml-0.2.2.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }