quantum_launcher.base.base#

Summary#

Classes:

Algorithm

Abstract class for Algorithms.

Backend

Abstract class representing a backend for quantum computing.

Problem

Abstract class for defining Problems.

Result

Result(best_bitstring: str, best_energy: float, most_common_bitstring: str, most_common_bitstring_energy: float, distribution: dict, energies: dict, num_of_samples: int, average_energy: float, energy_std: float, result: Any)

Reference#

class quantum_launcher.base.base.Result(best_bitstring: str, best_energy: float, most_common_bitstring: str, most_common_bitstring_energy: float, distribution: dict, energies: dict, num_of_samples: int, average_energy: float, energy_std: float, result: Any)[source]#

Bases: object

best_bitstring: str#
best_energy: float#
most_common_bitstring: str#
most_common_bitstring_energy: float#
distribution: dict#
energies: dict#
num_of_samples: int#
average_energy: float#
energy_std: float#
result: Any#
best()[source]#
most_common()[source]#
static from_distributions(bitstring_distribution: dict[str, float], energy_distribution: dict[str, float], result: Any = None) Result[source]#

Constructs the Result object from Dictionary with bitstring to num of occurrences, dictionary mapping bitstring to energy and optional result (rest)

class quantum_launcher.base.base.Backend(name: str, parameters: list | None = None)[source]#

Bases: object

Abstract class representing a backend for quantum computing.

name#

The name of the backend.

Type:

str

path#

The path to the backend (optional).

Type:

str | None

parameters#

A list of parameters for the backend (optional).

Type:

list

set_logger(logger: Logger)[source]#
class quantum_launcher.base.base.Problem(instance: Any, instance_name: str = 'unnamed')[source]#

Bases: ABC

Abstract class for defining Problems.

variant#

The variant of the problem. The default variant is “Optimization”.

Type:

str

path#

The path to the problem.

Type:

str | None

name#

The name of the problem.

Type:

str

instance_name#

The name of the instance.

Type:

str

instance#

An instance of the problem.

Type:

any

classmethod from_file(path: str) P[source]#
static from_preset(instance_name: str, **kwargs)[source]#
read_result(exp, log_path)[source]#

Reads a result from a file.

Parameters:
  • exp – The experiment.

  • log_path – The path to the log file.

Returns:

The result.

analyze_result(result)[source]#

Analyzes the result.

Parameters:

result – The result.

class quantum_launcher.base.base.Algorithm(**alg_kwargs)[source]#

Bases: ABC

Abstract class for Algorithms.

name#

The name of the algorithm, derived from the class name in lowercase.

Type:

str

path#

The path to the algorithm, if applicable.

Type:

str | None

parameters#

A list of parameters for the algorithm.

Type:

list

alg_kwargs#

Additional keyword arguments for the algorithm.

Type:

dict

Abstract methods:

__init__(self, **alg_kwargs): Initializes the Algorithm object. _get_path(self) -> str: Returns the common path for the algorithm. run(self, problem: Problem, backend: Backend): Runs the algorithm on a specific problem using a backend.

parse_result_to_json(o: object) dict[source]#

Parses results so that they can be saved as a JSON file.

Parameters:

o (object) – The result object to be parsed.

Returns:

The parsed result as a dictionary.

Return type:

dict

abstractmethod run(problem: Problem, backend: Backend, formatter: Callable | None = None) Result[source]#

Runs the algorithm on a specific problem using a backend.

Parameters:
  • problem (Problem) – The problem to be solved.

  • backend (Backend) – The backend to be used for execution.