BasisSearch

The BasisSearch class provides methods to uncover the optimal basis representation for a discrete dataset. The optimal basis representation is the one for which the set of the \(n\) one-body spin operators model in that basis has the largest log-evidence.

This class includes the following search algorithms:

  • Exhaustive search: Considers all spin operators to find the optimal basis, which is only feasible for small systems

  • up_to_order_k_fixed: Considers all spin operators up to interaction-order \(k\) to find the optimal basis.

  • up_to_order_k_iterative: Considers all spin operators up to interaction-order \(k\) in an interative procedure to find the optimal basis.

Each method returns a Basis object representing the best-found basis and stores it internally.

class mcmpy.BasisSearch

Initialization

__init__()

Constructs a BasisSearch object containing methods to find the best basis representation for a dataset.

Methods

exhaustive(data: Data, filename: str)

Performs a search over all spin operators to find the optimal basis for a given dataset.

This function searches over all spin operators of the variables and selects the optimal set of \(n\) linearly independent spin operators with the lowest entropy over the data. The result is returned as an Basis object and stored in the internal variable basis. Note that this search is only feasible for small systems (\(n < 15\)).

Parameters:
  • data (Data) – The dataset for which the optimal basis representation will be determined.

  • filename (str, optional) – Path to the file where the basis will be written. If not provided, nothing will be written to a file.

Returns:

The optimal basis for the given dataset found by an exhaustive search.

Return type:

Basis

up_to_order_k_fixed(data: Data, k: int, filename: str)

Performs a search over all spin operators up to order \(k\) to find the optimal basis for a given dataset.

This function searches over all spin operators up to order \(k\) and selects the set of \(n\) linearly independent spin operators with the lowest entropy over the data. The result is returned as an Basis object and stored in the internal variable basis.

Parameters:
  • data (Data) – The dataset for which the optimal basis representation will be determined.

  • k (int) – The maximum interaction order of the spin operators to consider.

  • filename (str, optional) – Path to the file where the basis will be written. If not provided, nothing will be written to a file.

Returns:

The optimal basis for the given dataset found by a search up to order k.

Return type:

Basis

up_to_order_k_iterative(data: Data, k: int, filename: str)

Performs an iterative search over all spin operators up to order \(k\) to find the optimal basis for a given dataset.

This function searches iteratively over all spin operators up to order \(k\) and selects the set of \(n\) linearly independent spin operators with the lowest entropy over the data. In each iteration the dataset is transformed using the current best basis, and a new optimal basis is searched for. This process continues until the optimal basis remains unchanged between two iterations. The result is returned as an Basis object and stored in the internal variable basis.

Parameters:
  • data (Data) – The dataset for which the optimal basis representation will be determined.

  • k (int) – The maximum interaction order of the spin operators to consider in each iteration.

  • filename (str, optional) – Path to the file where the basis will be written. If not provided, nothing will be written to a file.

Returns:

The optimal basis for the given dataset found by an iterative search up to order k.

Return type:

Basis

get_basis()

Returns a Basis object containing the solution of the last search.

Note that this function can only be called once a search has been run.

Returns:

The Basis object that was the result of the last search.

Return type:

Basis

print_result()

Prints out the result of the last search.

This function prints the search type, duration and the basis found by the last search. For a search up to order k, the maximum interaction order is also printed out. For an iterative search, the maximum interaction order and the number of iterations is also printed out.