Class to generate a QUBO model for the N-Queens problem.
More...
#include <qbpp_nqueen.hpp>
Class to generate a QUBO model for the N-Queens problem.
This class is a derived class of qbpp::QuadModel with the 2-dimensional vector of Var objects representing the chessboard.
Definition at line 22 of file qbpp_nqueen.hpp.
◆ Mode
◆ NQueenQuadModel() [1/2]
Constructor to initialize member variables.
- Parameters
-
tuple | A tuple containing values to initialize the member variables. |
- Note
- Since the arguments are the return values of the helper function, the rvalue reference is used.
Definition at line 159 of file qbpp_nqueen.hpp.
◆ NQueenQuadModel() [2/2]
qbpp::nqueen::NQueenQuadModel::NQueenQuadModel |
( |
int |
dim, |
|
|
Mode |
mode |
|
) |
| |
|
inline |
Constructor: Creates an N-Queens QUBO expression.
- Parameters
-
dim | Dimension of the chessboard |
mode | Mode to generate the QUBO expression |
Definition at line 168 of file qbpp_nqueen.hpp.
◆ expand_mode()
Generates qbpp::Expr for the N-Queens problem.
- Returns
- qbpp::Expr for the N-Queens problem
The expression is created using the one-hot and zero-one-hot constraints. If all constraints are satisfied, board variables store correct placement of queens and the energy value is 0.
Definition at line 38 of file qbpp_nqueen.hpp.
◆ fast_mode()
Generates the QUBO expression for the N-Queens problem.
- Returns
- QUBO expression for the N-Queens problem
The expression is created by setting the penalty for placing two queens in the same row, column, and diagonal. If the placement of queens is correct, the value of the expression will be 0.
Definition at line 72 of file qbpp_nqueen.hpp.
◆ parallel_mode()
Generates the QUBO expression for the N-Queens problem using TBB in parallel.
Definition at line 104 of file qbpp_nqueen.hpp.
◆ helper_func()
Helper function to compute initial values for member variables.
- Parameters
-
dim | The dimension of the chessboard. |
mode | The mode to generate the QUBO expression. |
- Returns
- A tuple containing the QUBO model, dimension, and variables.
Definition at line 140 of file qbpp_nqueen.hpp.
◆ get_var() [1/2]
qbpp::Var qbpp::nqueen::NQueenQuadModel::get_var |
( |
int |
i, |
|
|
int |
j |
|
) |
| const |
|
inline |
Gets the variable at (i, j)
- Parameters
-
- Returns
- Var object at (i, j)
Definition at line 175 of file qbpp_nqueen.hpp.
◆ get_linear() [1/2]
const std::vector<coeff_t>& qbpp::QuadModel::get_linear |
( |
| ) |
const |
|
inlineinherited |
◆ get_linear() [2/2]
◆ get_degree() [1/2]
const std::vector<vindex_t>& qbpp::QuadModel::get_degree |
( |
| ) |
const |
|
inlineinherited |
◆ get_degree() [2/2]
◆ get_quadratic() [1/2]
const std::vector<std::vector<std::pair<vindex_t, coeff_t> > >& qbpp::QuadModel::get_quadratic |
( |
| ) |
const |
|
inlineinherited |
◆ get_quadratic() [2/2]
◆ term_count() [1/2]
size_t qbpp::QuadModel::term_count |
( |
vindex_t |
deg | ) |
const |
|
inlineinherited |
◆ term_count() [2/2]
size_t qbpp::QuadModel::term_count |
( |
| ) |
const |
|
inlineoverridevirtualinherited |
◆ get_min_coeff()
coeff_t qbpp::QuadModel::get_min_coeff |
( |
| ) |
const |
|
inlineinherited |
◆ get_max_coeff()
coeff_t qbpp::QuadModel::get_max_coeff |
( |
| ) |
const |
|
inlineinherited |
◆ check_expr() [1/2]
static const Expr& qbpp::Model::check_expr |
( |
const Expr & |
expr | ) |
|
|
inlinestaticprotectedinherited |
◆ check_expr() [2/2]
static Expr qbpp::Model::check_expr |
( |
Expr && |
expr | ) |
|
|
inlinestaticprotectedinherited |
◆ var_count()
vindex_t qbpp::Model::var_count |
( |
| ) |
const |
|
inlineinherited |
◆ get_var() [2/2]
◆ get_index()
◆ has()
bool qbpp::Model::has |
( |
Var |
var | ) |
const |
|
inlineinherited |
◆ get_expr()
const Expr& qbpp::Model::get_expr |
( |
| ) |
const |
|
inlineinherited |
◆ operator const Expr &()
qbpp::Model::operator const Expr & |
( |
| ) |
const |
|
inlineinherited |
◆ get_constant()
energy_t qbpp::Model::get_constant |
( |
| ) |
const |
|
inlineinherited |
◆ get_terms()
const Terms& qbpp::Model::get_terms |
( |
| ) |
const |
|
inlineinherited |
◆ get_index_var()
std::vector<Var> qbpp::Model::get_index_var |
( |
| ) |
const |
|
inlineinherited |
◆ dim_
const int qbpp::nqueen::NQueenQuadModel::dim_ |
|
private |
◆ X_
2-dimensional vector of qbpp::Var representing the chessboard
The Var object X_[i][j] is 1 if a queen is placed at (i, j) and 0
Definition at line 31 of file qbpp_nqueen.hpp.
◆ pimpl_
const std::shared_ptr<const Impl> qbpp::QuadModel::pimpl_ |
|
privateinherited |
◆ linear_
const std::vector<coeff_t>& qbpp::QuadModel::linear_ |
|
privateinherited |
◆ degree_
const std::vector<vindex_t>& qbpp::QuadModel::degree_ |
|
privateinherited |
◆ quadratic_
const std::vector<std::vector<std::pair<vindex_t, coeff_t> > >& qbpp::QuadModel::quadratic_ |
|
privateinherited |
◆ expr_ptr_
const std::shared_ptr<const Expr> qbpp::Model::expr_ptr_ |
|
protectedinherited |
◆ index_var_ptr_
The documentation for this class was generated from the following file: