Skip to content

Commit 5eb1bd0

Browse files
committed
Remove billiard walk keep only accelerated billiard, enhance volume tests, fix typos
1 parent f733c7e commit 5eb1bd0

10 files changed

Lines changed: 40 additions & 41 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if(NOT Eigen3_FOUND)
4646
endif()
4747

4848
# ─── Find Boost ──────────────────────────────────────────────────────────────
49-
# volesti only needs Boost headers (random, math) no compiled libraries required
49+
# volesti only needs Boost headers (random, math) - no compiled libraries required
5050
find_package(Boost 1.56 REQUIRED)
5151
if(NOT Boost_FOUND)
5252
# Fallback: locate headers manually

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ a high-performance library for **volume approximation** and **sampling** of conv
3535
| Boost | ≥ 1.56 (headers + `random`, `math`) |
3636

3737
Optional:
38-
* **LP-solve 5.5** needed for VPolytope inner ball computation (otherwise auto-disabled)
38+
* **LP-solve 5.5** - needed for VPolytope inner ball computation (otherwise auto-disabled)
3939

4040
---
4141

@@ -237,7 +237,7 @@ volestipy/
237237
├── pyproject.toml
238238
├── README.md
239239
├── external/
240-
│ └── volesti/ # git submodule volesti library
240+
│ └── volesti/ # git submodule - volesti library
241241
├── src/
242242
│ └── bindings/
243243
│ └── volesti_bindings.cpp # pybind11 binding definitions
@@ -257,15 +257,15 @@ volestipy/
257257

258258
## Relationship to Other Projects
259259

260-
* **[volesti](https://github.com/GeomScale/volesti)** the underlying C++ library
261-
* **[dingo](https://github.com/GeomScale/dingo)** metabolic network analysis using volesti
262-
* **volestipy** a standalone, general-purpose Python binding via pybind11
260+
* **[volesti](https://github.com/GeomScale/volesti)** - the underlying C++ library
261+
* **[dingo](https://github.com/GeomScale/dingo)** - metabolic network analysis using volesti
262+
* **volestipy** - a standalone, general-purpose Python binding via pybind11
263263

264264
---
265265

266266
## License
267267

268268
GNU Lesser General Public License v3.0 — see [LICENSE](LICENSE).
269269

270-
Copyright (c) 20122024 Vissarion Fisikopoulos, Apostolos Chalkis, Elias Tsigaridas
270+
Copyright (c) 2012-2024 Vissarion Fisikopoulos, Apostolos Chalkis, Elias Tsigaridas
271271
and contributors.

examples/example_hypercube.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
def main():
1919
print("=" * 60)
20-
print("volestipy hypercube example")
20+
print("volestipy - hypercube example")
2121
print("=" * 60)
2222

2323
# ------------------------------------------------------------------
2424
# 1. Build the 4-D hypercube [-1, 1]^4
2525
# ------------------------------------------------------------------
26-
d = 10
26+
d = 40
2727
P = hypercube(d)
2828
print(f"\nPolytope: {P}")
2929
center, radius = P.compute_inner_ball()

examples/example_random_polytope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def random_hpoly(d: int, m: int, seed: int = 0) -> HPolytope:
3232

3333
def main():
3434
print("=" * 60)
35-
print("volestipy random polytope example")
35+
print("volestipy - random polytope example")
3636
print("=" * 60)
3737

3838
d = 5 # dimension

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
setup.py for volestipy Python bindings for the volesti library.
2+
setup.py for volestipy - Python bindings for the volesti library.
33
44
Build:
55
pip install . --no-build-isolation
@@ -98,7 +98,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
9898
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
9999
"Programming Language :: Python :: 3",
100100
"Programming Language :: C++",
101-
"Topic :: Scientific/Engineering :: Mathematics",
101+
"Topic :: Scientific/Engineering :: Mathematics :: Optimization",
102102
],
103103
zip_safe=False,
104104
)

src/bindings/volesti_bindings.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,10 @@ MatrixXd hpoly_uniform_sample(HPolytopeType& P,
128128
uniform_sampling<BallWalk>(randPoints, P, rng,
129129
walk_length, n_samples,
130130
starting_point, n_burns);
131-
} else if (walk_type == "billiard" || walk_type == "BilliardWalk") {
131+
} else if (walk_type == "billiard" || walk_type == "AcceleratedBilliardWalk") {
132132
uniform_sampling<BilliardWalk>(randPoints, P, rng,
133133
walk_length, n_samples,
134134
starting_point, n_burns);
135-
} else if (walk_type == "accelerated_billiard" || walk_type == "AcceleratedBilliardWalk") {
136-
uniform_sampling<AcceleratedBilliardWalk>(randPoints, P, rng,
137-
walk_length, n_samples,
138-
starting_point, n_burns);
139135
} else if (walk_type == "dikin" || walk_type == "DikinWalk") {
140136
uniform_sampling<DikinWalk>(randPoints, P, rng,
141137
walk_length, n_samples,
@@ -151,7 +147,7 @@ MatrixXd hpoly_uniform_sample(HPolytopeType& P,
151147
} else {
152148
throw std::invalid_argument("Unknown walk type: '" + walk_type +
153149
"'. Choose from: cdhr, rdhr, ball_walk, billiard, "
154-
"accelerated_billiard, dikin, john, vaidya.");
150+
"dikin, john, vaidya.");
155151
}
156152

157153
return points_to_matrix(randPoints);
@@ -492,7 +488,7 @@ PYBIND11_MODULE(_volestipy, m) {
492488
Number of burn-in steps.
493489
walk_type : str
494490
Walk algorithm. One of: 'cdhr', 'rdhr', 'ball_walk',
495-
'billiard', 'accelerated_billiard', 'dikin', 'john', 'vaidya'.
491+
'billiard', 'dikin', 'john', 'vaidya'.
496492
seed : int
497493
Random seed.
498494

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# conftest.py shared pytest fixtures for volestipy tests
1+
# conftest.py - shared pytest fixtures for volestipy tests
22
import pytest
33
import numpy as np
44

tests/test_hpolytope.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests for volestipy.HPolytope construction, membership, sampling, volume.
2+
Tests for volestipy.HPolytope - construction, membership, sampling, volume.
33
"""
44
import math
55
import numpy as np
@@ -168,9 +168,9 @@ def test_invalid_walk_type(self):
168168
with pytest.raises((RuntimeError, ValueError, Exception)):
169169
P.sample(walk_type="unknown_walk_xyz")
170170

171-
def test_accelerated_billiard(self):
171+
def test_billiard(self):
172172
P = make_cube_hpoly(4)
173-
samples = P.sample(n_samples=50, walk_type="accelerated_billiard", seed=0)
173+
samples = P.sample(n_samples=50, walk_type="billiard", seed=0)
174174
assert samples.shape == (4, 50)
175175

176176
@pytest.mark.parametrize("walk_type", ["dikin", "john", "vaidya"])

tests/test_vpolytope.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests for volestipy.VPolytope construction, membership, sampling, volume.
2+
Tests for volestipy.VPolytope - construction, membership, sampling, volume.
33
"""
44
import math
55
import numpy as np
@@ -105,7 +105,7 @@ def test_inner_ball_simplex(self):
105105
# ── Sampling tests ────────────────────────────────────────────────────────────
106106

107107
class TestVPolytopeUniformSampling:
108-
@pytest.mark.parametrize("walk_type", ["cdhr", "rdhr", "ball_walk"])
108+
@pytest.mark.parametrize("walk_type", ["cdhr", "rdhr", "ball_walk", "billiard"])
109109
def test_sample_shape(self, walk_type):
110110
P = make_simplex_vpoly(3)
111111
samples = P.sample(n_samples=100, walk_type=walk_type, seed=42)
@@ -135,21 +135,25 @@ def test_sample_inside_square(self):
135135
# ── Volume tests ──────────────────────────────────────────────────────────────
136136

137137
class TestVPolytopeVolume:
138-
def test_simplex_volume_2d(self):
138+
#cooling_gaussians not applicable to V-polytopes
139+
@pytest.mark.parametrize("volume_algo", ["cooling_balls", "sequence_of_balls"])
140+
def test_simplex_volume_2d(self, volume_algo):
139141
# Vol(triangle with vertices (0,0),(1,0),(0,1)) = 0.5
140142
V = np.array([[0., 0.], [1., 0.], [0., 1.]])
141143
P = VPolytope(V)
142-
vol = P.volume(error=0.3, algorithm="cooling_balls")
144+
vol = P.volume(error=0.3, algorithm=volume_algo)
143145
expected = 0.5
144146
assert abs(vol - expected) / expected < 1.0, f"vol={vol:.4f}"
145147

146-
def test_square_volume(self):
148+
@pytest.mark.parametrize("volume_algo", ["cooling_balls", "sequence_of_balls"])
149+
def test_square_volume(self, volume_algo):
147150
P = make_cube_vpoly_2d()
148-
vol = P.volume(error=0.3, algorithm="cooling_balls")
151+
vol = P.volume(error=0.3, algorithm=volume_algo)
149152
expected = 4.0 # 2x2 square
150153
assert abs(vol - expected) / expected < 0.5, f"vol={vol:.3f}"
151154

152-
def test_volume_positive(self):
155+
@pytest.mark.parametrize("volume_algo", ["cooling_balls", "sequence_of_balls"])
156+
def test_volume_positive(self, volume_algo):
153157
P = make_simplex_vpoly(3)
154-
vol = P.volume(error=0.3)
158+
vol = P.volume(error=0.3, algorithm=volume_algo)
155159
assert vol > 0

volestipy/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
volestipy Python bindings for the volesti C++ library.
2+
volestipy - Python bindings for the volesti C++ library.
33
44
This module re-exports the C++ pybind11 extension and adds
55
convenient Python-level wrappers and utilities.
@@ -74,7 +74,7 @@ class HPolytope:
7474
"""
7575
H-Polytope: a convex polytope in half-space representation.
7676
77-
P = { x ∈ ^d : A x ≤ b }
77+
P = { x ∈ R^d : A x ≤ b }
7878
7979
Parameters
8080
----------
@@ -174,14 +174,13 @@ def sample(
174174
walk_type : str
175175
MCMC walk type. Supported options:
176176
177-
* ``'cdhr'`` – Coordinate Directions Hit-and-Run (default)
178-
* ``'rdhr'`` – Random Directions Hit-and-Run
179-
* ``'ball_walk'`` – Ball Walk
180-
* ``'billiard'`` – Billiard Walk
181-
* ``'accelerated_billiard'`` – Accelerated Billiard Walk
182-
* ``'dikin'`` – Dikin Walk
183-
* ``'john'`` – John Walk
184-
* ``'vaidya'`` – Vaidya Walk
177+
* ``'cdhr'`` - Coordinate Directions Hit-and-Run (default)
178+
* ``'rdhr'`` - Random Directions Hit-and-Run
179+
* ``'ball_walk'`` - Ball Walk
180+
* ``'billiard'`` - Billiard Walk (Accelerated Billiard Walk)
181+
* ``'dikin'`` - Dikin Walk
182+
* ``'john'`` - John Walk
183+
* ``'vaidya'`` - Vaidya Walk
185184
seed : int
186185
Random number generator seed.
187186

0 commit comments

Comments
 (0)