Comparison with other methods

Each polytope metric of pycapacity belongs to one of three families of problems, and each family has a dedicated algorithm. This page compares them with the general methods that are usually used instead: the convex hull (Qhull), the double description method (DDM, pycddlib) and the Bretl and Lall projection (pypoman).

Problem

Metrics

pycapacity

Usual alternatives

\(P=\{x ~|~ x=By,~ y_{min} \leq y \leq y_{max}\}\)

robot velocity and acceleration, human acceleration

HPSM

convex hull of the images of the \(2^n\) vertices of the box

\(P=\{x ~|~ y_{min} \leq Ax \leq y_{max}\}\)

robot force, force sum and intersection

VEPOLI2

\(\mathcal{H}\)-representation, then vertex enumeration (Qhull or DDM)

\(P=\{x ~|~ Ax=By,~ y_{min} \leq y \leq y_{max}\}\)

human force and velocity, robot reachable space

ICHM

projection: Bretl and Lall (2D only), DDM on the lifted polytope

All the methods were checked to return the same polytopes (the ICHM within its tolerance). Times are in ms, measured on an Intel i7-12850HX with Python 3.11, wall clock including the Python call. The C++ column is the optional compiled package pycapacity-cpp (see C++ acceleration).

HPSM

Random \(B \in \mathbb{R}^{m \times n}\), median time. The convex hull computes the images of all the \(2^n\) vertices of the box and their hull with Qhull.

\((m, n)\)

facets

HPSM (Python)

HPSM (C++)

\(2^n\) vertices + Qhull

(3, 7)

42

1.03

0.024

0.17

(3, 12)

132

3.24

0.053

2.49

(3, 16)

240

6.10

0.090

41.0

(3, 20)

380

9.84

0.146

786

(6, 7)

42

1.13

0.075

13.5

(6, 12)

1584

56.6

2.30

1187

The number of vertices of the box grows as \(2^n\), while the HPSM only looks at the combinations of \(m-1\) columns of \(B\).

VEPOLI2

Random \(A \in \mathbb{R}^{n \times m}\) on the sizes of the original VEPOLI2 paper, mean \(\pm\) std. (max) over 1000 systems per size. The alternatives first build the \(\mathcal{H}\)-representation and then enumerate its vertices with Qhull (halfspace intersection) or with the DDM (pycddlib). \(\bar N_v\) is the mean number of vertices.

\((n, m)\)

\(\bar N_v\)

VEPOLI2 (Python)

VEPOLI2 (C++)

\(\mathcal{H}\) + Qhull

\(\mathcal{H}\) + DDM

(4, 2)

5.0

0.50 \(\pm\) 0.07 (1.06)

0.025 \(\pm\) 0.002 (0.045)

0.22 \(\pm\) 0.01 (0.37)

0.11 \(\pm\) 0.04 (1.35)

(4, 3)

10.3

0.45 \(\pm\) 0.06 (0.55)

0.026 \(\pm\) 0.001 (0.032)

0.28 \(\pm\) 0.01 (0.31)

0.13 \(\pm\) 0.01 (0.16)

(6, 3)

13.8

1.30 \(\pm\) 0.21 (1.70)

0.051 \(\pm\) 0.006 (0.067)

0.31 \(\pm\) 0.02 (0.36)

0.19 \(\pm\) 0.02 (0.26)

(6, 6)

64.0

0.44 \(\pm\) 0.02 (0.54)

0.043 \(\pm\) 0.004 (0.058)

4.66 \(\pm\) 0.31 (5.70)

0.35 \(\pm\) 0.01 (0.44)

(7, 3)

14.7

2.11 \(\pm\) 0.38 (2.73)

0.068 \(\pm\) 0.011 (0.093)

0.31 \(\pm\) 0.02 (0.38)

0.21 \(\pm\) 0.02 (0.29)

(7, 6)

105.4

0.91 \(\pm\) 0.07 (1.07)

0.085 \(\pm\) 0.010 (0.113)

10.4 \(\pm\) 4.8 (97.9)

0.61 \(\pm\) 0.06 (0.77)

On these small problems the DDM is faster than the Python VEPOLI2, and the C++ VEPOLI2 is 3 to 8 times faster than the DDM.

ICHM

Human-like models: \(m\) output dimensions, 7 joints and \(n\) muscles in antagonist pairs, 5 models per size, median time. The ICHM tolerance is relative to the size of the polytope; at \(10^{-6}\) the result is exact up to the precision of the linear programs.

2D (the only case pypoman’s Bretl and Lall projection supports), tolerance \(10^{-6}\):

\(n\)

vertices

ICHM (Python)

ICHM (C++)

Bretl and Lall

10

14

2.0

0.15

7.9

20

56

12.3

0.48

23.2

50

174

120

2.1

159

100

354

754

6.3

923

200

637

4878

19.2

6303

3D, tolerance \(10^{-3}\) and \(10^{-6}\):

\(n\)

ICHM (Python), \(10^{-3}\)

ICHM (C++), \(10^{-3}\)

ICHM (Python), \(10^{-6}\)

ICHM (C++), \(10^{-6}\)

10

4.8

0.41

6.7

0.93

20

68.6

3.3

143

13.6

50

795

17.8

5095

198

100

3350

41.6

72186

1131

200

18451

123

not run

5688

The DDM on the lifted polytope (exact) takes 6 ms in 2D and 7 ms in 3D at \(n=10\), 0.9 s and 2.5 s at \(n=16\), and more than 60 s from \(n=20\).

The linear programs of the ICHM all share the same constraints, so the C++ version solves them with a small simplex that keeps its basis from one to the next; this is where most of its speed comes from. See C++ acceleration for details, and Polytope evaluation algorithms for the description of the three algorithms.