Skip to content

Results are limited to QUBO Solver v0.8.2

Product news
You are reading QUBO Solver v0.8.2, an older version of this documentation. Go to the latest version (v0.10.0)

Custom

If one desires to develop his own drive shaping method, a subclass of qubosolver.pipeline.drive.BaseDriveShaper should be implemented with a mandatory generate method.

The generate method syntax is generate(register: Register, instance: QUBOInstance) -> tuple[Drive, QUBOSolution] with arguments:

  • a Register instance specifying the qubits we work with.
  • a QUBOInstance specifying the qubo problem we target.

It returns:

  • an instance of qoolqit.Drive
  • a QUBOSolution specyfing the solution that may be used by a solver.

For concrete examples, we have the HeuristicDriveShaper and the OptimizedDriveShaper and their current implementations lie in qubosolver.pipeline.drive.py.

Let us show an example of a custom simple hard-coded drive shaper.

from qoolqit import Drive, Constant, Ramp, Register
from qubosolver.pipeline.drive import BaseDriveShaper
from qubosolver.data import QUBOSolution
from qubosolver.config import (
DriveShapingConfig,
SolverConfig,
)
class SimpleShaper(BaseDriveShaper):
def generate(
self,
register: Register,
) -> tuple[Drive, QUBOSolution]:
# Defining the drive parameters
omega = 2.0
delta_i = -4.0 * omega
delta_f = -delta_i
T = 200.0
# Defining the drive
wf_amp = Constant(T, omega)
wf_det = Ramp(T, delta_i, delta_f)
drive = Drive(amplitude=wf_amp, detuning=wf_det)
return drive, QUBOSolution(torch.Tensor(), torch.Tensor())
config = SolverConfig(
use_quantum=True,
drive_shaping=DriveShapingConfig(drive_shaping_method=SimpleShaper),
)