|
11 | 11 | """ |
12 | 12 | import numpy as np |
13 | 13 | import scipy.spatial |
14 | | -from numba import jit, guvectorize |
| 14 | +from numba import jit, guvectorize, types |
| 15 | +from numba.typed import Dict |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def vertex_enumeration(g, qhull_options=None): |
@@ -109,18 +110,26 @@ def _vertex_enumeration_gen(labelings_bits_tup, equations_tup, trans_recips): |
109 | 110 | ZERO_LABELING0_BITS = (np.uint64(1) << np.uint64(m)) - np.uint64(1) |
110 | 111 | COMPLETE_LABELING_BITS = (np.uint64(1) << np.uint64(m+n)) - np.uint64(1) |
111 | 112 |
|
| 113 | + labelings_bits_dict1 = Dict.empty(key_type=types.uint64, |
| 114 | + value_type=types.intp) |
| 115 | + for j in range(num_vertices1): |
| 116 | + labelings_bits_dict1[labelings_bits_tup[1][j]] = j |
| 117 | + |
112 | 118 | for i in range(num_vertices0): |
113 | | - if labelings_bits_tup[0][i] == ZERO_LABELING0_BITS: |
| 119 | + bits0 = labelings_bits_tup[0][i] |
| 120 | + if bits0 == ZERO_LABELING0_BITS: |
| 121 | + continue |
| 122 | + complement0 = bits0 ^ COMPLETE_LABELING_BITS |
| 123 | + try: |
| 124 | + j = labelings_bits_dict1[complement0] |
| 125 | + except Exception: |
114 | 126 | continue |
115 | | - for j in range(num_vertices1): |
116 | | - xor = labelings_bits_tup[0][i] ^ labelings_bits_tup[1][j] |
117 | | - if xor == COMPLETE_LABELING_BITS: |
118 | | - yield _get_mixed_actions( |
119 | | - labelings_bits_tup[0][i], |
120 | | - (equations_tup[0][i], equations_tup[1][j]), |
121 | | - trans_recips |
122 | | - ) |
123 | | - break |
| 127 | + |
| 128 | + yield _get_mixed_actions( |
| 129 | + bits0, |
| 130 | + (equations_tup[0][i], equations_tup[1][j]), |
| 131 | + trans_recips |
| 132 | + ) |
124 | 133 |
|
125 | 134 |
|
126 | 135 | class _BestResponsePolytope: |
|
0 commit comments