Class PythonQuantumBackend
java.lang.Object
org.episteme.natural.physics.quantum.backends.PythonQuantumBackend
- All Implemented Interfaces:
AlgorithmProvider, Backend, ComputeBackend, QuantumAlgorithmProvider, QuantumBackend
@AutoService({AlgorithmProvider.class,QuantumBackend.class,ComputeBackend.class,Backend.class})
public class PythonQuantumBackend
extends Object
implements QuantumBackend, QuantumAlgorithmProvider
Robust Quantum computing backend with advanced Qiskit integration.
Supports hybrid algorithms (VQE, QAOA) and rich circuit features.
-
Nested Class Summary
Nested classes/interfaces inherited from interface QuantumBackend
QuantumBackend.QuantumCircuit, QuantumBackend.QuantumResult -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCircuit(int qubits, int clbits) Creates a new quantum circuit.Creates an execution context for running operations.executeHardware(QuantumBackend.QuantumCircuit circuit, int shots, String backend) Executes a quantum circuit on real quantum hardware.executeSimulator(QuantumBackend.QuantumCircuit circuit, int shots) Executes a quantum circuit on a simulator.Returns the type of hardware accelerator used by this backend.String[]Returns available quantum backends (simulators and hardware).Returns backend information (num_qubits, connectivity, etc.).getName()Returns the display name for UI presentation.intReturns the priority for auto-selection (higher = preferred).Returns a human-readable status message for this backend.groverSearch(QuantumBackend.QuantumCircuit o, int q) Performs Grover's search algorithm.booleanChecks if this backend is currently available (libraries loaded, etc.).Converts a classical matrix to a quantum unitary operator.Performs Quantum Approximate Optimization Algorithm (QAOA).doublequantumPhaseEstimation(Matrix<Complex> u, Vector<Complex> e, int p) Performs Quantum Phase Estimation (QPE).int[]shorFactor(int N) Performs Shor's factoring algorithm.voidshutdown()Called when the application is shutting down or the backend is being replaced.stateTomography(QuantumBackend.QuantumCircuit c, int s) Performs quantum state tomography to reconstruct a density matrix.doublevqe(Matrix<Complex> hamiltonian, QuantumBackend.QuantumCircuit ansatz, String optimizer) Performs Variational Quantum Eigensolver (VQE) to find ground state energy.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, getMetadata, scoreMethods inherited from interface Backend
getAlgorithmProviders, isExplicitlyDisabledMethods inherited from interface ComputeBackend
createBackend, getDescription, getId, supportsComplexNumbers, supportsFloatingPoint, supportsParallelOpsMethods inherited from interface QuantumAlgorithmProvider
getAlgorithmTypeMethods inherited from interface QuantumBackend
execute, getType
-
Constructor Details
-
PythonQuantumBackend
public PythonQuantumBackend() -
PythonQuantumBackend
-
-
Method Details
-
getPriority
public int getPriority()Description copied from interface:BackendReturns the priority for auto-selection (higher = preferred). Used when multiple backends are available.- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceBackend
-
getName
Description copied from interface:BackendReturns the display name for UI presentation.- Specified by:
getNamein interfaceAlgorithmProvider- Specified by:
getNamein interfaceBackend- Specified by:
getNamein interfaceQuantumAlgorithmProvider
-
isAvailable
public boolean isAvailable()Description copied from interface:BackendChecks if this backend is currently available (libraries loaded, etc.).Default implementation checks
Backend.isExplicitlyDisabled()and returns false if it is.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceBackend- Specified by:
isAvailablein interfaceQuantumBackend
-
getStatusMessage
Description copied from interface:BackendReturns a human-readable status message for this backend. Useful for debugging "Unavailable" states.- Specified by:
getStatusMessagein interfaceBackend- Returns:
- status message (e.g., "Ready", "Native library missing", etc.)
-
shutdown
public void shutdown()Description copied from interface:BackendCalled when the application is shutting down or the backend is being replaced. Use this to release hardware resources, close file handles, or stop background threads.- Specified by:
shutdownin interfaceAlgorithmProvider- Specified by:
shutdownin interfaceBackend
-
createContext
Description copied from interface:ComputeBackendCreates an execution context for running operations.The context should be used within a try-with-resources block to ensure proper cleanup of resources.
- Specified by:
createContextin interfaceComputeBackend- Returns:
- new execution context
-
createCircuit
Description copied from interface:QuantumBackendCreates a new quantum circuit.- Specified by:
createCircuitin interfaceQuantumBackend
-
executeSimulator
public QuantumBackend.QuantumResult executeSimulator(QuantumBackend.QuantumCircuit circuit, int shots) Description copied from interface:QuantumBackendExecutes a quantum circuit on a simulator.- Specified by:
executeSimulatorin interfaceQuantumBackend
-
executeHardware
public QuantumBackend.QuantumResult executeHardware(QuantumBackend.QuantumCircuit circuit, int shots, String backend) Description copied from interface:QuantumBackendExecutes a quantum circuit on real quantum hardware.- Specified by:
executeHardwarein interfaceQuantumBackend
-
vqe
public double vqe(Matrix<Complex> hamiltonian, QuantumBackend.QuantumCircuit ansatz, String optimizer) Description copied from interface:QuantumAlgorithmProviderPerforms Variational Quantum Eigensolver (VQE) to find ground state energy.- Specified by:
vqein interfaceQuantumAlgorithmProvider- Parameters:
hamiltonian- Hamiltonian matrixansatz- Parameterized quantum circuitoptimizer- Classical optimizer ("COBYLA", "SPSA", etc.)- Returns:
- Ground state energy
-
shorFactor
public int[] shorFactor(int N) Description copied from interface:QuantumAlgorithmProviderPerforms Shor's factoring algorithm.- Specified by:
shorFactorin interfaceQuantumAlgorithmProvider- Parameters:
N- Number to factor- Returns:
- Factors of N
-
qaoa
Description copied from interface:QuantumAlgorithmProviderPerforms Quantum Approximate Optimization Algorithm (QAOA).- Specified by:
qaoain interfaceQuantumAlgorithmProvider- Parameters:
h- Cost Hamiltonian for the optimization probleml- Number of QAOA layers (p parameter)- Returns:
- Optimal parameters and final state
-
quantumPhaseEstimation
Description copied from interface:QuantumAlgorithmProviderPerforms Quantum Phase Estimation (QPE).- Specified by:
quantumPhaseEstimationin interfaceQuantumAlgorithmProvider- Parameters:
u- Unitary operatore- Initial eigenstatep- Number of precision qubits- Returns:
- Estimated phase
-
groverSearch
Description copied from interface:QuantumAlgorithmProviderPerforms Grover's search algorithm.- Specified by:
groverSearchin interfaceQuantumAlgorithmProvider- Parameters:
o- Oracle function (marks solution states)q- Number of qubits in search space- Returns:
- Measurement result (solution state)
-
matrixToUnitary
Description copied from interface:QuantumAlgorithmProviderConverts a classical matrix to a quantum unitary operator.- Specified by:
matrixToUnitaryin interfaceQuantumAlgorithmProvider
-
stateTomography
Description copied from interface:QuantumAlgorithmProviderPerforms quantum state tomography to reconstruct a density matrix.- Specified by:
stateTomographyin interfaceQuantumAlgorithmProvider
-
getAvailableBackends
Description copied from interface:QuantumBackendReturns available quantum backends (simulators and hardware).- Specified by:
getAvailableBackendsin interfaceQuantumBackend
-
getBackendInfo
Description copied from interface:QuantumBackendReturns backend information (num_qubits, connectivity, etc.).- Specified by:
getBackendInfoin interfaceQuantumBackend
-
getAcceleratorType
Description copied from interface:ComputeBackendReturns the type of hardware accelerator used by this backend.- Specified by:
getAcceleratorTypein interfaceComputeBackend- Returns:
- the accelerator type
-