InflationProblem Class
- class inflation.InflationProblem(dag: Dict | None = None, outcomes_per_party: Tuple[int, ...] | List[int] | ndarray = (), settings_per_party: Tuple[int, ...] | List[int] | ndarray = (), inflation_level_per_source: Tuple[int, ...] | List[int] | ndarray = (), classical_sources: str | Tuple[str, ...] | List[str] | None = (), nonclassical_intermediate_latents: Tuple[str, ...] | List[str] = (), classical_intermediate_latents: Tuple[str, ...] | List[str] = (), order: Tuple[str, ...] | List[str] = (), verbose=0)[source]
Class for encoding relevant details concerning the causal compatibility.
- discover_lexorder_symmetries() ndarray [source]
Calculates all the symmetries pertaining to the set of generating monomials. The new set of operators is a permutation of the old. The function outputs a list of all permutations.
- Returns:
The permutations of the lexicographic order implied by the inflation symmetries.
- Return type:
numpy.ndarray[int]
- factorize_monomial_1d(monomial_as_1darray: ndarray, canonical_order=False) Tuple[ndarray, ...] [source]
Split a moment/expectation value into products of moments according to the support of the operators within the moment. The moment is encoded as a 1d array representing elements of the lexorder.
The output is a tuple of ndarrays where each array represents another monomial s.t. their product is equal to the original monomial.
- Parameters:
monomial_as_1darray (numpy.ndarray) – Monomial in 1d array form.
canonical_order (bool, optional) – Whether to return the different factors in a canonical order.
- Returns:
A tuple of ndarrays, where each array represents a picklist for an atomic monomial factor.
- Return type:
Tuple[numpy.ndarray]
- factorize_monomial_2d(monomial_as_2darray: ndarray, canonical_order=False) Tuple[ndarray, ...] [source]
Split a moment/expectation value into products of moments according to the support of the operators within the moment. The moment is encoded as a 2d array where each row is an operator. If
monomial=A*B*C*B
then row 1 isA
, row 2 isB
, row 3 isC
, and row 4 isB
. In each row, the columns encode the following information:First column: The party index, starting from 1 (e.g., 1 for
A
, 2 forB
, etc.)Last two columns: The input
x
starting from zero, and then the outputa
starting from zero.In between: This encodes the support of the operator. There are as many columns as sources/quantum states. Column j represents source j-1 (-1 because the first column represents the party). If the value is 0, then this operator does not measure this source. If the value is, e.g., 2, then this operator is acting on copy 2 of source j-1.
The output is a tuple of ndarrays where each array represents another monomial s.t. their product is equal to the original monomial.
- Parameters:
monomial_as_2darray (numpy.ndarray) – Monomial in 2d array form.
canonical_order (bool, optional) – Whether to return the different factors in a canonical order.
- Returns:
A tuple of ndarrays, where each array represents an atomic monomial factor.
- Return type:
Tuple[numpy.ndarray]
Examples
>>> monomial = np.array([[1, 0, 1, 1, 0, 0], [2, 1, 0, 2, 0, 0], [1, 0, 3, 3, 0, 0], [3, 3, 5, 0, 0, 0], [3, 1, 4, 0, 0, 0], [3, 6, 6, 0, 0, 0], [3, 4, 5, 0, 0, 0]]) >>> factorised = factorize_monomial(monomial_as_2darray) [array([[1, 0, 1, 1, 0, 0]]), array([[1, 0, 3, 3, 0, 0]]), array([[2, 1, 0, 2, 0, 0], [3, 1, 4, 0, 0, 0]]), array([[3, 3, 5, 0, 0, 0], [3, 4, 5, 0, 0, 0]]), array([[3, 6, 6, 0, 0, 0]])]
- rectify_fake_setting(monomial: ndarray) ndarray [source]
When constructing the monomials in a non-network scenario, we rely on an internal representation of operators where the integer denoting the setting actually is an ‘effective setting’ that encodes, in addition to the ‘private setting’ that each party is free to choose, the values of all the parents of the variable in question, which also effectively act as settings. This function resets this ‘effective setting’ integer to the true ‘private setting’ integer. It is useful to relate knowable monomials to their meaning as conditional events in non-network scenarios. If the scenario is a network, this function does nothing.
- Parameters:
monomial (numpy.ndarray) – An internal representation of a monomial as a 2d numpy array. Each row in the array corresponds to an operator. For each row, the zeroth element represents the party, the last element represents the outcome, the second-to-last element represents the setting, and the remaining elements represent inflation copies.
- Returns:
The monomial with the index of the setting representing only the private setting.
- Return type:
numpy.ndarray