Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ Our code is released under the MIT license (refer to the [LICENSE](https://githu

## Requirements

To run the library you need atleast Python 3.5.
To run the library you need at least Python 3.5.

Other dependencies:
- NumPy (1.19.5)
- SciPy (1.6.0)
- NumPy
- SciPy

## Installation

- Install from source: git clone this repo and from the root folder execute the command ```pip install .```
- Install with modern Python tooling: ```uv sync``` (requires [uv](https://github.com/astral-sh/uv))

## Usage/Examples

You can import the library by typing ```python import vrft``` in your code.

To learn how to use the library, check the examples located in the examples/ folder. At the moment there are examples available.
To learn how to use the library, check the examples located in the examples/ folder. At the moment there are examples available.
Check example3 to see usage of instrumental variables.

In general the code has the following structure
Expand Down Expand Up @@ -73,7 +74,7 @@ theta, _, _, C = compute_vrft(data, ref_model, control, pre_filter)
To execute tests run the following command from the root folder of the repo
```sh
python -m unittest
```
```

## Changelog

Expand All @@ -97,4 +98,3 @@ If you find this code useful in your research, please, consider citing it:
>}

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "pythonvrft"
version = "0.0.7"
description = "VRFT Python Library"
readme = "README.md"
keywords = ["VRFT", "Virtual Reference Feedback Tuning", "Data Driven Control", "Adaptive Control"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.5"
dependencies = [
"scipy",
"numpy",
]

[[project.authors]]
name = "Alessio Russo"
email = "alessior@kth.se"

[project.urls]
Homepage = "https://github.com/rssalessio/PythonVRFT/"

[project.license]
text = "GPL3"

[project.optional-dependencies]
test = ["pytest"]

[dependency-groups]
dev = [
"pytest"
]

[tool.setuptools.packages.find]
include = ["vrft", "test"]
35 changes: 0 additions & 35 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_deconvolve(self):
data = iddata(y, u, t_step, [0])
r1, _ = virtual_reference(data, sys.num, sys.den)
r2 = deconvolve_signal(sys, data.y)
self.assertTrue(np.linalg.norm(r2-r1[:r2.size], np.infty) < 1e-3)
self.assertTrue(np.linalg.norm(r2-r1[:r2.size], np.inf) < 1e-3)


def test_check_system(self):
Expand Down
10 changes: 5 additions & 5 deletions test/test_vrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_vrft(self):

expected_theta = np.array([1.93220784, -1.05808206, 1.26623764, 0.0088772])
expected_loss = 0.00064687904235295

for t_end in t_ends:
t = np.arange(t_start, t_end, t_step)
u = np.ones(len(t)).tolist()
Expand All @@ -50,20 +50,20 @@ def test_vrft(self):
theta1, _, loss1, _ = compute_vrft(data, refModel, control, prefilter)
theta2, _, loss2, _ = compute_vrft([data], refModel, control, prefilter)
theta3, _, loss3, _ = compute_vrft([data, data], refModel, control, prefilter)

self.assertTrue(np.isclose(loss1, loss2))
self.assertTrue(np.isclose(loss1, loss3))
self.assertTrue(np.linalg.norm(theta1-theta2)<1e-15)
self.assertTrue(np.linalg.norm(theta1-theta3)<1e-15)
self.assertTrue(np.linalg.norm(theta1-expected_theta, np.infty) < 1e-5)
self.assertTrue(np.linalg.norm(theta1-expected_theta, np.inf) < 1e-5)
self.assertTrue(abs(expected_loss - loss1) < 1e-5)

def test_iv(self):
t_start = 0
t_step = 1e-2
t_ends = [10, 10 + t_step]


for t_end in t_ends:
t = np.arange(t_start, t_end, t_step)
u = np.ones(len(t)).tolist()
Expand All @@ -78,7 +78,7 @@ def test_iv(self):
_, y = scipysig.dlsim(sys, u, t)
y = y.flatten() + 1e-2 * np.random.normal(size=t.size)
data2 = iddata(y,u,t_step,[0])


refModel = ExtendedTF([0.2], [1, -0.8], dt=t_step)
prefilter = refModel * (1-refModel)
Expand Down
Loading