qlinks.constraints package#
Submodules#
qlinks.constraints.base module#
- class qlinks.constraints.base.ConstraintResult(satisfied, name='', residual=None, message='')[source]#
Bases:
objectResult of checking one constraint or sector condition.
- __init__(satisfied, name='', residual=None, message='')#
- class qlinks.constraints.base.ConstraintPropagation(consistent=True, forced_assignments=())[source]#
Bases:
objectResult of one incremental constraint-propagation step.
forced_assignmentscontains(variable_index, value)pairs that must hold in every completion of the current partial configuration. Generic constraints do not need to implement propagation; DFSBasisSolver treats this as an optional fast path and falls back topartial_check.- __init__(consistent=True, forced_assignments=())#
- class qlinks.constraints.base.Constraint(*args, **kwargs)[source]#
Bases:
ProtocolGeneral constraint interface.
A constraint decides whether a raw configuration is allowed.
Notes
affected_variables()should return the variable indices that can affectpartial_check()orcheck().DFSBasisSolveruses this support to avoid unnecessary checks. Returning all variables is correct but slower.- __init__(*args, **kwargs)#
- class qlinks.constraints.base.SectorCondition(*args, **kwargs)[source]#
Bases:
ProtocolDiagonal symmetry-sector filter.
Notes
affected_variables()should return the variable indices that can affectpartial_check()orcheck().DFSBasisSolveruses this support to avoid unnecessary checks. Returning all variables is correct but slower.- __init__(*args, **kwargs)#
- class qlinks.constraints.base.BaseConstraint[source]#
Bases:
objectConvenience base class for concrete constraints.
This is intentionally NOT a dataclass, because dataclass inheritance with default fields causes problems when subclasses add required fields.
- layout: VariableLayout#
- class qlinks.constraints.base.BaseSectorCondition[source]#
Bases:
objectConvenience base class for diagonal sector filters.
This is intentionally NOT a dataclass for the same reason as BaseConstraint.
- layout: VariableLayout#
qlinks.constraints.blockade module#
- class qlinks.constraints.blockade.NearestNeighborBlockadeConstraint(layout, site_i, site_j, occupied_value=1, name='nearest_neighbor_blockade')[source]#
Bases:
BaseConstraintPXP/Rydberg-blockade-style constraint on one lattice bond.
not (n_i == occupied_value and n_j == occupied_value)
Usually occupied_value = 1.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, site_i, site_j, occupied_value=1, name='nearest_neighbor_blockade')#
qlinks.constraints.collection module#
- class qlinks.constraints.collection.ConstraintCollection(constraints=(), sectors=())[source]#
Bases:
objectBundle local constraints and diagonal sector conditions.
The future basis solvers should consume this object or its two lists.
- constraints: tuple[Constraint, ...]#
- sectors: tuple[SectorCondition, ...]#
- __init__(constraints=(), sectors=())#
qlinks.constraints.dimer module#
- class qlinks.constraints.dimer.DimerCoveringConstraint(layout, site_id, link_ids, required_count=1, name='dimer_covering')[source]#
Bases:
BaseConstraintDimer covering constraint at one site.
sum_{links incident to site} n_l == required_count
Usually required_count = 1 for a fully packed dimer model.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, site_id, link_ids, required_count=1, name='dimer_covering')#
qlinks.constraints.gauss_law module#
- qlinks.constraints.gauss_law.internal_charge_value(charge, *, charge_normalization)[source]#
Convert user-facing charge into the raw integer target used by configs.
- integer_flux:
config values are interpreted as physical E_l = ±1. charge target is used directly.
- spin_half:
config values are stored as s_l = ±1, but physical E_l = s_l / 2. user-facing charge q is converted to raw target 2q.
- class qlinks.constraints.gauss_law.GaussLawConstraint(layout, site_id, link_ids, signs, charge, name='gauss_law', charge_normalization='spin_half')[source]#
Bases:
BaseConstraintLocal Gauss-law-like constraint at one lattice site.
Convention:
sum_l B[site, l] * E_l == charge
where B is the oriented incidence matrix with
B[source, link] = -1 B[target, link] = +1
If the layout is link-only, link_id == variable_index. More generally, this class maps link_id -> variable_index through layout.
- layout: VariableLayout#
- classmethod from_lattice_site(lattice, layout, site_id, charge=0, charge_normalization='spin_half')[source]#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, site_id, link_ids, signs, charge, name='gauss_law', charge_normalization='spin_half')#
qlinks.constraints.local module#
- class qlinks.constraints.local.BoundedLocalCountConstraint(layout, variable_indices, min_count, max_count, name='bounded_local_count')[source]#
Bases:
BaseConstraintBinary local count constraint with incremental propagation.
The constraint enforces
min_count <= sum(config[variable_indices]) <= max_count
where
min_count=Nonemeans there is no lower bound. All participating variables must have binary local space{0, 1}. Besides the usual partial feasibility check, the constraint can force remaining variables:if the current count already reaches
max_count, every unassigned variable in the support must be 0;if the lower bound can only be reached by occupying all remaining variables, every unassigned variable in the support must be 1.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, variable_indices, min_count, max_count, name='bounded_local_count')#
- class qlinks.constraints.local.FixedValueConstraint(layout, variable_indices, values, name='fixed_value')[source]#
Bases:
BaseConstraintRequire selected variables to take fixed values.
Useful for boundary conditions, pinned charges, frozen links, etc.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, variable_indices, values, name='fixed_value')#
- class qlinks.constraints.local.LocalSumConstraint(layout, variable_indices, coefficients, target, name='local_sum')[source]#
Bases:
BaseConstraintRequire a signed sum over selected variables to equal a target.
sum_i coefficients[i] * config[variable_indices[i]] == target
This is a generic building block for simple local constraints.
- layout: VariableLayout#
- __init__(layout, variable_indices, coefficients, target, name='local_sum')#
qlinks.constraints.sectors module#
- class qlinks.constraints.sectors.TotalValueSector(layout, target, variable_indices=None, coefficients=None, name='total_value_sector')[source]#
Bases:
BaseSectorConditionFix the total signed value over selected variables.
Examples
total particle number total magnetization total electric flux on selected links
- layout: VariableLayout#
- __init__(layout, target, variable_indices=None, coefficients=None, name='total_value_sector')#
- class qlinks.constraints.sectors.ParitySector(layout, target, variable_indices=None, name='parity_sector')[source]#
Bases:
BaseSectorConditionFix the parity of the sum over selected variables.
target should be 0 or 1.
- layout: VariableLayout#
- __init__(layout, target, variable_indices=None, name='parity_sector')#
qlinks.constraints.winding module#
- qlinks.constraints.winding.normalize_winding_target(target)[source]#
Normalize a user-facing winding target.
- Accepts:
1 Fraction(3, 2) “3/2”
Avoid floats to prevent precision ambiguity.
- qlinks.constraints.winding.internal_flux_winding_value(winding, *, flux_normalization)[source]#
Convert user-facing winding target into raw integer flux target.
- integer_flux:
stored flux s_l ∈ {-1,+1} is the physical electric field. raw_target = winding
- spin_half:
stored flux s_l ∈ {-1,+1} represents twice the physical spin-half electric field, E_l = s_l / 2. raw_target = 2 * winding
- qlinks.constraints.winding.user_winding_value_from_internal(raw_target, *, flux_normalization)[source]#
Convert raw integer winding value back to the user-facing convention.
- qlinks.constraints.winding.allowed_signed_sum_targets(*, layout, variable_indices, signs, value_transform=None)[source]#
Return all possible raw signed-sum sector values.
Computes all values of
sum_i signs[i] * f(x_i)over the local spaces of the selected variables.- Parameters:
layout (VariableLayout) – Variable layout.
variable_indices (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Variables included in the diagonal quantum number.
signs (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Integer signs/covector coefficients.
value_transform – Optional function mapping local-space values to the internal values used by the sector. If
None, values are used directly.
- Returns:
Sorted tuple of possible raw signed-sum targets.
- Return type:
- qlinks.constraints.winding.user_targets_from_raw_flux_targets(raw_targets, *, flux_normalization)[source]#
Convert raw stored-flux winding values into user-facing winding labels.
- integer_flux:
raw target equals user target.
- spin_half:
stored flux s_l in {-1,+1} represents twice the physical spin-half electric field, so raw target = 2 * user target. Only even raw targets are valid integer user labels under the current API.
- qlinks.constraints.winding.raw_targets_from_user_targets(user_targets, *, flux_normalization)[source]#
Convert user-facing winding labels to internal raw targets.
- Parameters:
- Returns:
Raw integer winding targets used internally by sector conditions.
- Return type:
- class qlinks.constraints.winding.WindingCutData(link_ids, signs, variable_indices)[source]#
Bases:
objectCached data defining one winding cut.
- link_ids:
Physical lattice links participating in the winding cut.
- signs:
Integer covector signs used in the winding value.
- variable_indices:
VariableLayout indices corresponding to link_ids.
- __init__(link_ids, signs, variable_indices)#
- class qlinks.constraints.winding.SquareWindingSector(layout, lattice, direction, target, name='square_winding_sector', flux_normalization='spin_half')[source]#
Bases:
BaseSectorConditionSquare-lattice electric winding sector.
The winding covector is a signed direction-link covector chosen so that it annihilates every plaquette boundary. This guarantees that local plaquette flips preserve the sector, including on small PBC lattices.
- layout: VariableLayout#
- lattice: SquareLattice#
- classmethod allowed_targets(*, layout, lattice, direction, flux_normalization='spin_half')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- classmethod validate_target(*, target, layout, lattice, direction, flux_normalization='spin_half')[source]#
- __init__(layout, lattice, direction, target, name='square_winding_sector', flux_normalization='spin_half')#
- class qlinks.constraints.winding.SquareQDMElectricWindingSector(layout, lattice, direction, target, name='square_qdm_electric_winding_sector')[source]#
Bases:
BaseSectorConditionSigned QDM winding sector compatible with the staggered-charge QLM mapping.
- QDM variables:
n_l in {0, 1}
- Electric-flux mapping:
E_l = eta(source(l)) * (2 n_l - 1)
- where:
eta(x, y) = (-1)^(x + y)
The winding is computed across wrapping links:
- direction=’x’:
sum over x-wrapping links
- direction=’y’:
sum over y-wrapping links
This is the sector convention to compare with QLM winding sectors.
- layout: VariableLayout#
- lattice: SquareLattice#
- classmethod allowed_targets(*, layout, lattice, direction)[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- __init__(layout, lattice, direction, target, name='square_qdm_electric_winding_sector')#
- class qlinks.constraints.winding.HoneycombElectricWindingSector(layout, lattice, direction, target, value_convention='binary', name='honeycomb_electric_winding_sector', flux_normalization='spin_half')[source]#
Bases:
BaseSectorConditionElectric winding sector for the honeycomb QLM on a periodic lattice.
This sector fixes one of the two conserved electric-flux winding numbers on a honeycomb torus. The winding number is the signed electric flux through a non-contractible cut; signs follow the lattice oriented-link convention.
- layout#
Variable layout.
- lattice#
Honeycomb lattice.
- direction#
Periodic cell direction,
"x"or"y".- Type:
Literal[‘x’, ‘y’]
- target#
User-facing target winding value.
- Type:
int | fractions.Fraction | str
- flux_normalization#
Convention used to interpret the target.
- Type:
Literal[‘integer_flux’, ‘spin_half’]
Notes
directionlabels the two independent periodic directions of the integer unit-cell coordinates, not the Cartesian directions of the plotting embedding.Specifically,
direction=”x”
means the winding sector associated with the first unit-cell direction, and
direction=”y”
means the winding sector associated with the second unit-cell direction.
For a honeycomb lattice these cell directions are generally oblique in the visual embedding. They should be understood as the two primitive torus cycles, or equivalently as a chosen basis of H_1(T^2, Z). Choosing a different pair of independent non-contractible cycles would give an equivalent winding basis, with sector labels related by an integer change of basis.
The primitive vectors and basis offsets used for plotting do not define the winding sector. The winding sector is defined by the combinatorial periodic cell coordinates and the oriented link/cut convention.
- layout: VariableLayout#
- lattice: HoneycombLattice#
- classmethod allowed_internal_targets(*, layout, lattice, direction, value_convention='binary')[source]#
- classmethod allowed_targets(*, layout, lattice, direction, value_convention='binary', flux_normalization='spin_half')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- classmethod validate_target(*, target, layout, lattice, direction, value_convention='binary', flux_normalization='spin_half')[source]#
- __init__(layout, lattice, direction, target, value_convention='binary', name='honeycomb_electric_winding_sector', flux_normalization='spin_half')#
qlinks.constraints.z2_winding module#
- class qlinks.constraints.z2_winding.Z2CutData(link_ids, variable_indices)[source]#
Bases:
objectCached link and variable indices for one Z2 winding cut.
- link_ids#
Physical link ids crossing the cut.
- Type:
numpy.ndarray[tuple[Any, …], numpy.dtype[numpy.int64]]
- variable_indices#
Layout variable indices associated with
link_ids.- Type:
numpy.ndarray[tuple[Any, …], numpy.dtype[numpy.int64]]
- __init__(link_ids, variable_indices)#
- class qlinks.constraints.z2_winding.TriangularZ2WindingSector(layout, lattice, direction, target, value_convention='binary', name='triangular_z2_winding_sector')[source]#
Bases:
BaseSectorConditionZ2 topological winding sector for triangular-lattice QDM/QLM on a torus.
The sector is the parity of occupied/electric-positive links crossing a non-contractible cut. The labels
direction="a"anddirection="b"refer to the two independent periodic cell directions of the triangular torus, not to filtering links bylink.kind.The cut is constructed from the periodic image shift of each link. This is important because triangular
clinks can also cross the primitive seams. Counting only wrapping links of kind"a"or"b"is not invariant under all triangular QDM rhombus flips.- layout: VariableLayout#
- lattice: TriangularLattice#
- classmethod allowed_targets(*, layout, lattice, direction, value_convention='binary')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- classmethod validate_target(*, target, layout, lattice, direction, value_convention='binary')[source]#
- __init__(layout, lattice, direction, target, value_convention='binary', name='triangular_z2_winding_sector')#
- class qlinks.constraints.z2_winding.KagomeZ2WindingSector(layout, lattice, direction, target, value_convention='binary', name='kagome_z2_winding_sector')[source]#
Bases:
BaseSectorConditionZ2 topological winding sector for kagome QDM/QLM on a torus.
The sector is the parity of occupied/electric-positive kagome links crossing a non-contractible cut of the triangular Bravais torus. The labels
direction="a"anddirection="b"refer to the two primitive cell directions, not to a bond kind.- layout: VariableLayout#
- lattice: KagomeLattice#
- classmethod allowed_targets(*, layout, lattice, direction, value_convention='binary')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- __init__(layout, lattice, direction, target, value_convention='binary', name='kagome_z2_winding_sector')#
Module contents#
- class qlinks.constraints.BaseConstraint[source]#
Bases:
objectConvenience base class for concrete constraints.
This is intentionally NOT a dataclass, because dataclass inheritance with default fields causes problems when subclasses add required fields.
- layout: VariableLayout#
- class qlinks.constraints.BaseSectorCondition[source]#
Bases:
objectConvenience base class for diagonal sector filters.
This is intentionally NOT a dataclass for the same reason as BaseConstraint.
- layout: VariableLayout#
- class qlinks.constraints.BoundedLocalCountConstraint(layout, variable_indices, min_count, max_count, name='bounded_local_count')[source]#
Bases:
BaseConstraintBinary local count constraint with incremental propagation.
The constraint enforces
min_count <= sum(config[variable_indices]) <= max_count
where
min_count=Nonemeans there is no lower bound. All participating variables must have binary local space{0, 1}. Besides the usual partial feasibility check, the constraint can force remaining variables:if the current count already reaches
max_count, every unassigned variable in the support must be 0;if the lower bound can only be reached by occupying all remaining variables, every unassigned variable in the support must be 1.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, variable_indices, min_count, max_count, name='bounded_local_count')#
- class qlinks.constraints.Constraint(*args, **kwargs)[source]#
Bases:
ProtocolGeneral constraint interface.
A constraint decides whether a raw configuration is allowed.
Notes
affected_variables()should return the variable indices that can affectpartial_check()orcheck().DFSBasisSolveruses this support to avoid unnecessary checks. Returning all variables is correct but slower.- __init__(*args, **kwargs)#
- class qlinks.constraints.ConstraintCollection(constraints=(), sectors=())[source]#
Bases:
objectBundle local constraints and diagonal sector conditions.
The future basis solvers should consume this object or its two lists.
- constraints: tuple[Constraint, ...]#
- sectors: tuple[SectorCondition, ...]#
- __init__(constraints=(), sectors=())#
- class qlinks.constraints.ConstraintPropagation(consistent=True, forced_assignments=())[source]#
Bases:
objectResult of one incremental constraint-propagation step.
forced_assignmentscontains(variable_index, value)pairs that must hold in every completion of the current partial configuration. Generic constraints do not need to implement propagation; DFSBasisSolver treats this as an optional fast path and falls back topartial_check.- __init__(consistent=True, forced_assignments=())#
- class qlinks.constraints.ConstraintResult(satisfied, name='', residual=None, message='')[source]#
Bases:
objectResult of checking one constraint or sector condition.
- __init__(satisfied, name='', residual=None, message='')#
- class qlinks.constraints.DimerCoveringConstraint(layout, site_id, link_ids, required_count=1, name='dimer_covering')[source]#
Bases:
BaseConstraintDimer covering constraint at one site.
sum_{links incident to site} n_l == required_count
Usually required_count = 1 for a fully packed dimer model.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, site_id, link_ids, required_count=1, name='dimer_covering')#
- class qlinks.constraints.FixedValueConstraint(layout, variable_indices, values, name='fixed_value')[source]#
Bases:
BaseConstraintRequire selected variables to take fixed values.
Useful for boundary conditions, pinned charges, frozen links, etc.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, variable_indices, values, name='fixed_value')#
- class qlinks.constraints.GaussLawConstraint(layout, site_id, link_ids, signs, charge, name='gauss_law', charge_normalization='spin_half')[source]#
Bases:
BaseConstraintLocal Gauss-law-like constraint at one lattice site.
Convention:
sum_l B[site, l] * E_l == charge
where B is the oriented incidence matrix with
B[source, link] = -1 B[target, link] = +1
If the layout is link-only, link_id == variable_index. More generally, this class maps link_id -> variable_index through layout.
- layout: VariableLayout#
- classmethod from_lattice_site(lattice, layout, site_id, charge=0, charge_normalization='spin_half')[source]#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, site_id, link_ids, signs, charge, name='gauss_law', charge_normalization='spin_half')#
- class qlinks.constraints.HoneycombElectricWindingSector(layout, lattice, direction, target, value_convention='binary', name='honeycomb_electric_winding_sector', flux_normalization='spin_half')[source]#
Bases:
BaseSectorConditionElectric winding sector for the honeycomb QLM on a periodic lattice.
This sector fixes one of the two conserved electric-flux winding numbers on a honeycomb torus. The winding number is the signed electric flux through a non-contractible cut; signs follow the lattice oriented-link convention.
- layout#
Variable layout.
- lattice#
Honeycomb lattice.
- direction#
Periodic cell direction,
"x"or"y".- Type:
Literal[‘x’, ‘y’]
- target#
User-facing target winding value.
- Type:
int | fractions.Fraction | str
- flux_normalization#
Convention used to interpret the target.
- Type:
Literal[‘integer_flux’, ‘spin_half’]
Notes
directionlabels the two independent periodic directions of the integer unit-cell coordinates, not the Cartesian directions of the plotting embedding.Specifically,
direction=”x”
means the winding sector associated with the first unit-cell direction, and
direction=”y”
means the winding sector associated with the second unit-cell direction.
For a honeycomb lattice these cell directions are generally oblique in the visual embedding. They should be understood as the two primitive torus cycles, or equivalently as a chosen basis of H_1(T^2, Z). Choosing a different pair of independent non-contractible cycles would give an equivalent winding basis, with sector labels related by an integer change of basis.
The primitive vectors and basis offsets used for plotting do not define the winding sector. The winding sector is defined by the combinatorial periodic cell coordinates and the oriented link/cut convention.
- layout: VariableLayout#
- lattice: HoneycombLattice#
- classmethod allowed_internal_targets(*, layout, lattice, direction, value_convention='binary')[source]#
- classmethod allowed_targets(*, layout, lattice, direction, value_convention='binary', flux_normalization='spin_half')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- classmethod validate_target(*, target, layout, lattice, direction, value_convention='binary', flux_normalization='spin_half')[source]#
- __init__(layout, lattice, direction, target, value_convention='binary', name='honeycomb_electric_winding_sector', flux_normalization='spin_half')#
- class qlinks.constraints.KagomeZ2WindingSector(layout, lattice, direction, target, value_convention='binary', name='kagome_z2_winding_sector')[source]#
Bases:
BaseSectorConditionZ2 topological winding sector for kagome QDM/QLM on a torus.
The sector is the parity of occupied/electric-positive kagome links crossing a non-contractible cut of the triangular Bravais torus. The labels
direction="a"anddirection="b"refer to the two primitive cell directions, not to a bond kind.- layout: VariableLayout#
- lattice: KagomeLattice#
- classmethod allowed_targets(*, layout, lattice, direction, value_convention='binary')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- __init__(layout, lattice, direction, target, value_convention='binary', name='kagome_z2_winding_sector')#
- class qlinks.constraints.LocalSumConstraint(layout, variable_indices, coefficients, target, name='local_sum')[source]#
Bases:
BaseConstraintRequire a signed sum over selected variables to equal a target.
sum_i coefficients[i] * config[variable_indices[i]] == target
This is a generic building block for simple local constraints.
- layout: VariableLayout#
- __init__(layout, variable_indices, coefficients, target, name='local_sum')#
- class qlinks.constraints.NearestNeighborBlockadeConstraint(layout, site_i, site_j, occupied_value=1, name='nearest_neighbor_blockade')[source]#
Bases:
BaseConstraintPXP/Rydberg-blockade-style constraint on one lattice bond.
not (n_i == occupied_value and n_j == occupied_value)
Usually occupied_value = 1.
- layout: VariableLayout#
- partial_check(config, assigned_mask)[source]#
Default partial check.
If all affected variables are assigned, perform the exact full check. Otherwise, do not prune.
Subclasses should override this for stronger pruning.
- __init__(layout, site_i, site_j, occupied_value=1, name='nearest_neighbor_blockade')#
- class qlinks.constraints.ParitySector(layout, target, variable_indices=None, name='parity_sector')[source]#
Bases:
BaseSectorConditionFix the parity of the sum over selected variables.
target should be 0 or 1.
- layout: VariableLayout#
- __init__(layout, target, variable_indices=None, name='parity_sector')#
- class qlinks.constraints.SectorCondition(*args, **kwargs)[source]#
Bases:
ProtocolDiagonal symmetry-sector filter.
Notes
affected_variables()should return the variable indices that can affectpartial_check()orcheck().DFSBasisSolveruses this support to avoid unnecessary checks. Returning all variables is correct but slower.- __init__(*args, **kwargs)#
- class qlinks.constraints.SquareDiskDiagonalLineSumSector(layout, lattice, family, target, occupied_value=1, name='square_disk_diagonal_line_sum_sector')[source]#
Bases:
BaseSectorConditionFix all disk-number sums along one square-lattice diagonal family.
This is a diagonal symmetry-sector filter for the quantum disk model. It is intentionally independent of the Hamiltonian implementation: a model can use it whenever its local moves preserve one of the two diagonal line-sum families.
- layout: VariableLayout#
- lattice: SquareLattice#
- __init__(layout, lattice, family, target, occupied_value=1, name='square_disk_diagonal_line_sum_sector')#
- class qlinks.constraints.SquareQDMElectricWindingSector(layout, lattice, direction, target, name='square_qdm_electric_winding_sector')[source]#
Bases:
BaseSectorConditionSigned QDM winding sector compatible with the staggered-charge QLM mapping.
- QDM variables:
n_l in {0, 1}
- Electric-flux mapping:
E_l = eta(source(l)) * (2 n_l - 1)
- where:
eta(x, y) = (-1)^(x + y)
The winding is computed across wrapping links:
- direction=’x’:
sum over x-wrapping links
- direction=’y’:
sum over y-wrapping links
This is the sector convention to compare with QLM winding sectors.
- layout: VariableLayout#
- lattice: SquareLattice#
- classmethod allowed_targets(*, layout, lattice, direction)[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- __init__(layout, lattice, direction, target, name='square_qdm_electric_winding_sector')#
- class qlinks.constraints.SquareWindingSector(layout, lattice, direction, target, name='square_winding_sector', flux_normalization='spin_half')[source]#
Bases:
BaseSectorConditionSquare-lattice electric winding sector.
The winding covector is a signed direction-link covector chosen so that it annihilates every plaquette boundary. This guarantees that local plaquette flips preserve the sector, including on small PBC lattices.
- layout: VariableLayout#
- lattice: SquareLattice#
- classmethod allowed_targets(*, layout, lattice, direction, flux_normalization='spin_half')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- classmethod validate_target(*, target, layout, lattice, direction, flux_normalization='spin_half')[source]#
- __init__(layout, lattice, direction, target, name='square_winding_sector', flux_normalization='spin_half')#
- class qlinks.constraints.TotalValueSector(layout, target, variable_indices=None, coefficients=None, name='total_value_sector')[source]#
Bases:
BaseSectorConditionFix the total signed value over selected variables.
Examples
total particle number total magnetization total electric flux on selected links
- layout: VariableLayout#
- __init__(layout, target, variable_indices=None, coefficients=None, name='total_value_sector')#
- class qlinks.constraints.TriangularZ2WindingSector(layout, lattice, direction, target, value_convention='binary', name='triangular_z2_winding_sector')[source]#
Bases:
BaseSectorConditionZ2 topological winding sector for triangular-lattice QDM/QLM on a torus.
The sector is the parity of occupied/electric-positive links crossing a non-contractible cut. The labels
direction="a"anddirection="b"refer to the two independent periodic cell directions of the triangular torus, not to filtering links bylink.kind.The cut is constructed from the periodic image shift of each link. This is important because triangular
clinks can also cross the primitive seams. Counting only wrapping links of kind"a"or"b"is not invariant under all triangular QDM rhombus flips.- layout: VariableLayout#
- lattice: TriangularLattice#
- classmethod allowed_targets(*, layout, lattice, direction, value_convention='binary')[source]#
Return all allowed target quantum numbers for this sector condition.
Subclasses should override this when the allowed labels can be determined from the lattice/layout.
- classmethod validate_target(*, target, layout, lattice, direction, value_convention='binary')[source]#
- __init__(layout, lattice, direction, target, value_convention='binary', name='triangular_z2_winding_sector')#
- class qlinks.constraints.WindingCutData(link_ids, signs, variable_indices)[source]#
Bases:
objectCached data defining one winding cut.
- link_ids:
Physical lattice links participating in the winding cut.
- signs:
Integer covector signs used in the winding value.
- variable_indices:
VariableLayout indices corresponding to link_ids.
- __init__(link_ids, signs, variable_indices)#
- class qlinks.constraints.Z2CutData(link_ids, variable_indices)[source]#
Bases:
objectCached link and variable indices for one Z2 winding cut.
- link_ids#
Physical link ids crossing the cut.
- Type:
numpy.ndarray[tuple[Any, …], numpy.dtype[numpy.int64]]
- variable_indices#
Layout variable indices associated with
link_ids.- Type:
numpy.ndarray[tuple[Any, …], numpy.dtype[numpy.int64]]
- __init__(link_ids, variable_indices)#
- qlinks.constraints.all_satisfied(config, constraints=(), sectors=())[source]#
Convenience helper used by simple solvers.
- qlinks.constraints.allowed_signed_sum_targets(*, layout, variable_indices, signs, value_transform=None)[source]#
Return all possible raw signed-sum sector values.
Computes all values of
sum_i signs[i] * f(x_i)over the local spaces of the selected variables.- Parameters:
layout (VariableLayout) – Variable layout.
variable_indices (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Variables included in the diagonal quantum number.
signs (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – Integer signs/covector coefficients.
value_transform – Optional function mapping local-space values to the internal values used by the sector. If
None, values are used directly.
- Returns:
Sorted tuple of possible raw signed-sum targets.
- Return type:
- qlinks.constraints.internal_charge_value(charge, *, charge_normalization)[source]#
Convert user-facing charge into the raw integer target used by configs.
- integer_flux:
config values are interpreted as physical E_l = ±1. charge target is used directly.
- spin_half:
config values are stored as s_l = ±1, but physical E_l = s_l / 2. user-facing charge q is converted to raw target 2q.
- qlinks.constraints.internal_flux_winding_value(winding, *, flux_normalization)[source]#
Convert user-facing winding target into raw integer flux target.
- integer_flux:
stored flux s_l ∈ {-1,+1} is the physical electric field. raw_target = winding
- spin_half:
stored flux s_l ∈ {-1,+1} represents twice the physical spin-half electric field, E_l = s_l / 2. raw_target = 2 * winding
- qlinks.constraints.normalize_winding_target(target)[source]#
Normalize a user-facing winding target.
- Accepts:
1 Fraction(3, 2) “3/2”
Avoid floats to prevent precision ambiguity.
- qlinks.constraints.raw_targets_from_user_targets(user_targets, *, flux_normalization)[source]#
Convert user-facing winding labels to internal raw targets.
- Parameters:
- Returns:
Raw integer winding targets used internally by sector conditions.
- Return type:
- qlinks.constraints.square_disk_line_label_for_cell(cell, lattice, *, family)[source]#
Return the diagonal-line label for one square-lattice cell/site.
- qlinks.constraints.square_disk_line_labels(lattice, *, family)[source]#
Return stable labels for square-lattice disk diagonal lines.
family='x_plus_y'labels anti-diagonals with constantx + y;family='x_minus_y'labels diagonals with constantx - y. Periodic lattices use labels modulo the corresponding linear size, so these are the line sums conserved by diagonal hopping on a torus.
- qlinks.constraints.user_targets_from_raw_flux_targets(raw_targets, *, flux_normalization)[source]#
Convert raw stored-flux winding values into user-facing winding labels.
- integer_flux:
raw target equals user target.
- spin_half:
stored flux s_l in {-1,+1} represents twice the physical spin-half electric field, so raw target = 2 * user target. Only even raw targets are valid integer user labels under the current API.