|
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. | |
| 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. | |
| BinaryQuadraticModel (const Linear< IndexType, FloatType > &linear, const Quadratic< IndexType, FloatType > &quadratic, const Vartype vartype) | |
| BinaryQuadraticModel constructor. | |
| 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);. | |
| BinaryQuadraticModel (const Eigen::Ref< const DenseMatrix > &mat, const std::vector< IndexType > &labels_vec, const Vartype vartype, bool fix_format=true) | |
| BinaryQuadraticModel constructor (with matrix);. | |
| 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. | |
| BinaryQuadraticModel (const SparseMatrix &mat, const std::vector< IndexType > &labels_vec, const Vartype vartype) | |
| BinaryQuadraticModel constructor (with sparse matrix); this constructor is for developers. | |
| BinaryQuadraticModel (const BinaryQuadraticModel &)=default | |
| size_t | get_num_variables () const |
| get the number of variables | |
| size_t | length () const |
| Return the number of variables. | |
| bool | contains (const IndexType &v) const |
| Return true if the variable contains v. | |
| FloatType | get_linear (IndexType label_i) const |
| Get the element of linear object. | |
| Linear< IndexType, FloatType > | get_linear () const |
| Get linear object. | |
| FloatType | get_quadratic (IndexType label_i, IndexType label_j) const |
| Get the element of quadratic object. | |
| Quadratic< IndexType, FloatType > | get_quadratic () const |
| Get uadratic object. | |
| FloatType | get_offset () const |
| Get the offset. | |
| Vartype | get_vartype () const |
| Get the vartype object. | |
| const std::vector< IndexType > & | get_variables () const |
| Get variables. | |
| BinaryQuadraticModel< IndexType, FloatType, DataType > | empty (Vartype vartype) |
| Create an empty BinaryQuadraticModel. | |
| void | add_variable (const IndexType &v, const FloatType &bias) |
| Add variable v and/or its bias to a binary quadratic model. | |
| void | add_variables_from (const Linear< IndexType, FloatType > &linear) |
| Add variables and/or linear biases to a binary quadratic model. | |
| void | add_interaction (const IndexType &u, const IndexType &v, const FloatType &bias) |
| Add an interaction and/or quadratic bias to a binary quadratic model. | |
| void | add_interactions_from (const Quadratic< IndexType, FloatType > &quadratic) |
| Add interactions and/or quadratic biases to a binary quadratic model. | |
| void | remove_variable (const IndexType &v) |
| Remove variable v and all its interactions from a binary quadratic model. | |
| void | remove_variables_from (const std::vector< IndexType > &variables) |
| Remove specified variables and all of their interactions from a binary quadratic model. | |
| void | remove_interaction (const IndexType &u, const IndexType &v) |
| Remove interaction of variables u, v from a binary quadratic model. | |
| void | remove_interactions_from (const std::vector< std::pair< IndexType, IndexType > > &interactions) |
| Remove all specified interactions from the binary quadratic model. | |
| void | add_offset (const FloatType &offset) |
| Add specified value to the offset of a binary quadratic model. | |
| void | remove_offset () |
| Set the binary quadratic model's offset to zero. | |
| 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. | |
| 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. | |
| void | fix_variable (const IndexType &v, const int32_t &value) |
| Fix the value of a variable and remove it from a binary quadratic model. | |
| 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. | |
| void | flip_variable (const IndexType &v) |
| Flip variable v in a binary quadratic model. | |
| void | change_vartype (const Vartype &vartype) |
| ** | |
| BinaryQuadraticModel< IndexType, FloatType, DataType > | change_vartype (const Vartype &vartype, bool inplace) |
| Create a binary quadratic model with the specified vartype. | |
| FloatType | energy (const Sample< IndexType > &sample) const |
| Determine the energy of the specified sample of a binary quadratic model. | |
| std::vector< FloatType > | energies (const std::vector< Sample< IndexType > > &samples_like) const |
| Determine the energies of the given samples. | |
| std::tuple< Quadratic< IndexType, FloatType >, FloatType > | to_qubo () |
| Convert a binary quadratic model to QUBO format. | |
| std::tuple< Linear< IndexType, FloatType >, Quadratic< IndexType, FloatType >, FloatType > | to_ising () |
| Convert a binary quadratic model to Ising format. | |
| Matrix | interaction_matrix () const |
| generate (Dense or Sparse) interaction matrix with given list of indices The generated matrix will be the following triangular matrix: | |
| template<typename T = DataType> | |
| json | to_serializable (dispatch_t< T, Dense >=nullptr) const |
| Convert the binary quadratic model to a dense-version serializable object. | |
| template<typename T = DataType> | |
| json | to_serializable (dispatch_t< T, Sparse >=nullptr) const |
| Convert the binary quadratic model to a serializable object. | |
Protected Member Functions | |
| void | _set_label_to_idx () |
| set _label_to_idx from _idx_to_label | |
| template<typename T = DataType> | |
| FloatType & | _quadmat_get (size_t i, size_t j, dispatch_t< T, Dense >=nullptr) |
| access elements for dense matrix | |
| template<typename T = DataType> | |
| FloatType | _quadmat_get (size_t i, size_t j, dispatch_t< T, Dense >=nullptr) const |
| access elements for dense matrix | |
| template<typename T = DataType> | |
| FloatType & | _quadmat_get (size_t i, size_t j, dispatch_t< T, Sparse >=nullptr) |
| access elements for sparse matrix | |
| template<typename T = DataType> | |
| FloatType | _quadmat_get (size_t i, size_t j, dispatch_t< T, Sparse >=nullptr) const |
| access elements for sparse matrix | |
| FloatType & | _mat (IndexType label_i, IndexType label_j) |
| get reference of _quadmat(i,j) | |
| FloatType & | _mat (IndexType label_i) |
| get reference of _quadmat(i,i) | |
| FloatType | _mat (IndexType label_i, IndexType label_j) const |
| get reference of _quadmat(i,j) | |
| FloatType | _mat (IndexType label_i) const |
| get reference of _quadmat(i,i) | |
| template<typename T = DataType> | |
| FloatType | _max_linear (dispatch_t< T, Dense >=nullptr) const |
| calculate maximum element in linear term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _max_quadratic (dispatch_t< T, Dense >=nullptr) const |
| calculate maximum element in quadratic term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _min_linear (dispatch_t< T, Dense >=nullptr) const |
| calculate minimum element in linear term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _min_quadratic (dispatch_t< T, Dense >=nullptr) const |
| calculate minimum element in quadratic term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _max_linear (dispatch_t< T, Sparse >=nullptr) const |
| calculate maximum element in linear term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _max_quadratic (dispatch_t< T, Sparse >=nullptr) const |
| calculate maximum element in quadratic term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _min_linear (dispatch_t< T, Sparse >=nullptr) const |
| calculate minimum element in linear term for dense graph | |
| template<typename T = DataType> | |
| FloatType | _min_quadratic (dispatch_t< T, Sparse >=nullptr) const |
| calculate minimum element in quadratic term for dense graph | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| void | _add_new_label (IndexType label_i) |
| add new label if label_i already exists, this process is skipped. | |
| void | _delete_label (IndexType label_i, bool force_delete=true) |
| delete label if label_i does not exist, this process is skipped. | |
| 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) | |
| 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) | |
| 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 | |
| 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 | |
| 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: | |
| 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: | |
| 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: | |
| 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: | |
| 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: | |
| 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: | |
Protected Attributes | |
| Matrix | _quadmat |
| quadratic dense-type matrix The stored matrix has the following triangular form: | |
| std::vector< IndexType > | _idx_to_label |
| vector for converting index to label the list is asssumed to be sorted | |
| std::unordered_map< IndexType, size_t > | _label_to_idx |
| dict for converting label to index | |
| FloatType | m_offset |
| The energy offset associated with the model. | |
| Vartype | m_vartype = Vartype::NONE |
| The model's type. | |
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 | |
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(), and declare_BQM().

|
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(), and declare_BQM().

|
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), and declare_BQM().
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
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, declare_BQM(), 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, declare_BQM(), 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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), and declare_BQM().
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and declare_BQM().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::get_linear().


|
inlineprotected |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and declare_BQM().
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, declare_BQM(), 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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), and declare_BQM().

|
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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), and declare_BQM().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::BinaryQuadraticModel(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::BinaryQuadraticModel(), and 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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), and declare_BQM().

|
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_set_label_to_idx(), and declare_BQM().

|
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
get reference of _quadmat(i,i)
| label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and declare_BQM().

|
inlineprotected |
get reference of _quadmat(i,i)
| label_i |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and declare_BQM().

|
inlineprotected |
get reference of _quadmat(i,j)
| label_i | |
| label_j |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and declare_BQM().
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, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), and declare_BQM().

|
inlineprotected |
calculate maximum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate maximum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate maximum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate maximum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate minimum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate minimum element in linear term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate minimum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
calculate minimum element in quadratic term for dense graph
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
access elements for dense matrix
| T |
| i | |
| j | |
| dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().
Referenced by 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 >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), 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, and declare_BQM().

|
inlineprotected |
access elements for sparse matrix
| T |
| i | |
| j | |
| dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
access elements for sparse matrix
| T |
| i | |
| j | |
| dispatch_t |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, and declare_BQM().

|
inlineprotected |
set _label_to_idx from _idx_to_label
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and declare_BQM().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_add_new_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_delete_label(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), 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, declare_BQM(), 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, declare_BQM(), 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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), and declare_BQM().
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(), and declare_BQM().
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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), and declare_BQM().
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(), and declare_BQM().
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, and cimod::SPIN.
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 declare_BQM().

|
inline |
Return true if the variable contains v.
| v |
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_label_to_idx, and declare_BQM().

|
inline |
Create an empty BinaryQuadraticModel.
References declare_BQM().

|
inline |
Determine the energies of the given samples.
| samples_like |
References declare_BQM(), and 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, declare_BQM(), 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(), declare_BQM(), 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 declare_BQM(), and 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(), declare_BQM(), 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 declare_BQM(), and cimod::SPIN.

|
inlinestatic |
Create a binary quadratic model from a QUBO model.
| Q | |
| offset |
.Vartype.BINARY. References cimod::BINARY, and declare_BQM().

|
inlinestatic |
Create a BinaryQuadraticModel instance from a serializable object.
| IndexType_serial | |
| FloatType_serial |
| input |
References cimod::BINARY, declare_BQM(), and cimod::SPIN.

|
inlinestatic |
Create a BinaryQuadraticModel instance from a serializable object.
| IndexType_serial | |
| FloatType_serial |
| input |
References cimod::BINARY, declare_BQM(), and cimod::SPIN.

|
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(), and declare_BQM().

|
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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().

|
inline |
Get the offset.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::m_offset.
|
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(), and declare_BQM().

|
inline |
Get variables.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_idx_to_label.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::interaction_matrix(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable(), 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(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_variable().

|
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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), and declare_BQM().
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 declare_BQM(), and 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(), and declare_BQM().
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 declare_BQM(), and 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(), declare_BQM(), and cimod::SPIN.

|
inline |
Convert a binary quadratic model to QUBO format.
References cimod::BINARY, cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::change_vartype(), and declare_BQM().

|
inline |
Convert the binary quadratic model to a dense-version serializable object.
References cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat, cimod::BINARY, declare_BQM(), 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, declare_BQM(), 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 >::_add_triangular_elements(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), 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 >::_generate_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), 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 >::_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 >::_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 >::_insert_label_into_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_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 >::_add_triangular_elements(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_binary_to_spin(), 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 >::_delete_label_from_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_generate_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_initialize_quadmat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_insert_label_into_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_insert_label_into_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_mat(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_max_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_max_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_max_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_max_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_min_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_min_linear(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_min_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_min_quadratic(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_quadmat_get(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), 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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable(), 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 >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), 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, 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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::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 >::_binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::_spin_to_binary(), 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 >::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(), cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable(), and cimod::BinaryQuadraticModel< IndexType, FloatType, DataType >::to_serializable().