|
27 | 27 | from .quantum_tools import (apply_inflation_symmetries, |
28 | 28 | calculate_momentmatrix_1d_internal, |
29 | 29 | construct_normalization_eqs, |
30 | | - flatten_symbolic_powers, |
31 | | - generate_operators |
| 30 | + flatten_symbolic_powers |
32 | 31 | ) |
33 | 32 | from .sdp_utils import solveSDP_MosekFUSION |
34 | 33 | from .writer_utils import (write_to_csv, |
@@ -103,11 +102,10 @@ def __init__(self, |
103 | 102 | self.setting_cardinalities = inflationproblem.settings_per_party |
104 | 103 | self._quantum_sources = inflationproblem._nonclassical_sources |
105 | 104 |
|
106 | | - self.measurements = self._generate_parties() |
107 | 105 | if self.verbose > 1: |
108 | 106 | eprint("Number of single operator measurements per party:", end="") |
109 | 107 | prefix = " " |
110 | | - for i, measures in enumerate(self.measurements): |
| 108 | + for i, measures in enumerate(self.InflationProblem.measurements_symbolic): |
111 | 109 | counter = count() |
112 | 110 | deque(zip(chain.from_iterable( |
113 | 111 | chain.from_iterable(measures)), |
@@ -2016,66 +2014,10 @@ def _discover_columns_symmetries(self) -> np.ndarray: |
2016 | 2014 | + f" {permutations_failed} symmetries were not be implemented.") |
2017 | 2015 | return np.unique(discovered_symmetries, axis=0)[1:] |
2018 | 2016 |
|
2019 | | - def _generate_parties(self) -> List[List[List[List[sp.Symbol]]]]: |
2020 | | - """Generates all the party operators in the quantum inflation. |
2021 | | -
|
2022 | | - Returns |
2023 | | - ------- |
2024 | | - List[List[List[List[sympy.Symbol]]]] |
2025 | | - The measurement operators as symbols. The array is indexed as |
2026 | | - measurements[p][c][i][o] for party p, inflation copies c, input i, |
2027 | | - and output o. |
2028 | | - """ |
2029 | | - settings = self.setting_cardinalities |
2030 | | - outcomes = self.outcome_cardinalities |
2031 | | - |
2032 | | - assert len(settings) == len(outcomes), \ |
2033 | | - "There\'s a different number of settings and outcomes" |
2034 | | - assert len(settings) == self.hypergraph.shape[1], \ |
2035 | | - "The hypergraph does not have as many columns as parties" |
2036 | | - measurements = [] |
2037 | | - parties = self.names |
2038 | | - n_states = self.hypergraph.shape[0] |
2039 | | - for pos, [party, ins, outs] in enumerate(zip(parties, |
2040 | | - settings, |
2041 | | - outcomes)): |
2042 | | - party_meas = [] |
2043 | | - # Generate all possible copy indices for a party |
2044 | | - all_inflation_indices = product( |
2045 | | - *[list(range(self.inflation_levels[p_idx])) |
2046 | | - for p_idx in np.flatnonzero(self.hypergraph[:, pos])]) |
2047 | | - # Include zeros in the positions of states not feeding the party |
2048 | | - all_indices = [] |
2049 | | - for inflation_indices in all_inflation_indices: |
2050 | | - indices = [] |
2051 | | - i = 0 |
2052 | | - for idx in range(n_states): |
2053 | | - if self.hypergraph[idx, pos] == 0: |
2054 | | - indices.append("0") |
2055 | | - elif self.hypergraph[idx, pos] == 1: |
2056 | | - # The +1 is just to begin at 1 |
2057 | | - indices.append(str(inflation_indices[i] + 1)) |
2058 | | - i += 1 |
2059 | | - else: |
2060 | | - raise Exception("You don\'t have a proper hypergraph") |
2061 | | - all_indices.append(indices) |
2062 | | - # Generate measurements for every combination of indices. |
2063 | | - # The -1 in outs - 1 is because the use of Collins-Gisin notation |
2064 | | - # (see [arXiv:quant-ph/0306129]), whereby the last operator is |
2065 | | - # understood to be written as the identity minus the rest. |
2066 | | - for indices in all_indices: |
2067 | | - meas = generate_operators( |
2068 | | - [outs - 1 for _ in range(ins)], |
2069 | | - party + "_" + "_".join(indices) |
2070 | | - ) |
2071 | | - party_meas.append(meas) |
2072 | | - measurements.append(party_meas) |
2073 | | - return measurements |
2074 | | - |
2075 | 2017 | ########################################################################### |
2076 | 2018 | # HELPER FUNCTIONS FOR ENSURING CONSISTENCY # |
2077 | 2019 | ########################################################################### |
2078 | | - |
| 2020 | + |
2079 | 2021 | def _cleanup_after_set_values(self) -> None: |
2080 | 2022 | """Helper function to reset or make consistent class attributes after |
2081 | 2023 | setting values.""" |
|
0 commit comments