Prime Factorization
Problem Definition
Prime Factorization(Factoring) is to decompose a number $m$ into its prime factors $p$ and $q$, denoted as $m = p \times q$.
Interfaces
To initialize a Factoring
, we need to specify the number to be factored(input
) and the number of bits of the factors(m
and n
).
julia> using ProblemReductions
julia> factoring = Factoring(2,2,6)
Factoring(2, 2, 6)
Here, the two 2
is the factors' bit size and 6
is the number to be factored. $6$ is $110$ in binary so its factors should be 2-bits number.
Functions variables
,flavors
and evaluate
are implemented for Factoring
model.
julia> variables(factoring) # return the sum of factors' bit size
4-element Vector{Int64}: 1 2 3 4
julia> flavors(factoring)
2-element Vector{Int64}: 0 1
julia> evaluate(factoring,[0,1,1,1]) # 01 -> 2, 11 -> 3
0
evaluate
function return 0
if the config is a correct factorization and 1
otherwise.