Reference
GadgetSearch.EnergyModel — Type
EnergyModelAbstract type for energy models. Subtypes define how energy is computed from vertex states.
GadgetSearch.Gadget — Type
Gadget{M<:EnergyModel, T<:Real}A gadget found by the search algorithm.
Type Parameters
M: Energy model type (RydbergModel or QUBOModel)T: Numeric type for weights
Fields
constraint::GadgetConstraint: The constraint this gadget satisfiesgraph::SimpleGraph{Int}: The graph structurepins::Vector{Int}: Pin vertex indicesvertex_weights::Vector{T}: Vertex weights (hᵢ)edge_weights::Vector{T}: Edge weights (Jᵢⱼ), empty for RydbergModeledge_list::Vector{Tuple{Int,Int}}: Edge list corresponding to edge_weightspos::Union{Nothing, Vector{Tuple{Float64, Float64}}}: Vertex positions
GadgetSearch.GadgetConstraint — Type
GadgetConstraintAbstract type for gadget constraints. Subtypes define what ground states are required.
GadgetSearch.QUBOModel — Type
QUBOModel <: EnergyModelEnergy model for general QUBO (Quadratic Unconstrained Binary Optimization).
- State space: All 2^n binary configurations
- Energy: E(σ) = Σᵢ hᵢσᵢ + Σ₍ᵢ,ⱼ₎ Jᵢⱼσᵢσⱼ (vertex + edge weights)
GadgetSearch.RydbergModel — Type
RydbergModel <: EnergyModelEnergy model for Rydberg atom systems.
- State space: Maximal Independent Sets (MIS)
- Energy: E(σ) = Σᵢ hᵢσᵢ (vertex weights only)
GadgetSearch.TruthTableConstraint — Type
TruthTableConstraint <: GadgetConstraintConstraint defined by a truth table (for Rydberg/MIS-based gadgets).
Fields
truth_table::BitMatrix: Truth table where each row is a ground state configuration on pins
GadgetSearch.UnweightedGadget — Type
UnweightedGadgetResult of an unweighted gadget search. Stores the pattern graph R, replacement graph R', boundary vertices, constant offset between reduced alpha tensors, and optional vertex positions.
GadgetSearch._find_weights — Function
_find_weights(::Type{RydbergModel}, ...) -> Union{Nothing, Vector{Float64}}Find vertex weights for Rydberg model.
GadgetSearch._find_weights — Function
_find_weights(::Type{QUBOModel}, ...) -> Union{Nothing, Tuple{Vector{Float64}, Vector{Float64}}}Find vertex and edge weights for QUBO model.
GadgetSearch._graph_hash — Method
_graph_hash(g::SimpleGraph{Int}) -> UInt64Create a hash for graph structure for caching purposes.
GadgetSearch._make_unweighted_filter — Method
_make_unweighted_filter(pattern_graph, pattern_boundary; prefilter)Build a filter closure that checks candidate graphs against the target pattern.
GadgetSearch._solve_weights_sampled — Method
_solve_weights_sampled(...)Optimized version for large combination spaces using random sampling.
GadgetSearch.calculate_alpha_tensor — Method
calculate_alpha_tensor(graph, boundary_vertices) -> Array{<:Tropical}Compute the alpha tensor α(R) via tropical tensor network contraction. Element α(R)_s is the maximum independent set size with boundary fixed to s, or -Inf if s violates the independent set constraint.
GadgetSearch.calculate_reduced_alpha_tensor — Method
calculate_reduced_alpha_tensor(graph, boundary_vertices) -> Array{Float64}Compute the reduced alpha tensor α̃(R) by applying mis_compactify! to α(R). Dominated boundary configurations (where a subset achieves equal or better MIS size) are set to -Inf.
GadgetSearch.check_connectivity_after_removal — Method
check_connectivity_after_removal(graph, vertices_to_remove)Check if a graph remains connected after removing specified vertices.
GadgetSearch.check_gadget — Method
check_gadget(gadget::Gadget; _return_info::Bool=false, model::Type{<:EnergyModel}=RydbergModel)Validate a Gadget by computing energies for its state space and reporting the ground state configurations on pins.
Arguments
gadget::Gadget: The gadget to check.
Keyword Arguments
_return_info::Bool=false: Iftrue, return a string; otherwise log with@info.model::Type{<:EnergyModel}=RydbergModel: Energy model to use for validation.
Returns
- When
_return_infoistrue, returns a formattedString; otherwise returnsnothing.
GadgetSearch.check_gadget_qubo — Method
check_gadget_qubo(gadget::Gadget; _return_info::Bool=false)Check gadget using QUBO (full state space) model.
GadgetSearch.check_gadget_rydberg — Method
check_gadget_rydberg(gadget::Gadget; _return_info::Bool=false)Check gadget using Rydberg (MIS) model.
GadgetSearch.clear_cache! — Method
clear_cache!()Clear the MIS cache to free memory. Useful for long-running processes.
GadgetSearch.complete_graph — Method
complete_graph(n::Int) -> SimpleGraphCreate a complete graph with n vertices where every pair of vertices is connected.
Arguments
n: Number of vertices
Returns
SimpleGraph: The complete graph K_n
GadgetSearch.find_matching_gadget — Method
find_matching_gadget(loader; filter=nothing, limit=nothing, keys_range=nothing, max_results=nothing)Find gadgets matching a given filter function from the graph loader.
GadgetSearch.find_maximal_independent_sets — Method
find_maximal_independent_sets(g)Find all maximal independent sets of a graph using bit masks with caching.
GadgetSearch.generate_full_grid_graph — Method
generate_full_grid_graph(lattice::LatticeType, nx::Int, ny::Int; path::String="grid.g6") -> StringGenerate complete graphs on a grid lattice (without boundary expansion) and save to file. All vertices are connected to each other, regardless of distance.
Arguments
lattice: Type of lattice (Square or Triangular) - determines physical positionsnx: Number of grid points in x directionny: Number of grid points in y directionpath: Output file path for saving graphs (default: "grid.g6")
Returns
String: Path to the saved graph file
Details
Generates a single complete graph on the nx×ny grid. The physical positions follow the lattice geometry, but edges connect all pairs of vertices.
GadgetSearch.generate_full_grid_udg — Method
generate_full_grid_udg(lattice::LatticeType, nx::Int, ny::Int; path::String="udg.g6") -> StringGenerate unit disk graphs on a grid lattice with four boundary pins and save to file.
Arguments
lattice: Type of lattice (Square or Triangular)nx: Number of inner positions in x directionny: Number of inner positions in y directionpath: Output file path for saving graphs (default: "udg.g6")
Returns
String: Path to the saved graph file
Details
Generates all possible UDGs by placing pins on boundary positions and connecting vertices within unit distance on the specified lattice type.
GadgetSearch.get_cache_stats — Method
get_cache_stats()Get statistics about the MIS cache usage.
GadgetSearch.get_state_space — Method
get_state_space(::Type{QUBOModel}, graph::SimpleGraph{Int}) -> Tuple{Vector{UInt32}, Int}Get the state space for QUBO model (all 2^n states).
GadgetSearch.get_state_space — Method
get_state_space(::Type{RydbergModel}, graph::SimpleGraph{Int}) -> Tuple{Vector{UInt32}, Int}Get the state space for Rydberg model (Maximal Independent Sets).
GadgetSearch.graph_to_g6 — Method
graph_to_g6(g::SimpleGraph{Int}; include_header::Bool=false) -> StringEncode a graph to graph6 text. By default this returns the canonical graph6 payload without the >>graph6<< prefix so it can be used directly in GraphDataset.
GadgetSearch.inf_mask — Method
inf_mask(tensor) -> BigIntBitmask encoding -Inf positions in tensor (LSB = first linear index).
GadgetSearch.is_diff_by_constant — Method
is_diff_by_constant(t1, t2) -> (Bool, Real)Return (true, c) if t1 - t2 == c at all finite entries and both tensors share the same -Inf pattern; (false, 0) otherwise.
GadgetSearch.is_gadget_replacement — Method
is_gadget_replacement(g1, g2, open_vertices1, open_vertices2) -> (Bool, Real)Check whether g2 is a valid MIS replacement for g1, i.e., their reduced alpha tensors differ only by a constant. Returns (is_valid, α̃(g2) - α̃(g1)).
GadgetSearch.make_filter — Method
make_filter(model_type, constraint, optimizer, env; kwargs...)Create a filter closure for graph search that checks if a graph can implement the given constraint.
Arguments
model_type::Type{<:EnergyModel}: RydbergModel or QUBOModelconstraint::GadgetConstraint: The target constraint to implementoptimizer: Optimization solver for weight findingenv: Environment for the optimizer
Keywords
connected::Bool=false: Whether to require connected graphs onlyobjective=nothing: Objective function for optimizationallow_defect::Bool=false: Whether to allow zero vertex weightsmax_samples::Int=1000: Maximum samples for enumerationpin_candidates::Union{Nothing, Vector{Vector{Int}}}=nothing: Candidate pin combinationscheck_connectivity::Bool=true: Whether to check graph connectivity
Returns
Function: Filter function that takes (graph, pos, pin_set) and returns Gadget or nothing
GadgetSearch.match_constraint_to_states — Method
match_constraint_to_states(states, constraint, pin_set)Match constraint ground states to full graph states based on pin configuration.
Returns
Vector{Vector{Int}}: For each ground state pattern, indices of matching states in the state space
GadgetSearch.pins_prefilter — Method
pins_prefilter(g, pins)Return true when every connected component of g contains at least one pin.
GadgetSearch.search_by_truth_tables — Method
search_by_truth_tables(loader, truth_tables; kwargs...)Search for Rydberg gadgets by truth tables (legacy interface).
GadgetSearch.search_gadgets — Method
search_gadgets(model_type, loader, constraints; kwargs...)Unified search function for both Rydberg and QUBO gadgets.
Arguments
model_type::Type{<:EnergyModel}: RydbergModel or QUBOModelloader::GraphLoader: The graph loader containing candidate graphsconstraints::Vector{<:GadgetConstraint}: Constraints to search for
Keywords
optimizer: Optimization solver to use for weight findingenv=nothing: Environment for the optimizerconnected::Bool=false: Whether to require connected graphs onlyobjective=nothing: Objective function for optimizationallow_defect::Bool=false: Whether to allow zero vertex weightslimit=nothing: Maximum number of graphs to searchmax_samples::Int=100: Maximum samples for weight enumerationsave_path::String="results.json": Path to save intermediate resultspin_candidates::Union{Nothing, Vector{Vector{Int}}}=nothing: Candidate pin combinationscheck_connectivity::Bool=true: Whether to check graph connectivitymax_result_num::Int=1: Maximum number of results per constraint
Returns
Tuple{Vector{Vector{Gadget}}, Vector{<:GadgetConstraint}}: Found gadgets grouped by constraint and failed constraints
GadgetSearch.search_unweighted_gadgets — Method
search_unweighted_gadgets(target_graph, target_boundary, loader; kwargs...)Search for unweighted gadget replacements of target_graph by iterating over a GraphLoader.
GadgetSearch.solve_weights — Method
solve_weights(model_type, states, target_indices_all, graph, pin_set, optimizer; kwargs...)Unified weight solver that works for both Rydberg and QUBO models.
GadgetSearch.unit_disk_graph — Method
unit_disk_graph(locs::AbstractVector, unit::Real) -> SimpleGraphCreate a unit disk graph from given locations. Two vertices are connected if their Euclidean distance is less than the unit distance.
Arguments
locs: Vector of vertex locationsunit: Unit distance threshold for edge creation
Returns
SimpleGraph: The constructed unit disk graph