cimod
C++ library for a binary (and polynomial) quadratic model.
|
Class for dense binary quadratic model. More...
#include <binary_quadratic_model.hpp>
Public Types | |
using | DenseMatrix = Eigen::Matrix< FloatType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > |
Eigen Matrix if DataType is Dense , Matrix is equal to Eigen::Matrix if DataType is Sparse, Matrix is equal to Eigen::SparseMatrix. More... | |
using | SparseMatrix = Eigen::SparseMatrix< FloatType, Eigen::RowMajor > |
using | SpIter = typename SparseMatrix::InnerIterator |
using | Matrix = std::conditional_t< std::is_same_v< DataType, Dense >, DenseMatrix, SparseMatrix > |
using | Vector = Eigen::Matrix< FloatType, Eigen::Dynamic, 1 > |
using | json = nlohmann::json |
Public Member Functions | |
BinaryQuadraticModel (const Linear< IndexType, FloatType > &linear, const Quadratic< IndexType, FloatType > &quadratic, const FloatType &offset, const Vartype vartype) | |
BinaryQuadraticModel constructor. More... | |
BinaryQuadraticModel (const Linear< IndexType, FloatType > &linear, const Quadratic< IndexType, FloatType > &quadratic, const Vartype vartype) | |
BinaryQuadraticModel constructor. More... | |
BinaryQuadraticModel (const Eigen::Ref< const DenseMatrix > &mat, const std::vector< IndexType > &labels_vec, const FloatType &offset, const Vartype vartype, bool fix_format=true) | |
BinaryQuadraticModel constructor (with matrix);. More... | |
BinaryQuadraticModel (const Eigen::Ref< const DenseMatrix > &mat, const std::vector< IndexType > &labels_vec, const Vartype vartype, bool fix_format=true) | |
BinaryQuadraticModel constructor (with matrix);. More... | |
BinaryQuadraticModel (const SparseMatrix &mat, const std::vector< IndexType > &labels_vec, const FloatType &offset, const Vartype vartype) | |
BinaryQuadraticModel constructor (with sparse matrix); this constructor is for developers. More... | |
BinaryQuadraticModel (const SparseMatrix &mat, const std::vector< IndexType > &labels_vec, const Vartype vartype) | |
BinaryQuadraticModel constructor (with sparse matrix); this constructor is for developers. More... | |
BinaryQuadraticModel (const BinaryQuadraticModel &)=default | |
size_t | get_num_variables () const |
get the number of variables More... | |
size_t | length () const |
Return the number of variables. More... | |
bool | contains (const IndexType &v) const |
Return true if the variable contains v. More... | |
FloatType | get_linear (IndexType label_i) const |
Get the element of linear object. More... | |
Linear< IndexType, FloatType > | get_linear () const |
Get linear object. More... | |
FloatType | get_quadratic (IndexType label_i, IndexType label_j) const |
Get the element of quadratic object. More... | |
Quadratic< IndexType, FloatType > | get_quadratic () const |
Get uadratic object. More... | |
FloatType | get_offset () const |
Get the offset. More... | |
Vartype | get_vartype () const |
Get the vartype object. More... | |
const std::vector< IndexType > & | get_variables () const |
Get variables. More... | |
BinaryQuadraticModel< IndexType, FloatType, DataType > | empty (Vartype vartype) |
Create an empty BinaryQuadraticModel. More... | |
void | add_variable (const IndexType &v, const FloatType &bias) |
Add variable v and/or its bias to a binary quadratic model. More... | |
void | add_variables_from (const Linear< IndexType, FloatType > &linear) |
Add variables and/or linear biases to a binary quadratic model. More... | |
void | add_interaction (const IndexType &u, const IndexType &v, const FloatType &bias) |
Add an interaction and/or quadratic bias to a binary quadratic model. More... | |
void | add_interactions_from (const Quadratic< IndexType, FloatType > &quadratic) |
Add interactions and/or quadratic biases to a binary quadratic model. More... | |
void | remove_variable (const IndexType &v) |
Remove variable v and all its interactions from a binary quadratic model. More... | |
void | remove_variables_from (const std::vector< IndexType > &variables) |
Remove specified variables and all of their interactions from a binary quadratic model. More... | |
void | remove_interaction (const IndexType &u, const IndexType &v) |
Remove interaction of variables u, v from a binary quadratic model. More... | |
void | remove_interactions_from (const std::vector< std::pair< IndexType, IndexType >> &interactions) |
Remove all specified interactions from the binary quadratic model. More... | |
void | add_offset (const FloatType &offset) |
Add specified value to the offset of a binary quadratic model. More... | |
void | remove_offset () |
Set the binary quadratic model's offset to zero. More... | |
void | scale (const FloatType &scalar, const std::vector< IndexType > &ignored_variables={}, const std::vector< std::pair< IndexType, IndexType >> &ignored_interactions={}, const bool ignored_offset=false) |
Multiply by the specified scalar all the biases and offset of a binary quadratic model. More... | |
void | normalize (const std::pair< FloatType, FloatType > &bias_range={ 1.0, 1.0 }, const bool use_quadratic_range=false, const std::pair< FloatType, FloatType > &quadratic_range={ 1.0, 1.0 }, const std::vector< IndexType > &ignored_variables={}, const std::vector< std::pair< IndexType, IndexType >> &ignored_interactions={}, const bool ignored_offset=false) |
Normalizes the biases of the binary quadratic model such that they fall in the provided range(s), and adjusts the offset appropriately. More... | |
void | fix_variable (const IndexType &v, const int32_t &value) |
Fix the value of a variable and remove it from a binary quadratic model. More... | |
void | fix_variables (const std::vector< std::pair< IndexType, int32_t >> &fixed) |
Fix the value of the variables and remove it from a binary quadratic model. More... | |
void | flip_variable (const IndexType &v) |
Flip variable v in a binary quadratic model. More... | |
void | change_vartype (const Vartype &vartype) |
** More... | |
BinaryQuadraticModel< IndexType, FloatType, DataType > | change_vartype (const Vartype &vartype, bool inplace) |
Create a binary quadratic model with the specified vartype. More... | |
FloatType | energy (const Sample< IndexType > &sample) const |
Determine the energy of the specified sample of a binary quadratic model. More... | |
std::vector< FloatType > | energies (const std::vector< Sample< IndexType >> &samples_like) const |
Determine the energies of the given samples. More... | |
std::tuple< Quadratic< IndexType, FloatType >, FloatType > | to_qubo () |
Convert a binary quadratic model to QUBO format. More... | |
std::tuple< Linear< IndexType, FloatType >, Quadratic< IndexType, FloatType >, FloatType > | to_ising () |
Convert a binary quadratic model to Ising format. More... | |
Matrix | interaction_matrix () const |
generate (Dense or Sparse) interaction matrix with given list of indices The generated matrix will be the following triangular matrix: More... | |
template<typename T = DataType> | |
json | to_serializable (dispatch_t< T, Dense >=nullptr) const |
Convert the binary quadratic model to a dense-version serializable object. More... | |
template<typename T = DataType> | |
json | to_serializable (dispatch_t< T, Sparse >=nullptr) const |
Convert the binary quadratic model to a serializable object. More... | |
Static Public Member Functions | |
static BinaryQuadraticModel< IndexType, FloatType, DataType > | from_qubo (const Quadratic< IndexType, FloatType > &Q, FloatType offset=0.0) |
Create a binary quadratic model from a QUBO model. More... | |
static BinaryQuadraticModel< IndexType, FloatType, DataType > | from_ising (const Linear< IndexType, FloatType > &linear, const Quadratic< IndexType, FloatType > &quadratic, FloatType offset=0.0) |
Create a binary quadratic model from an Ising problem. More... | |
template<typename IndexType_serial = IndexType, typename FloatType_serial = FloatType, typename T = DataType> | |
static BinaryQuadraticModel< IndexType_serial, FloatType_serial, DataType > | from_serializable (const json &input, dispatch_t< T, Dense >=nullptr) |
Create a BinaryQuadraticModel instance from a serializable object. More... | |
template<typename IndexType_serial = IndexType, typename FloatType_serial = FloatType, typename T = DataType> | |
static BinaryQuadraticModel< IndexType_serial, FloatType_serial, DataType > | from_serializable (const json &input, dispatch_t< T, Sparse >=nullptr) |
Create a BinaryQuadraticModel instance from a serializable object. More... | |
Protected Member Functions | |
void | _set_label_to_idx () |
set _label_to_idx from _idx_to_label More... | |
template<typename T = DataType> | |
FloatType & | _quadmat_get (size_t i, size_t j, dispatch_t< T, Dense >=nullptr) |
access elements for dense matrix More... | |
template<typename T = DataType> | |
FloatType | _quadmat_get (size_t i, size_t j, dispatch_t< T, Dense >=nullptr) const |
access elements for dense matrix More... | |
template<typename T = DataType> | |
FloatType & | _quadmat_get (size_t i, size_t j, dispatch_t< T, Sparse >=nullptr) |
access elements for sparse matrix More... | |
template<typename T = DataType> | |
FloatType | _quadmat_get (size_t i, size_t j, dispatch_t< T, Sparse >=nullptr) const |
access elements for sparse matrix More... | |
FloatType & | _mat (IndexType label_i, IndexType label_j) |
get reference of _quadmat(i,j) More... | |
FloatType & | _mat (IndexType label_i) |
get reference of _quadmat(i,i) More... | |
FloatType | _mat (IndexType label_i, IndexType label_j) const |
get reference of _quadmat(i,j) More... | |
FloatType | _mat (IndexType label_i) const |
get reference of _quadmat(i,i) More... | |
template<typename T = DataType> | |
FloatType | _max_linear (dispatch_t< T, Dense >=nullptr) const |
calculate maximum element in linear term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _max_quadratic (dispatch_t< T, Dense >=nullptr) const |
calculate maximum element in quadratic term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _min_linear (dispatch_t< T, Dense >=nullptr) const |
calculate minimum element in linear term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _min_quadratic (dispatch_t< T, Dense >=nullptr) const |
calculate minimum element in quadratic term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _max_linear (dispatch_t< T, Sparse >=nullptr) const |
calculate maximum element in linear term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _max_quadratic (dispatch_t< T, Sparse >=nullptr) const |
calculate maximum element in quadratic term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _min_linear (dispatch_t< T, Sparse >=nullptr) const |
calculate minimum element in linear term for dense graph More... | |
template<typename T = DataType> | |
FloatType | _min_quadratic (dispatch_t< T, Sparse >=nullptr) const |
calculate minimum element in quadratic term for dense graph More... | |
template<typename T = DataType> | |
void | _insert_label_into_mat (IndexType label_i, dispatch_t< T, Dense >=nullptr) |
insert row and column that corresponds to added label into _quadmat for dense matrix More... | |
template<typename T = DataType> | |
void | _insert_label_into_mat (IndexType label_i, dispatch_t< T, Sparse >=nullptr) |
insert row and column that corresponds to added label into _quadmat for sparse matrix More... | |
template<typename T = DataType> | |
void | _delete_label_from_mat (IndexType label_i, dispatch_t< T, Dense >=nullptr) |
delete row and column that corresponds to existing label from _quadmat for dense matrix More... | |
template<typename T = DataType> | |
void | _delete_label_from_mat (IndexType label_i, dispatch_t< T, Sparse >=nullptr) |
delete row and column that corresponds to existing label from _quadmat for sparse matrix More... | |
void | _add_new_label (IndexType label_i) |
add new label if label_i already exists, this process is skipped. More... | |
void | _delete_label (IndexType label_i, bool force_delete=true) |
delete label if label_i does not exist, this process is skipped. More... | |
template<typename T = DataType> | |
void | _initialize_quadmat (const Linear< IndexType, FloatType > &linear, const Quadratic< IndexType, FloatType > &quadratic, dispatch_t< T, Dense >=nullptr) |
initialize matrix with linear and quadratic dicts (for dense matrix) More... | |
template<typename T = DataType> | |
void | _initialize_quadmat (const Linear< IndexType, FloatType > &linear, const Quadratic< IndexType, FloatType > &quadratic, dispatch_t< T, Sparse >=nullptr) |
initialize matrix with linear and quadratic dicts (for sparse matrix) More... | |
template<typename T = DataType> | |
void | _add_triangular_elements (const DenseMatrix &mat, bool fix_format, dispatch_t< T, Dense >=nullptr) |
add non-diagonal elements to upper triangular components for dense matrix More... | |
template<typename T = DataType> | |
void | _add_triangular_elements (const DenseMatrix &mat, bool fix_format, dispatch_t< T, Sparse >=nullptr) |
add non-diagonal elements to upper triangular components for sparse matrix More... | |
void | _initialize_quadmat (const DenseMatrix &mat, const std::vector< IndexType > &labels_vec, bool fix_format) |
initialize matrix with matrix and labels the form of matrix is assumed to be the following two forms: More... | |
Linear< IndexType, FloatType > | _generate_linear () const |
template<typename T = DataType> | |
Quadratic< IndexType, FloatType > | _generate_quadratic (dispatch_t< T, Dense >=nullptr) const |
template<typename T = DataType> | |
Quadratic< IndexType, FloatType > | _generate_quadratic (dispatch_t< T, Sparse >=nullptr) const |
void | _initialize_quadmat (const SparseMatrix &mat, const std::vector< IndexType > &labels_vec) |
initialize matrix with matrix and labels the form of matrix is assumed to be the following form: More... | |
template<typename T = DataType> | |
void | _spin_to_binary (dispatch_t< T, Dense >=nullptr) |
change internal variable from Ising to QUBO ones for dense matrix The following conversion is applied: More... | |
template<typename T = DataType> | |
void | _spin_to_binary (dispatch_t< T, Sparse >=nullptr) |
change internal variable from Ising to QUBO ones for sparse matrix The following conversion is applied: More... | |
template<typename T = DataType> | |
void | _binary_to_spin (dispatch_t< T, Dense >=nullptr) |
change internal variable from QUBO to Ising ones for dense matrix The following conversion is applied: More... | |
template<typename T = DataType> | |
void | _binary_to_spin (dispatch_t< T, Sparse >=nullptr) |
change internal variable from QUBO to Ising ones for sparse matrix The following conversion is applied: More... | |
Protected Attributes | |
Matrix | _quadmat |
quadratic dense-type matrix The stored matrix has the following triangular form: More... | |
std::vector< IndexType > | _idx_to_label |
vector for converting index to label the list is asssumed to be sorted More... | |
std::unordered_map< IndexType, size_t > | _label_to_idx |
dict for converting label to index More... | |
FloatType | m_offset |
The energy offset associated with the model. More... | |
Vartype | m_vartype = Vartype::NONE |
The model's type. More... | |
Private Types | |
template<typename T , typename U > | |
using | dispatch_t = std::enable_if_t< std::is_same_v< T, U >, std::nullptr_t > |
template type for dispatch used for SFINAE More... | |
Class for dense binary quadratic model.
IndexType | index type. type must be hashable and comparable. |
FloatType | |
IndexType |
using cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::DenseMatrix = Eigen::Matrix<FloatType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> |
|
private |
template type for dispatch used for SFINAE
T | |
U |
using cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::json = nlohmann::json |
using cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::Matrix = std::conditional_t<std::is_same_v<DataType, Dense>, DenseMatrix, SparseMatrix> |
using cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::SparseMatrix = Eigen::SparseMatrix<FloatType, Eigen::RowMajor> |
using cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::SpIter = typename SparseMatrix::InnerIterator |
using cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::Vector = Eigen::Matrix<FloatType, Eigen::Dynamic, 1> |
|
inline |
BinaryQuadraticModel constructor.
linear | |
quadratic | |
offset | |
vartype |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat().
|
inline |
BinaryQuadraticModel constructor.
linear | |
quadratic | |
vartype |
|
inline |
BinaryQuadraticModel constructor (with matrix);.
mat | |
labels_vec | |
offset | |
vartype |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat().
|
inline |
BinaryQuadraticModel constructor (with matrix);.
mat | |
labels_vec | |
vartype |
|
inline |
BinaryQuadraticModel constructor (with sparse matrix); this constructor is for developers.
mat | |
labels_vec | |
offset | |
vartype |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat().
|
inline |
BinaryQuadraticModel constructor (with sparse matrix); this constructor is for developers.
mat | |
labels_vec | |
vartype |
|
default |
|
inlineprotected |
add new label if label_i already exists, this process is skipped.
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_insert_label_into_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_interaction(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_variable().
|
inlineprotected |
add non-diagonal elements to upper triangular components for dense matrix
T |
mat | |
fix_format |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat().
|
inlineprotected |
add non-diagonal elements to upper triangular components for sparse matrix
T |
mat | |
fix_format |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
change internal variable from QUBO to Ising ones for dense matrix The following conversion is applied:
\[ \mathrm{offset} += \frac{1}{4}\sum_{i<j} Q_{ij} + \frac{1}{2}\sum_{i}Q_{ii} \]
\[ h_i += \frac{1}{4}\left(\sum_{j}Q_{ji}+\sum_{j}Q_{ij}\right) + \frac{1}{2}Q_{ii} \]
\[ J_{ij} = \frac{1}{4}Q_{ij} \]
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype, and cimod::SPIN.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype().
|
inlineprotected |
change internal variable from QUBO to Ising ones for sparse matrix The following conversion is applied:
\[ \mathrm{offset} += \frac{1}{4}\sum_{i<j} Q_{ij} + \frac{1}{2}\sum_{i}Q_{ii} \]
\[ h_i += \frac{1}{4}\left(\sum_{j}Q_{ji}+\sum_{j}Q_{ij}\right) + \frac{1}{2}Q_{ii} \]
\[ J_{ij} = \frac{1}{4}Q_{ij} \]
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype, and cimod::SPIN.
|
inlineprotected |
delete label if label_i does not exist, this process is skipped.
label_i | |
force_delete | if true, delete label whenever there exists corresponding nonzero elements in the matrix. otherwise, delete label only if there are no corresponding nonzero elements in the matrix. |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label_from_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_interaction(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_variable().
|
inlineprotected |
delete row and column that corresponds to existing label from _quadmat for dense matrix
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label().
|
inlineprotected |
delete row and column that corresponds to existing label from _quadmat for sparse matrix
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_linear().
|
inlineprotected |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_quadratic().
|
inlineprotected |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_num_variables().
|
inlineprotected |
initialize matrix with matrix and labels the form of matrix is assumed to be the following two forms:
\[ \begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ J_{1,0} & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ J_{N-1,0} & J_{N-1,1} & \cdots & J_{N-1,N-1} & h_{N-1}\\ h_{0} & h_{1} & \cdots & h_{N-1} & 1 \\ \end{pmatrix} \]
or
\[ \begin{pmatrix} h_{0} & J_{0,1} & \cdots & J_{0,N-1}\\ J_{1,0} & h_{1} & \cdots & J_{1,N-1}\\ \vdots & \vdots & \vdots & \vdots\\ J_{N-1,0} & J_{N-1,1} & \cdots & h_{N-1}\\ \end{pmatrix} \]
if fix_format is set to false, the following shape is assumed:
\[ \begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ 0 & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & J_{N-1,N-1} & h_{N-1}\\ 0 & 0 & \cdots & 0 & 1 \\ \end{pmatrix} \]
mat | |
labels | |
fix_format |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_triangular_elements(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx().
|
inlineprotected |
initialize matrix with linear and quadratic dicts (for dense matrix)
linear | |
quadratic |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::BinaryQuadraticModel().
|
inlineprotected |
initialize matrix with linear and quadratic dicts (for sparse matrix)
linear | |
quadratic |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx().
|
inlineprotected |
initialize matrix with matrix and labels the form of matrix is assumed to be the following form:
\[ \begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ 0 & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & J_{N-1,N-1} & h_{N-1}\\ 0 & 0 & \cdots & 0 & 1 \\ \end{pmatrix} \]
mat | |
labels_vec |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx().
|
inlineprotected |
insert row and column that corresponds to added label into _quadmat for dense matrix
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label().
|
inlineprotected |
insert row and column that corresponds to added label into _quadmat for sparse matrix
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
get reference of _quadmat(i,i)
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get().
|
inlineprotected |
get reference of _quadmat(i,i)
label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get().
|
inlineprotected |
get reference of _quadmat(i,j)
label_i | |
label_j |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_quadratic(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_interaction().
|
inlineprotected |
get reference of _quadmat(i,j)
label_i | |
label_j |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get().
|
inlineprotected |
calculate maximum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate maximum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate maximum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate maximum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate minimum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate minimum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate minimum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
calculate minimum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
access elements for dense matrix
T |
i | |
j | |
dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat().
|
inlineprotected |
access elements for dense matrix
T |
i | |
j | |
dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
access elements for sparse matrix
T |
i | |
j | |
dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
access elements for sparse matrix
T |
i | |
j | |
dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inlineprotected |
set _label_to_idx from _idx_to_label
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat().
|
inlineprotected |
change internal variable from Ising to QUBO ones for dense matrix The following conversion is applied:
\[ \mathrm{offset} += \sum_{i<j} J_{ij} - \sum_{i}h_{i} \]
\[ Q_ii += -2\left(\sum_{j}J_{ji}+\sum_{j}J_{ij}\right) + 2h_{i} \]
\[ Q_{ij} = 4J_{ij} \]
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype().
|
inlineprotected |
change internal variable from Ising to QUBO ones for sparse matrix The following conversion is applied:
\[ \mathrm{offset} += \sum_{i<j} J_{ij} - \sum_{i}h_{i} \]
\[ Q_ii += -2\left(\sum_{j}J_{ji}+\sum_{j}J_{ij}\right) + 2h_{i} \]
\[ Q_{ij} = 4J_{ij} \]
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype.
|
inline |
Add an interaction and/or quadratic bias to a binary quadratic model.
u | |
v | |
bias |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_interactions_from(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_interactions_from(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables().
|
inline |
Add interactions and/or quadratic biases to a binary quadratic model.
quadratic |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_interaction().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::BinaryQuadraticModel().
|
inline |
Add specified value to the offset of a binary quadratic model.
offset |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::fix_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::flip_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_offset(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::remove_offset().
|
inline |
Add variable v and/or its bias to a binary quadratic model.
v | |
bias |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_variables_from(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_variables_from(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::fix_variable().
|
inline |
Add variables and/or linear biases to a binary quadratic model.
linear |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_variable().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::BinaryQuadraticModel().
|
inline |
**
Create a binary quadratic model with the specified vartype. This function does not return any object.
vartype |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype, cimod::SPIN, and cimod.model.legacy.binary_quadratic_model::vartype.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::flip_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_qubo(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_qubo().
|
inline |
Create a binary quadratic model with the specified vartype.
This function generates and returns a new object.
vartype | |
inplace | if set true, the current object is converted. |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), and cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Return true if the variable contains v.
v |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx.
|
inline |
Create an empty BinaryQuadraticModel.
References cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Determine the energies of the given samples.
samples_like |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::energy().
|
inline |
Determine the energy of the specified sample of a binary quadratic model.
sample |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::energies(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::energies().
|
inline |
Fix the value of a variable and remove it from a binary quadratic model.
v | |
value |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_interactions_from(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_variable().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variables(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::fix_variables().
|
inline |
Fix the value of the variables and remove it from a binary quadratic model.
fixed |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable().
|
inline |
Flip variable v in a binary quadratic model.
v |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype, and cimod::SPIN.
|
inlinestatic |
Create a binary quadratic model from an Ising problem.
linear | |
quadratic | |
offset |
.Vartype.SPIN
. References cimod::SPIN.
|
inlinestatic |
Create a binary quadratic model from a QUBO model.
Q | |
offset |
.Vartype.BINARY
. References cimod::BINARY.
|
inlinestatic |
Create a BinaryQuadraticModel instance from a serializable object.
IndexType_serial | |
FloatType_serial |
input |
References cimod::BINARY, cimod::SPIN, and cimod.model.legacy.binary_quadratic_model::vartype.
|
inlinestatic |
Create a BinaryQuadraticModel instance from a serializable object.
IndexType_serial | |
FloatType_serial |
input |
References cimod::BINARY, cimod::SPIN, and cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Get linear object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_linear().
|
inline |
Get the element of linear object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_qubo(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_qubo().
|
inline |
get the number of variables
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::interaction_matrix(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::length(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::length(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().
|
inline |
Get the offset.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_qubo(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_qubo().
|
inline |
Get uadratic object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_quadratic().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable().
|
inline |
Get the element of quadratic object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_ising(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_qubo(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_qubo().
|
inline |
Get variables.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::interaction_matrix(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().
|
inline |
Get the vartype object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_variable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::change_vartype().
|
inline |
generate (Dense or Sparse) interaction matrix with given list of indices The generated matrix will be the following triangular matrix:
\[ \begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ 0 & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & J_{N-1,N-1} & h_{N-1}\\ 0 & 0 & \cdots & 0 & 1 \\ \end{pmatrix} \]
indices |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat.
|
inline |
Return the number of variables.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_num_variables().
|
inline |
Normalizes the biases of the binary quadratic model such that they fall in the provided range(s), and adjusts the offset appropriately.
bias_range | |
use_quadratic_range | |
quadratic_range | |
ignored_variables | |
ignored_interactions | |
ignored_offset |
|
inline |
Remove interaction of variables u, v from a binary quadratic model.
u | |
v |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_interactions_from(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::remove_interactions_from().
|
inline |
Remove all specified interactions from the binary quadratic model.
interactions |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_interaction().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::fix_variable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::remove_variable().
|
inline |
Set the binary quadratic model's offset to zero.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_offset(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset.
|
inline |
Remove variable v and all its interactions from a binary quadratic model.
v |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::fix_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::fix_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::remove_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_variables_from(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::remove_variables_from().
|
inline |
Remove specified variables and all of their interactions from a binary quadratic model.
variables |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_variable().
|
inline |
Multiply by the specified scalar all the biases and offset of a binary quadratic model.
scalar | |
ignored_variables | |
ignored_interactions | |
ignored_offset |
|
inline |
Convert a binary quadratic model to Ising format.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_quadratic(), and cimod::SPIN.
|
inline |
Convert a binary quadratic model to QUBO format.
References cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_offset(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_quadratic().
|
inline |
Convert the binary quadratic model to a dense-version serializable object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_num_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype, and cimod::SPIN.
|
inline |
Convert the binary quadratic model to a serializable object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_num_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_vartype, and cimod::SPIN.
|
protected |
vector for converting index to label the list is asssumed to be sorted
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_triangular_elements(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_num_variables(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_variables().
|
protected |
dict for converting label to index
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label_from_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_insert_label_into_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::contains(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::energy(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::flip_variable().
|
protected |
quadratic dense-type matrix The stored matrix has the following triangular form:
\[ \begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ 0 & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & J_{N-1,N-1} & h_{N-1}\\ 0 & 0 & \cdots & 0 & 1 \\ \end{pmatrix} \]
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_triangular_elements(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label_from_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_insert_label_into_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_max_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_max_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_min_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_min_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::energy(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::flip_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::interaction_matrix(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().
|
protected |
The energy offset associated with the model.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::add_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::energy(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::energy(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::get_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::remove_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::remove_offset(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_serializable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().
|
protected |
The model's type.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::change_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::contract_variables(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::energy(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::flip_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::flip_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::get_vartype(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_serializable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().