QUBO++ Library with QUBO Solver APIs
Author: Koji Nakano, License: Non-commercial research and evaluation purposes without any guarantees.
|
Namespace for factorization using QUBO++ library. More...
Classes | |
class | SolHolder |
Solution holder to store the best solution of factorization. More... | |
class | ABS2Callback |
Class to define ABS2 callback function for factorization. More... | |
class | GRB_Callback |
Class to define Gurobi callback function for factorization. More... | |
Functions | |
Expr | and_gate (const Expr &a, const Expr &b, Var x, MapList &opt_sol) |
Function to generate a QUBO expression Expr object for the AND gate. More... | |
Expr | half_adder (const Expr &x, const Expr &y, Var s, Var c, MapList &opt_sol) |
Function to generates a QUBO expression Expr object for the Half Adder. More... | |
Expr | full_adder (const Expr &x, const Expr &y, const Expr &z, Var s, Var c, MapList &opt_sol) |
Function to generate a QUBO expression Expr object for the Full Adder. More... | |
template<typename T , typename U > | |
Expr | adder (const qbpp::Vector< T > &x, const qbpp::Vector< U > &y, const qbpp::Vector< Var > &s, const qbpp::Vector< Var > &c, MapList &opt_sol) |
function to generate QUBO expression for n-bit adder More... | |
template<typename T , typename U > | |
Expr | multiplier (const qbpp::Vector< T > &x, const qbpp::Vector< U > &y, const qbpp::Vector< Var > &z, MapList &opt_sol) |
Function to generate QUBO expression for multiplier. More... | |
std::string | toBinaryString (uint64_t num) |
Converts a number to a binary string. More... | |
uint64_t | as_uint64 (const qbpp::Sol &sol, const qbpp::Vector< qbpp::Var > &var, bool fix_lsb) |
Converts a vector of Var in a solution to a 64-bit unsigned integer. More... | |
uint64_t | as_uint64 (const qbpp::SolHolder &sol_holder, const qbpp::Vector< qbpp::Var > &var, bool fix_lsb) |
Converts a vector of Var in a solution holder to a 64-bit unsigned integer. More... | |
bool | is_prime (uint32_t num) |
uint32_t | rand_prime (int size) |
Generates a random prime number of the specified size. More... | |
Namespace for factorization using QUBO++ library.
|
inline |
Function to generate a QUBO expression Expr object for the AND gate.
a | The Expr object of the input. |
b | The Expr object of the input. |
x | The Var object of the output. |
opt_sol | The MapList object of the optimal solution. |
Expr is a binary expression taking the minimum value 0 if x = a & b
Definition at line 26 of file qbpp_multiplier.hpp.
|
inline |
Function to generates a QUBO expression Expr object for the Half Adder.
x | The Expr object of the input. |
y | The Expr object of the input. |
s | The Var object of the sum output. |
c | The Var object of the carry output. |
opt_sol | The MapList object of the optimal solution. |
Expr is a binary expression taking the minimum value 0 if x, y, s, c satisfy s = x ^ y and c = x & y
Definition at line 43 of file qbpp_multiplier.hpp.
|
inline |
Function to generate a QUBO expression Expr object for the Full Adder.
x | The Expr object of the input. |
y | The Expr object of the input. |
z | The Expr object of the input. |
s | The Var object of the sum output. |
c | The Var object of the carry output. |
opt_sol | optimal solution of the QUBO expression to be updated |
Expr is a binary expression taking the minimum value 0 if x, y, z, s, satisfy s = x ^ y ^ z and c = x & y + y & z + z & x
Definition at line 66 of file qbpp_multiplier.hpp.
Expr qbpp::factorization::adder | ( | const qbpp::Vector< T > & | x, |
const qbpp::Vector< U > & | y, | ||
const qbpp::Vector< Var > & | s, | ||
const qbpp::Vector< Var > & | c, | ||
MapList & | opt_sol | ||
) |
function to generate QUBO expression for n-bit adder
x | The input vector of T object. |
y | The input vector of U object. |
s | The output vector of Var object. |
c | The carry vector of Var object. |
opt_sol | optimal solution of the QUBO expression to be updated. |
Expr is a binary expression taking the minimum value 0 if x, y, s, c satisfy s = x + y and c are carry bits
Definition at line 95 of file qbpp_multiplier.hpp.
Expr qbpp::factorization::multiplier | ( | const qbpp::Vector< T > & | x, |
const qbpp::Vector< U > & | y, | ||
const qbpp::Vector< Var > & | z, | ||
MapList & | opt_sol | ||
) |
Function to generate QUBO expression for multiplier.
T | input type of input vector x: Var or Expr |
U | input type of input vector y: Var or Expr |
x | input vector of T |
y | input vector of U |
z | input vector of Var |
opt_sol | optimal solution of the QUBO expression to be updated |
Expr is a binary expression taking the minimum value 0 if z = x * y
Definition at line 122 of file qbpp_multiplier.hpp.
std::string qbpp::factorization::toBinaryString | ( | uint64_t | num | ) |
Converts a number to a binary string.
num | The number to be easyerted. |
Definition at line 40 of file factorization.cpp.
uint64_t qbpp::factorization::as_uint64 | ( | const qbpp::Sol & | sol, |
const qbpp::Vector< qbpp::Var > & | var, | ||
bool | fix_lsb | ||
) |
Converts a vector of Var in a solution to a 64-bit unsigned integer.
sol | The solution. |
var | The vector of Var. |
fix_lsb | True if the LSBs of x, y, and z are fixed to 1. |
Definition at line 55 of file factorization.cpp.
uint64_t qbpp::factorization::as_uint64 | ( | const qbpp::SolHolder & | sol_holder, |
const qbpp::Vector< qbpp::Var > & | var, | ||
bool | fix_lsb | ||
) |
Converts a vector of Var in a solution holder to a 64-bit unsigned integer.
sol_holder | The solution holder. |
var | The vector of Var. |
fix_lsb | True if the LSBs of x, y, and z are fixed to 1. |
Definition at line 75 of file factorization.cpp.
bool qbpp::factorization::is_prime | ( | uint32_t | num | ) |
uint32_t qbpp::factorization::rand_prime | ( | int | size | ) |
Generates a random prime number of the specified size.
size | The number of bits of the prime number. |
Definition at line 89 of file factorization.cpp.