qlauncher.launcher.qlauncher#

File with templates

Summary#

Classes:

QLauncher

QLauncher class.

Functions:

Reference#

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

Bases: object

QLauncher class.

Qlauncher 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 qlauncher import QLauncher
from qlauncher.problems import MaxCut
from qlauncher.routines.qiskit import QAOA, QiskitBackend

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

launcher = QLauncher(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, save_format: Literal['pickle', 'txt', 'json'] = 'pickle')[source]#

Save last run result to file

Parameters:
  • path (str) – File path.

  • save_format (Literal['pickle', 'txt', 'json'], optional) – Save format. Defaults to ‘pickle’.

Raises:

ValueError – When no result is available or an incorrect save format was chosen

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