Reference
ProblemReductions.AbstractProblem
ProblemReductions.AbstractReductionResult
ProblemReductions.BoolVar
ProblemReductions.BruteForce
ProblemReductions.CNF
ProblemReductions.CNFClause
ProblemReductions.Circuit
ProblemReductions.CircuitSAT
ProblemReductions.Coloring
ProblemReductions.ConcatenatedReduction
ProblemReductions.DominatingSet
ProblemReductions.Factoring
ProblemReductions.GridGraph
ProblemReductions.HyperGraph
ProblemReductions.IndependentSet
ProblemReductions.KSatisfiability
ProblemReductions.LogicGadget
ProblemReductions.Matching
ProblemReductions.MaxCut
ProblemReductions.MaximalIS
ProblemReductions.PaintShop
ProblemReductions.QUBO
ProblemReductions.ReductionCircuitToSpinGlass
ProblemReductions.ReductionFactoringToSat
ProblemReductions.ReductionGraph
ProblemReductions.ReductionIndependentSetToSetPacking
ProblemReductions.ReductionMaxCutToSpinGlass
ProblemReductions.ReductionQUBOToSpinGlass
ProblemReductions.ReductionSATTo3SAT
ProblemReductions.ReductionSATToDominatingSet
ProblemReductions.ReductionSATToIndependentSet
ProblemReductions.ReductionSatToColoring
ProblemReductions.ReductionSpinGlassToMaxCut
ProblemReductions.ReductionSpinGlassToQUBO
ProblemReductions.ReductionVertexCoveringToSetCovering
ProblemReductions.Satisfiability
ProblemReductions.SetPacking
ProblemReductions.SpinGlass
ProblemReductions.StaticBitVector
ProblemReductions.StaticElementVector
ProblemReductions.TruthTable
ProblemReductions.UnitDiskGraph
ProblemReductions.VertexCovering
ProblemReductions.:¬
ProblemReductions.:∧
ProblemReductions.:∨
ProblemReductions.configuration_space_size
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.evaluate
ProblemReductions.extract_multiple_solutions
ProblemReductions.extract_solution
ProblemReductions.findbest
ProblemReductions.flavor_to_logical
ProblemReductions.flavors
ProblemReductions.implement_reduction_path
ProblemReductions.is_matching
ProblemReductions.is_maximal_independent_set
ProblemReductions.is_set_covering
ProblemReductions.is_set_packing
ProblemReductions.is_vertex_coloring
ProblemReductions.is_vertex_covering
ProblemReductions.num_flavors
ProblemReductions.num_variables
ProblemReductions.onehotv
ProblemReductions.paint_shop_coloring_from_config
ProblemReductions.parameter_type
ProblemReductions.parameters
ProblemReductions.problem_size
ProblemReductions.problem_size
ProblemReductions.reduce_size
ProblemReductions.reduceto
ProblemReductions.reduction_graph
ProblemReductions.reduction_paths
ProblemReductions.satisfiable
ProblemReductions.set_parameters
ProblemReductions.spinglass_energy
ProblemReductions.spinglass_gadget
ProblemReductions.target_problem
ProblemReductions.truth_table
ProblemReductions.variables
ProblemReductions.@bools
ProblemReductions.@bv_str
ProblemReductions.@circuit
ProblemReductions.AbstractProblem
— TypeAbstractProblem
The abstract base type of computational problems.
ProblemReductions.AbstractReductionResult
— Typeabstract type AbstractReductionResult
The base type for a reduction result.
ProblemReductions.BoolVar
— TypeBoolVar{T}
BoolVar(name, neg)
Boolean variable for constructing CNF clauses.
ProblemReductions.BruteForce
— Typestruct BruteForce
A brute force method to find the best configuration of a problem.
ProblemReductions.CNF
— TypeCNF{T}
CNF(clauses)
Boolean expression in conjunctive normal form. clauses
is a vector of CNFClause
, if and only if all clauses are satisfied, this CNF is satisfied.
Example
Under development
ProblemReductions.CNFClause
— TypeCNFClause{T}
CNFClause(vars)
A clause in CNF
, its value is the logical or of vars
, where vars
is a vector of BoolVar
.
ProblemReductions.Circuit
— Typestruct Circuit
A circuit expression is a sequence of assignments.
Fields
exprs::Vector{Assignment}
: The assignments in the circuit.
ProblemReductions.CircuitSAT
— Typestruct CircuitSAT <: AbstractProblem
Circuit satisfiability problem, where the goal is to find an assignment that satisfies the circuit.
Fields
circuit::Circuit
: The circuit expression in SSA form.symbols::Vector{Symbol}
: The variables in the circuit.
ProblemReductions.Coloring
— Typestruct Coloring{K, WT<:(AbstractVector)} <: AbstractProblem
Coloring{K}(graph; weights=UnitWeight(nv(graph)))
The Vertex Coloring problem.
Positional arguments
graph
is the problem graph.weights
are associated with the edges of thegraph
, default toUnitWeight(ne(graph))
.
ProblemReductions.ConcatenatedReduction
— Typestruct ConcatenatedReduction
A sequence of reductions.
Fields
sequence::Vector{Any}
: The sequence of reductions.
ProblemReductions.DominatingSet
— Typestruct DominatingSet{GT<:Graphs.AbstractGraph} <: AbstractProblem
DominatingSet(graph; weights=UnitWeight())
The dominating set problem.
Positional arguments
graph
is the problem graph.
We don't have weights for this problem.
ProblemReductions.Factoring
— TypeFactoring <: AbstractProblem
Factoring problem. Given two numbers a
and b
, find the product a * b
.
Fields
m::Int64
n::Int64
input::Int64
where m
is the number of bits for the first number, n
is the number of bits for the second number, and input
is the number to factorize.
ProblemReductions.GridGraph
— Typestruct GridGraph <: Graphs.AbstractGraph{Int64}
A grid graph is a graph in which the vertices are arranged in a grid and two vertices are connected by an edge if and only if they are adjacent in the grid.
Fields
grid::BitMatrix
: a matrix of booleans, wheretrue
indicates the presence of an edge.radius::Float64
: the radius of the unit disk
ProblemReductions.HyperGraph
— Typestruct HyperGraph <: Graphs.AbstractGraph{Int64}
A hypergraph is a generalization of a graph in which an edge can connect any number of vertices.
Fields
n::Int
: the number of verticesedges::Vector{Vector{Int}}
: a vector of vectors of integers, where each vector represents a hyperedge connecting the vertices with the corresponding indices.
ProblemReductions.IndependentSet
— Typestruct IndependentSet{GT<:Graphs.AbstractGraph, WT<:(AbstractVector)} <: AbstractProblem
The independent set problem in graph theory.
Positional arguments
graph
is the problem graph.weights
are associated with the vertices of thegraph
.
ProblemReductions.KSatisfiability
— Typestruct KSatisfiability{K, T} <: ProblemReductions.AbstractSatisfiabilityProblem{T}
The satisfiability problem for k-SAT, where the goal is to find an assignment that satisfies the CNF.
Fields
variables::Vector{T}
: The variables in the CNF.cnf::CNF{T}
: The CNF expression.
ProblemReductions.LogicGadget
— Typestruct LogicGadget{PT<:AbstractProblem}
The logic gadget defined on an computational model.
Fields
problem::PT
: the computational model, e.g.,SpinGlass
.inputs::Vector{Int}
: the input variables.outputs::Vector{Int}
: the output variables.
References
- What are the cost function for NAND and NOR gates?
- Nguyen, M.-T., Liu, J.-G., Wurtz, J., Lukin, M.D., Wang, S.-T., Pichler, H., 2023. Quantum Optimization with Arbitrary Connectivity Using Rydberg Atom Arrays. PRX Quantum 4, 010316.
ProblemReductions.Matching
— Typestruct Matching{WT<:Union{UnitWeight, Vector}} <: AbstractProblem
The Vertex matching problem.
Positional arguments
graph
is the problem graph.weights
are associated with the edges of thegraph
.
ProblemReductions.MaxCut
— Typestruct MaxCut{WT<:(AbstractVector)} <: AbstractProblem
The cutting problem.
- In this problem, we would like to find the cut of the graph that maximizes the sum of the
weights of the edges that are cut.
Positional arguments
graph
is the problem graph.weights
are associated with the edges of thegraph
. We have ensure that theweights
are in the same order as the edges inedges(graph)
.
ProblemReductions.MaximalIS
— Typestruct MaximalIS{WT<:Union{UnitWeight, Vector}} <: AbstractProblem
The [maximal independent set]problem. In the constructor, weights
are the weights of vertices.
Positional arguments
graph
is the problem graph.weights
are associated with the vertices of thegraph
.
ProblemReductions.PaintShop
— Typestruct PaintShop{LT} <: AbstractProblem
The binary paint shop problem.
Positional arguments
sequence
is a vector of symbols, each symbol is associated with a color.isfirst
is a vector of boolean numbers, indicating whether the symbol is the first appearance in the sequence.
ProblemReductions.QUBO
— Typestruct QUBO{T<:Real} <: AbstractProblem
The quadratic unconstrained binary optimization.
\[E = \sum_{i,j} Q_{ij} x_i x_j\]
where x_i \in \{0, 1\}
.
Arguments
matrix::AbstractMatrix
: the matrix Q of the QUBO problem.
ProblemReductions.ReductionCircuitToSpinGlass
— Typestruct ReductionCircuitToSpinGlass{GT, T} <: AbstractReductionResult
The reduction result of a circuit to a spin glass problem.
Fields
num_source_vars::Int
: the number of variables in the source circuit.spinglass::SpinGlass{GT, T}
: the spin glass problem.variables::Vector{Int}
: the variables in the spin glass problem.
ProblemReductions.ReductionFactoringToSat
— Typestruct ReductionFactoringToSat <: AbstractReductionResult
The reduction result of a factoring problem to a CircuitSAT problem.
Fields
circuit::CircuitSAT
: the CircuitSAT problem.p::Vector{Int}
: the first number to multiply (store bit locations)q::Vector{Int}
: the second number to multiply.m::Vector{Int}
: the result of the multiplication.
ProblemReductions.ReductionGraph
— TypeReductionGraph
A directed graph representing the reduction paths between different problems. A node represents a problem type, and an edge represents a reduction rule from one problem type to another.
Fields
graph::Graphs.SimpleGraphs.SimpleDiGraph{Int64}
nodes::Vector{Any}
method_table::Dict{Pair{Int64, Int64}, Method}
ProblemReductions.ReductionIndependentSetToSetPacking
— Typestruct ReductionIndependentSetToSetPacking{ET} <: AbstractReductionResult
The reduction result of an Independent Set problem to a Set Packing problem.
Fields
target::SetPacking
vertices_list::Vector{Int64}
ProblemReductions.ReductionMaxCutToSpinGlass
— Typestruct ReductionMaxCutToSpinGlass{GT, T} <: AbstractReductionResult
The reduction result of a maxcut to a spin glass problem.
Fields
spinglass::SpinGlass{GT, T}
: the spin glass problem.
We only consider a simple reduction from MaxCut to SpinGlass(the graph must be SimpleGraph
).
ProblemReductions.ReductionQUBOToSpinGlass
— Typestruct ReductionQUBOToSpinGlass{GT, T} <: AbstractReductionResult
The reduction result of a qubo to a spin glass problem.
Fields
spinglass::SpinGlass{GT, T}
: the spin glass problem.
We only consider a simple reduction from QUBO to SpinGlass(the graph must be SimpleGraph
).
ProblemReductions.ReductionSATTo3SAT
— TypeThe reduction result of a general SAT problem to a 3-SAT problem.
Fields
sat_source::Satisfiability{GT, T}
: the source general SAT problem.
ProblemReductions.ReductionSATToDominatingSet
— Typestruct ReductionSATToDominatingSet{GT<:Graphs.AbstractGraph} <: AbstractReductionResult
The reduction result of a general SAT problem to an Dominating Set problem.
Fields
target::DominatingSet
num_literals::Int64
num_clauses::Int64
ProblemReductions.ReductionSATToIndependentSet
— Typestruct ReductionSATToIndependentSet{T, GT<:Graphs.AbstractGraph, WT<:(AbstractVector)} <: AbstractReductionResult
The reduction result of a general SAT problem to an Independent Set problem.
Fields
target::IndependentSet
literals::Array{BoolVar{T}, 1} where T
source_variables::Vector
num_clauses::Int64
ProblemReductions.ReductionSatToColoring
— Typestruct ReductionSatToColoring{K, T, WT<:(AbstractVector)} <: AbstractReductionResult
The reduction result of a Sat problem to a Coloring problem.
Fields
Coloring{K, WT<:AbstractVector}
: the coloring problem, where K is the number of colors and WT is the weights type.varlabel
, used to filter extra variables
Note: The coloring problem is a 3 coloring problem, in which a auxiliary color is used Auxiliary color => 2.
ProblemReductions.ReductionSpinGlassToMaxCut
— Typestruct ReductionSpinGlassToMaxCut{WT} <: AbstractReductionResult
The reduction result of a spin glass to a maxcut problem.
Fields
maxcut::MaxCut{WT}
: the MaxCut problem.ancilla::Int
: the ancilla vertex.
ProblemReductions.ReductionSpinGlassToQUBO
— Typestruct ReductionSpinGlassToQUBO{WT} <: AbstractReductionResult
The reduction result of a spin glass to a QUBO problem.
Fields
qubo::QUBO{WT}
: the QUBO problem.
ProblemReductions.ReductionVertexCoveringToSetCovering
— Typestruct ReductionVertexCoveringToSetCovering{ET, WT<:(AbstractVector)} <: AbstractReductionResult
The reduction result of a vertex covering to a set covering problem.
Fields
setcovering::SetCovering{ET,WT}
: the set covering problem, where ET is the sets type and WT is the weights type.edgelabel
: map each edge to a number in order to identify the edge (otherwise the vector would be cluttering)
ProblemReductions.Satisfiability
— Typestruct Satisfiability{T} <: ProblemReductions.AbstractSatisfiabilityProblem{T}
The satisfiability problem.
Fields
cnf
is a conjunctive normal form (CNF
) for specifying the satisfiability problems.weights
are associated with clauses.
ProblemReductions.SetPacking
— Typestruct SetPacking{ET} <: AbstractProblem
The set packing problem, a generalization of independent set problem to hypergraphs.
Positional arguments
elements
is a vector of elements in the universe.sets
is a vector of vectors, each set is associated with a weight specified inweights
.
Currently this type problem doesn't support weights.
ProblemReductions.SpinGlass
— Typestruct SpinGlass{GT<:Graphs.AbstractGraph, WT<:(AbstractVector)} <: AbstractProblem
SpinGlass(graph::AbstractGraph, J, h=zeros(nv(graph)))
The spin-glass problem.
Positional arguments
graph
is a graph object.weights
are associated with the edges.
ProblemReductions.StaticBitVector
— TypeStaticBitVector{N,C} = StaticElementVector{N,1,C}
StaticBitVector(x::AbstractVector)
Examples
julia> sb = StaticBitVector([1,0,0,1,1])
10011
julia> sb[3]
0x0000000000000000
julia> collect(Int, sb)
5-element Vector{Int64}:
1
0
0
1
1
ProblemReductions.StaticElementVector
— TypeStaticElementVector{N,S,C}
StaticElementVector(nflavor::Int, x::AbstractVector)
N
is the length of vector, C
is the size of storage in unit of UInt64
, S
is the stride defined as the log2(# of flavors)
. When the number of flavors is 2, it is a StaticBitVector
.
Fields
data
is a tuple ofUInt64
for storing the configuration of static elements.
Examples
julia> ev = StaticElementVector(3, [1,2,0,1,2])
12012
julia> ev[2]
0x0000000000000002
julia> collect(Int, ev)
5-element Vector{Int64}:
1
2
0
1
2
ProblemReductions.TruthTable
— Typestruct TruthTable{N, T}
The truth table.
Fields
inputs::Vector{T}
: The input values.outputs::Vector{T}
: The output values.values::Vector{BitStr{N, Int}}
: The truth table values.
Examples
julia> tt = TruthTable(['a', 'b'], ['c'], [bit"0", bit"0", bit"0", bit"1"])
┌───┬───┬───┐
│ a │ b │ c │
├───┼───┼───┤
│ 0 │ 0 │ 0 │
│ 1 │ 0 │ 0 │
│ 0 │ 1 │ 0 │
│ 1 │ 1 │ 1 │
└───┴───┴───┘
ProblemReductions.UnitDiskGraph
— Typestruct UnitDiskGraph{D, T} <: Graphs.AbstractGraph{Int64}
A unit disk graph is a graph in which the vertices are points in a plane and two vertices are connected by an edge if and only if the Euclidean distance between them is at most a given radius.
Fields
n::Int
: the number of verticeslocations::Vector{NTuple{D, T}}
: the locations of the verticesradius::T
: the radius of the unit disk
ProblemReductions.VertexCovering
— Typestruct VertexCovering{WT<:(AbstractVector)} <: AbstractProblem
Vertex covering is a problem that seeks to find a minimum set of vertices that cover all edges in a graph.
Positional arguments
graph
is a graph object.weights
are associated with the vertices of thegraph
, default toUnitWeight(nv(graph))
.
ProblemReductions.:¬
— Method¬(var::BoolVar)
Negation of a boolean variables of type BoolVar
.
ProblemReductions.:∧
— MethodProblemReductions.:∨
— MethodProblemReductions.configuration_space_size
— Methodconfiguration_space_size(problem::AbstractProblem) -> Any
Return the log2 size of the configuration space of the problem.
ProblemReductions.evaluate
— Functionevaluate(problem::AbstractProblem, config) -> Real
Evaluate the energy of the problem
given the configuration config
. The lower the energy, the better the configuration.
ProblemReductions.evaluate
— Methodevaluate(c::Coloring, config)
Compute the energy of the vertex coloring configuration config
, the energy is the number of violated edges.
ProblemReductions.evaluate
— Methodevaluate(c::IndependentSet, config)
Firstly, we count the edges connecting the input 'config' (a subset of vertices): If this number is zero, this 'config' corresponds to an Independent Set.
- If the 'config' is an independent set, we return - (size(independent set));
- If the 'config' is not an independent set, we return Inf.
ProblemReductions.evaluate
— Methodevaluate(c::Matching, config)
Return Inf if the configuration is not a matching, otherwise return the sum of the weights of the edges in the matching.
ProblemReductions.evaluate
— Methodevaluate(c::MaxCut, config)
Compute the cut weights for the vertex configuration config
(an iterator). The energy is the sum of the weights of the edges that are cut.
ProblemReductions.evaluate
— Methodevaluate(c::MaximalIS, config)
Return the weights of the vertices that are not in the maximal independent set.
ProblemReductions.evaluate
— Methodevaluate(ps::PaintShop, config)
Returns the number of color switches. For example, if the sequence is abaccb
,there are three variables, then the config should be [1,0,1] or [0,1,0]. Here [1,0,1] means you want the first color for a
and c
is red, and the first color for b
is blue.
ProblemReductions.evaluate
— Methodevaluate(c::SetPacking, config)
- First step: We check if
config
(a vector of boolean numbers as the mask of sets) is a set packing ofsets
; - Second step: If it is a set packing, we return - (size(set packing)); Otherwise, we return size(variables) + 1.
ProblemReductions.evaluate
— Methodevaluate(c::VertexCovering, config)
return the weights of edge that is not covered but return typemax(eltype(weights)) if the edge is not covered. config
is a vector of boolean numbers.
ProblemReductions.extract_multiple_solutions
— Methodextract_multiple_solutions(reduction::AbstractReductionResult, solution_set)
Extract multiple solutions together solution_set
of the target problem to the original problem.
Arguments
reduction
: The reduction result.solution_set
: The set of multiple solutions of the target problem.
ProblemReductions.extract_solution
— Functionextract_solution(reduction::AbstractReductionResult, solution)
Extract the solution solution
of the target problem to the original problem.
Arguments
reduction
: The reduction result.solution
: The solution of the target problem.
ProblemReductions.findbest
— Functionfindbest(problem::AbstractProblem, method) -> Vector
Find the best configurations of the problem
using the method
.
ProblemReductions.flavor_to_logical
— Methodflavor_to_logical(::Type{T}, flavor) -> T
Convert the flavor to a logical value.
ProblemReductions.flavors
— Methodflavors(::Type{<:AbstractProblem}) -> Vector
Returns a vector of integers as the flavors (domain) of a degree of freedom.
ProblemReductions.implement_reduction_path
— Methodimplement_reduction_path(rg::ReductionGraph, path::AbstractVector, problem::AbstractProblem)
Implement a reduction path on a problem. Returns a ConcatenatedReduction
instance.
Arguments
path::AbstractVector
: A sequence of problem types, each element is anAbstractProblem
instance.problem::AbstractProblem
: The source problem, the type of which must be the same as the first node in the path.
ProblemReductions.is_matching
— Methodis_matching(graph::SimpleGraph, config)
Returns true if config
is a valid matching on graph
, and false
if a vertex is double matched. config
is a vector of boolean variables, which has one to one correspondence with edges(graph)
.
ProblemReductions.is_maximal_independent_set
— Methodis_maximal_independent_set(g::SimpleGraph, config)
Return true if config
(a vector of boolean numbers as the mask of vertices) is a maximal independent set of graph g
.
ProblemReductions.is_set_covering
— Methodis_set_covering(c::SetCovering, config)
Return true if config
(a vector of boolean numbers as the mask of sets) is a set covering of sets
.
ProblemReductions.is_set_packing
— Methodis_set_packing(sets::AbstractVector, config)
Return true if config
(a vector of boolean numbers as the mask of sets) is a set packing of sets
.
ProblemReductions.is_vertex_coloring
— Methodis_vertex_coloring(graph::SimpleGraph, config)
Returns true if the coloring specified by config is a valid one, i.e. does not violate the contraints of vertices of an edges having different colors.
ProblemReductions.is_vertex_covering
— Methodis_vertex_covering(graph::SimpleGraph, config)
return true if the vertex configuration config
is a vertex covering of the graph. Our judgement is based on the fact that for each edge, at least one of its vertices is selected.
ProblemReductions.num_flavors
— Methodnum_flavors(::Type{<:AbstractProblem}) -> Int
Returns the number of flavors (domain) of a degree of freedom.
ProblemReductions.num_variables
— Methodnum_variables(problem::AbstractProblem) -> Int
The number of variables in the computational problem.
ProblemReductions.onehotv
— Methodonehotv(::Type{<:StaticElementVector}, i, v)
onehotv(::Type{<:StaticBitVector, i)
Returns a static element vector, with the value at location i
being v
(1 if not specified).
ProblemReductions.paint_shop_coloring_from_config
— Methodpaint_shop_coloring_from_config(p::PaintShop, config)
Returns a valid painting from the paint shop configuration (given by the configuration solvers). The config
is a sequence of 0 and 1, where 0 means painting the first appearence of a car in red, and 1 means painting the first appearence of a car in blue.
ProblemReductions.parameter_type
— Methodparameter_type(problem::AbstractProblem) -> Type
The data type of the parameters in the computational problem.
ProblemReductions.parameters
— Functionparameters(problem::AbstractProblem) -> Vector
The parameters of the computational problem.
ProblemReductions.problem_size
— Functionproblem_size(problem::AbstractProblem) -> NamedTuple
The size of the computational problem, which is problem dependent.
ProblemReductions.problem_size
— MethodDefined as the number of sets.
ProblemReductions.reduce_size
— Methodreduce_size(::Type{T}, ::Type{S}, size)
Return the size of the target problem T
after reducing the source problem S
to T
.
The problem size measure is problem dependent. Please check problem_size
for the problem size measure.
Arguments
T
: The target problem type.S
: The source problem type.size
: The size of the source problem.
ProblemReductions.reduceto
— Functionreduceto(::Type{TA}, x::AbstractProblem)
Reduce the problem x
to a target problem of type TA
. Returns an instance of AbstractReductionResult
.
Arguments
TA
: The target problem type.x
: The original problem.
ProblemReductions.reduction_graph
— Method reduction_graph()
Returns a ReductionGraph
instance from the reduction rules defined with method reduceto
.
ProblemReductions.reduction_paths
— Methodreduction_paths([rg::ReductionGraph, ]S::Type, T::Type)
Find all reduction paths from problem type S
to problem type T
. Returns a list of paths, where each path is a sequence of problem types.
Arguments
rg::ReductionGraph
: The reduction graph of typeReductionGraph
.S::Type
: The source problem type.T::Type
: The target problem type.
ProblemReductions.satisfiable
— Methodsatisfiable(cnf::CNF, config::AbstractDict)
Returns true if an assignment of variables satisfies a CNF
.
ProblemReductions.set_parameters
— Functionset_parameters(problem::AbstractProblem, parameters) -> AbstractProblem
Change the parameters for the problem
and return a new problem instance.
ProblemReductions.spinglass_energy
— Methodspinglass_energy(g::SimpleGraph, config; J, h)
spinglass_energy(cliques::AbstractVector{Vector{Int}}, config; weights)
Compute the spin glass state energy for the vertex configuration config
. In the configuration, the spin ↑ is mapped to configuration 0, while spin ↓ is mapped to configuration 1. Let $G=(V,E)$ be the input graph, the hamiltonian is
\[H = \sum_{ij \in E} J_{ij} s_i s_j + \sum_{i \in V} h_i s_i,\]
where $s_i \in \{-1, 1\}$ stands for spin ↓ and spin ↑.
In the hypergraph case, the hamiltonian is
\[H = \sum_{c \in C} w_c \prod_{i \in c} s_i,\]
where $C$ is the set of cliques, and $w_c$ is the weight of the clique $c$.
ProblemReductions.spinglass_gadget
— Methodspinglass_gadget(::Val{:arraymul})
The array multiplier gadget.
s_{i+1,j-1} p_i
\ |
q_j ------------ q_j
|
c_{i,j} ------------ c_{i-1,j}
| \
p_i s_{i,j}
- variables: pi, qj, pq, c{i-1,j}, s{i+1,j-1}, c{i,j}, s{i,j}
- constraints: 2 * c{i,j} + s{i,j} = pi qj + c{i-1,j} + s{i+1,j-1}
ProblemReductions.target_problem
— Functiontarget_problem(res::AbstractReductionResult) -> AbstractProblem
Return the target problem of the reduction result.
ProblemReductions.truth_table
— Methodtruth_table(ga::LogicGadget; variables=1:num_variables(ga.problem), solver=BruteForce())
Compute the truth table of a logic gadget.
Arguments
ga::LogicGadget
: the logic gadget.
Keyword Arguments
variables::Vector{Int}
: the variables to be displayed.solver::AbstractSolver
: the solver to be used.
ProblemReductions.variables
— Functionvariables(problem::AbstractProblem) -> Vector
The degrees of freedoms in the computational problem. e.g. for the maximum independent set problems, they are the indices of vertices: 1, 2, 3..., while for the max cut problem, they are the edges.
ProblemReductions.@bools
— Macro@bools(syms::Symbol...)
Create some boolean variables of type BoolVar
in current scope that can be used in create a CNF
.
Example
Under Development
ProblemReductions.@bv_str
— MacroConstructing a static bit vector.
ProblemReductions.@circuit
— Macro@circuit circuit_expr
Construct a circuit expression from a block of assignments.
Examples
julia> @circuit begin
x = a ∨ b
y = x ∧ c
end
Circuit:
| x = ∨(a, b)
| y = ∧(x, c)