quantum_launcher.launcher.qlauncher#
File with templates
Summary#
Classes:
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.
- 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
- 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