Skip to content

Commit 176db0e

Browse files
Merge pull request #70 from machines-in-motion/main
Merge main into devel
2 parents a05b31f + 1094db8 commit 176db0e

File tree

4 files changed

+52
-36
lines changed

4 files changed

+52
-36
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ jobs:
2121
runs-on: "ubuntu-latest"
2222
strategy:
2323
matrix:
24-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
24+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2525
steps:
26-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v5
2727
with:
2828
submodules: 'true'
29-
- uses: actions/setup-python@v5
29+
- uses: actions/setup-python@v6
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232
- run: python -m pip install crocoddyl[build] proxsuite[build]
3333
- run: echo "CMAKE_PREFIX_PATH=$(cmeel cmake)" >> $GITHUB_ENV
3434
- run: cmake -B build -S .
3535
- run: cmake --build build -j 4
3636

37-
- run: python -m pip install osqp
37+
- run: python -m pip install "osqp<1.0.0"
3838
- run: echo "LD_LIBRARY_PATH=$(cmeel lib)" >> $GITHUB_ENV
3939
- run: cmake --build build -t test

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
os: [ubuntu, macos]
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222
- uses: cachix/install-nix-action@v31
2323
- uses: cachix/cachix-action@v16
2424
with:

.github/workflows/update-flake-lock.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414
- name: Install Nix
1515
uses: DeterminateSystems/nix-installer-action@main
1616
- name: Update flake.lock

tests/python/test_clqr_osqp.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pathlib
1313

1414
import numpy as np
15+
import unittest
1516

1617
python_path = pathlib.Path(".").absolute().parent.parent / "python"
1718
os.sys.path.insert(1, str(python_path))
@@ -23,34 +24,49 @@
2324

2425
print(" TEST OSQP ".center(LINE_WIDTH, "-"))
2526

26-
problem, xs_init, us_init = create_clqr_problem()
2727

28-
ddp1 = CSQP(problem, "CustomOSQP")
29-
ddp2 = CSQP(problem, "OSQP")
30-
31-
ddp1.with_callbacks = True
32-
ddp2.with_callbacks = True
33-
34-
max_qp_iters = 10000
35-
ddp1.max_qp_iters = max_qp_iters
36-
ddp2.max_qp_iters = max_qp_iters
37-
38-
eps_abs = 1e-8
39-
eps_rel = 0.0
40-
ddp1.eps_abs = eps_abs
41-
ddp2.eps_abs = eps_abs
42-
43-
converged = ddp1.solve(xs_init, us_init, 1)
44-
converged = ddp2.solve(xs_init, us_init, 1)
45-
46-
47-
assert ddp1.qp_iters == ddp2.qp_iters
48-
49-
set_tol = 1e-8
50-
assert np.linalg.norm(np.array(ddp1.xs) - np.array(ddp2.xs)) < set_tol, "Test failed"
51-
assert np.linalg.norm(np.array(ddp1.us) - np.array(ddp2.us)) < set_tol, "Test failed"
52-
assert np.linalg.norm(np.array(ddp1.lag_mul) - np.array(ddp2.lag_mul)) < set_tol, (
53-
"Test failed"
54-
)
55-
for t in range(len(ddp1.y)):
56-
assert np.linalg.norm(ddp1.y[t] - ddp2.y[t]) < set_tol, "Test failed"
28+
class TestCLQROSQP(unittest.TestCase):
29+
def setUp(self):
30+
self.problem, self.xs_init, self.us_init = create_clqr_problem()
31+
self.ddp1 = CSQP(self.problem, "CustomOSQP")
32+
self.ddp2 = CSQP(self.problem, "OSQP")
33+
self.ddp1.with_callbacks = True
34+
self.ddp2.with_callbacks = True
35+
max_qp_iters = 10000
36+
self.ddp1.max_qp_iters = max_qp_iters
37+
self.ddp2.max_qp_iters = max_qp_iters
38+
eps_abs = 1e-8
39+
self.ddp1.eps_abs = eps_abs
40+
self.ddp2.eps_abs = eps_abs
41+
42+
# @unittest.skip("Skipping this test as it seems that the \"OSQP\" solver does not converge as of 12/09/2025.")
43+
def test_osqp_match(self):
44+
self.ddp1.solve(self.xs_init, self.us_init, 1)
45+
self.ddp2.solve(self.xs_init, self.us_init, 1)
46+
set_tol = 1e-8
47+
self.assertEqual(self.ddp1.qp_iters, self.ddp2.qp_iters)
48+
self.assertTrue(
49+
np.linalg.norm(np.array(self.ddp1.xs) -
50+
np.array(self.ddp2.xs)) < set_tol,
51+
"Test failed: xs mismatch",
52+
)
53+
self.assertTrue(
54+
np.linalg.norm(np.array(self.ddp1.us) -
55+
np.array(self.ddp2.us)) < set_tol,
56+
"Test failed: us mismatch",
57+
)
58+
self.assertTrue(
59+
np.linalg.norm(np.array(self.ddp1.lag_mul) -
60+
np.array(self.ddp2.lag_mul))
61+
< set_tol,
62+
"Test failed: lag_mul mismatch",
63+
)
64+
for t in range(len(self.ddp1.y)):
65+
self.assertTrue(
66+
np.linalg.norm(self.ddp1.y[t] - self.ddp2.y[t]) < set_tol,
67+
f"Test failed: y mismatch at t={t}",
68+
)
69+
70+
71+
if __name__ == "__main__":
72+
unittest.main()

0 commit comments

Comments
 (0)