quantum_launcher.launcher.qlauncher#

File with templates

Summary#

Classes:

QuantumLauncher

Quantum Launcher class.

Functions:

Reference#

class quantum_launcher.launcher.qlauncher.QuantumLauncher(problem: Problem, algorithm: Algorithm, backend: Backend = None, logger: Logger | None = None)[source]#

Bases: object

Quantum Launcher class.

Quantum launcher is used to run quantum algorithms on specific problem instances and backends. It provides methods for binding parameters, preparing the problem, running the algorithm, and processing the results.

problem#

The problem instance to be solved.

Type:

Problem

algorithm#

The quantum algorithm to be executed.

Type:

Algorithm

backend#

The backend to be used for execution. Defaults to None.

Type:

Backend, optional

path#

The path to save the results. Defaults to ‘results/’.

Type:

str

binding_params#

The parameters to be bound to the problem and algorithm. Defaults to None.

Type:

dict or None

encoding_type#

The encoding type to be used changing the class of the problem. Defaults to None.

Type:

type

Example of usage:

from templates import QuantumLauncher
from problems import MaxCut
from qiskit_routines import QAOA, QiskitBackend

problem = MaxCut(instance_name='default')
algorithm = QAOA()
backend = QiskitBackend('local_simulator')

launcher = QuantumLauncher(problem, algorithm, backend)
result = launcher.process(save_pickle=True)
print(result)
run(**kwargs) Result[source]#

Finds proper formatter, and runs the algorithm on the problem with given backends.

Returns:

The results of the algorithm execution.

Return type:

dict

save(path: str, format: Literal['pickle', 'txt', 'json'] = 'pickle')[source]#
process(*, file_path: str | None = None, format: Literal['pickle', 'txt', 'json'] | List[Literal['pickle', 'txt', 'json']] = 'pickle', **kwargs) dict[source]#

Runs the algorithm, processes the data, and saves the results if specified.

Parameters:
  • file_path (Optional[str]) – Flag indicating whether to save the results to a file. Defaults to None.

  • format (Union[Literal['pickle', 'txt', 'json'], List[Literal['pickle', 'txt', 'json']]]) – Format in which file should be saved. Defaults to ‘pickle’

Returns:

The processed results.

Return type:

dict

quantum_launcher.launcher.qlauncher.fix_json(o: object)[source]#