qilisdk.analog.schedule
Attributes
Classes
Builds a set of time-dependent coefficients applied to a collection of Hamiltonians. |
Module Contents
- CoeffDict[fuente]
- InterpDict[fuente]
- class Schedule(hamiltonians: dict[str, qilisdk.analog.hamiltonian.Hamiltonian] | None = None, coefficients: InterpDict | CoeffDict | None = None, dt: float = 0.1, total_time: PARAMETERIZED_NUMBER | None = None, interpolation: qilisdk.core.interpolator.Interpolation = Interpolation.LINEAR)[fuente]
Bases:
qilisdk.core.parameterizable.ParameterizableBuilds a set of time-dependent coefficients applied to a collection of Hamiltonians.
A Schedule defines the evolution of a system by associating time steps with a set of Hamiltonian coefficients. Coefficients can be provided directly, defined as functions of time, or specified over time intervals and interpolated (step or linear).
Ejemplo
import numpy as np from qilisdk.analog import Schedule, X, Z T, dt = 10.0, 1.0 h1 = X(0) + X(1) + X(2) h2 = -Z(0) - Z(1) - 2 * Z(2) + 3 * Z(0) * Z(1) schedule = Schedule( dt=dt, hamiltonians={"driver": h1, "problem": h2}, coefficients={ "driver": {(0, T): lambda t: 1 - t / T}, "problem": {(0, T): lambda t: t / T}, }, ) schedule.draw()Create a Schedule that assigns time-dependent coefficients to Hamiltonians.
- Parámetros:
hamiltonians (
dict[str,Hamiltonian] | None) – Mapping of labels to Hamiltonian objects. If omitted, an empty schedule is created.coefficients (
InterpDict | CoeffDict | None) – Per-Hamiltonian time definitions. Keys are time points or intervals; values are coefficients or callables. If anInterpolatoris supplied, it is used directly.dt (
float) – Time resolution used for sampling callable/interval definitions and plotting. Must be positive.total_time (
float | Parameter | Term | None) – Optional maximum time that rescales all defined time points proportionally.interpolation (
Interpolation) – How to interpolate between provided time points (LINEARorSTEP).
- Muestra:
ValueError – if the coefficients reference an undefined hamiltonian.
- iter_time_step = 0[fuente]
- property hamiltonians: dict[str, qilisdk.analog.hamiltonian.Hamiltonian][fuente]
Return the Hamiltonians managed by the schedule.
- Devuelve:
Mapping of labels to Hamiltonian instances.
- Tipo del valor devuelto:
dict[str, Hamiltonian]
- property coefficients_dict: dict[str, dict[PARAMETERIZED_NUMBER, PARAMETERIZED_NUMBER]][fuente]
- property coefficients: dict[str, qilisdk.core.interpolator.Interpolator][fuente]
- property T: float[fuente]
Total annealing time of the schedule.
- property tlist: list[float][fuente]
- property dt: float[fuente]
- set_dt(dt: float) None[fuente]
Set the time resolution
dtused for sampling callable/interval definitions and plotting.- Parámetros:
dt (
float) – New time resolution. Must be positive.- Muestra:
ValueError – If
dtis not a positive float.
- property nqubits: int[fuente]
Maximum number of qubits affected by Hamiltonians contained in the schedule.
- property nparameters: int[fuente]
Number of symbolic parameters introduced by the Hamiltonians or coefficients.
- set_parameters(parameters: dict[str, int | float]) None[fuente]
Update parameter values across all Hamiltonian coefficient interpolators.
- Parámetros:
parameters (
dict[str,int | float]) – Mapping from parameter labels to numeric values.- Muestra:
ValueError – If an unknown parameter label is provided.
- set_parameter_bounds(ranges: dict[str, tuple[float, float]]) None[fuente]
Propagate bound updates to all interpolators and cached parameters.
- Parámetros:
ranges (
dict[str,tuple[float,float]]) – Mapping of parameter label to(lower, upper)bounds.- Muestra:
ValueError – If an unknown parameter label is provided.
- get_constraints() list[qilisdk.core.variables.ComparisonTerm][fuente]
Return the set of parameter constraints arising from all interpolators.
- scale_max_time(max_time: PARAMETERIZED_NUMBER) None[fuente]
Rescale the schedule to a new maximum time while keeping relative points fixed.
- Muestra:
ValueError – If the max time provided is zero.
- add_hamiltonian(label: str, hamiltonian: qilisdk.analog.hamiltonian.Hamiltonian, coefficients: qilisdk.core.interpolator.TimeDict) None[fuente]
- add_hamiltonian(label: str, hamiltonian: qilisdk.analog.hamiltonian.Hamiltonian, coefficients: qilisdk.core.interpolator.Interpolator) None
- update_hamiltonian(label: str, new_hamiltonian: qilisdk.analog.hamiltonian.Hamiltonian | None = None, new_coefficients: qilisdk.core.interpolator.TimeDict | None = None, interpolation: qilisdk.core.interpolator.Interpolation = Interpolation.LINEAR) None[fuente]
- update_hamiltonian(label: str, new_hamiltonian: qilisdk.analog.hamiltonian.Hamiltonian | None = None, new_coefficients: qilisdk.core.interpolator.Interpolator | None = None) None
- draw(style: qilisdk.utils.visualization.ScheduleStyle | None = None, filepath: str | None = None) None[fuente]
Render a plot of the schedule using matplotlib and optionally save it to a file.
The schedule is rendered using the provided style configuration. If
filepathis given, the resulting figure is saved to disk (the output format is inferred from the file extension, e.g..png,.pdf,.svg).- Parámetros:
style (
ScheduleStyle, optional) – Customization options for the plot appearance. Defaults to ScheduleStyle().filepath (
str | None, optional) – If provided, saves the plot to the specified file path.