|
cimod
C++ library for a binary (and polynomial) quadratic model.
|
Namespaces | |
| namespace | _version |
| namespace | model |
| namespace | utils |
| namespace | vartype |
Classes | |
| class | BinaryPolynomialModel |
| Class for BinaryPolynomialModel. More... | |
| class | BinaryQuadraticModel |
| Class for dense binary quadratic model. More... | |
| class | BinaryQuadraticModel< IndexType, FloatType, Dict > |
| Class for legacy binary quadratic model (dict datastructure). More... | |
| struct | Dense |
| struct | Dict |
| struct | pair_hash |
| Hash function for std::unordered_map. More... | |
| struct | Sparse |
| struct | vector_hash |
Typedefs | |
| template<typename IndexType , typename FloatType > | |
| using | Polynomial = std::unordered_map< std::vector< IndexType >, FloatType, vector_hash > |
| Type alias for the polynomial interactions as std::unordered_map. | |
| template<typename IndexType > | |
| using | PolynomialKeyList = std::vector< std::vector< IndexType > > |
| Type alias for the indices of the polynomial interactions (namely, the list of keys of the polynomial interactions as std::unordered_map) as std::vector<std::vector>>. | |
| template<typename FloatType > | |
| using | PolynomialValueList = std::vector< FloatType > |
| Type alias for the values of the polynomial interactions (namely, the list of values of the polynomial interactions as std::unordered_map) as std::vector. | |
| template<typename IndexType > | |
| using | Sample = std::unordered_map< IndexType, int32_t > |
| Type alias for sample, which represents the spin or binary configurations. | |
| template<typename IndexType , typename FloatType > | |
| using | Linear = std::unordered_map< IndexType, FloatType > |
| Type alias for linear bias. | |
| template<typename IndexType , typename FloatType > | |
| using | Quadratic = std::unordered_map< std::pair< IndexType, IndexType >, FloatType, pair_hash > |
| Type alias for quadratic bias. | |
| template<typename IndexType , typename FloatType > | |
| using | Adjacency = std::unordered_map< IndexType, std::unordered_map< IndexType, FloatType > > |
| Type alias for adjacency list. | |
Enumerations | |
| enum class | Vartype { SPIN = 0 , BINARY , NONE = -1 } |
| Enum class for representing problem type. More... | |
Functions | |
| template<class C_key , class C_value , class Hash > | |
| void | insert_or_assign (std::unordered_map< C_key, C_value, Hash > &um, const C_key &key, const C_value &val) |
| Insert or assign a element of unordered_map (for C++14 or C++11) | |
| template<typename IndexType > | |
| void | FormatPolynomialKey (std::vector< IndexType > *key, const Vartype &vartype) |
| Format the input key: for example, {2,1,1}-->{1,2} for BINARY variable and {2,1,1}-->{2} for SPIN variable. | |
| cimod::Vartype | ToCimodVartype (const std::string &vartype_str) |
| Convert vartype from string to cimod::Vartype. | |
| template<typename IntegerType > | |
| void | CheckVariables (const std::vector< IntegerType > &configurations, const Vartype &vartype) |
| Convert vartype from string to cimod::Vartype. | |
| void | CheckVartypeNotNONE (const Vartype &vartype) |
| Check if the input vartype is not Vartype::NONE. | |
| bool | check_vartype (const int32_t &var, const Vartype &vartype) |
| Check that the variable has appropriate value. | |
Variables | |
| __path__ = extend_path(__path__, __name__) | |
| list | __all__ |
| using cimod::Adjacency = typedef std::unordered_map<IndexType, std::unordered_map<IndexType, FloatType> > |
Type alias for adjacency list.
| IndexType |
| using cimod::Linear = typedef std::unordered_map<IndexType, FloatType> |
Type alias for linear bias.
| IndexType |
| using cimod::Polynomial = typedef std::unordered_map<std::vector<IndexType>, FloatType, vector_hash> |
Type alias for the polynomial interactions as std::unordered_map.
| IndexType | |
| FloatType |
| using cimod::PolynomialKeyList = typedef std::vector<std::vector<IndexType> > |
Type alias for the indices of the polynomial interactions (namely, the list of keys of the polynomial interactions as std::unordered_map) as std::vector<std::vector>>.
| IndexType |
Type alias for the values of the polynomial interactions (namely, the list of values of the polynomial interactions as std::unordered_map) as std::vector.
| FloatType |
| using cimod::Quadratic = typedef std::unordered_map<std::pair<IndexType, IndexType>, FloatType, pair_hash> |
Type alias for quadratic bias.
| IndexType |
Type alias for sample, which represents the spin or binary configurations.
Type alias for sample.
| IndexType |
|
strong |
Check that the variable has appropriate value.
| var | |
| vartype |
References BINARY, declare_BQM(), and SPIN.
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::energy().


| void cimod::CheckVariables | ( | const std::vector< IntegerType > & | configurations, |
| const Vartype & | vartype | ||
| ) |
Convert vartype from string to cimod::Vartype.
| IntegerType | The type of spin/binary configuration |
| configurations | The spin/binary configuration |
| vartype | The model's type. cimod::Vartype::SPIN or cimod::Vartype::BINARY. |
References BINARY, declare_BQM(), and SPIN.

Check if the input vartype is not Vartype::NONE.
| vartype | The model's type. cimod::Vartype::SPIN or cimod::Vartype::BINARY. |
References NONE.
Format the input key: for example, {2,1,1}-->{1,2} for BINARY variable and {2,1,1}-->{2} for SPIN variable.
| IndexType | Used to represent the indices of variables |
| key | This may be formatted. |
| vartype | The model's type. cimod::Vartype::SPIN or cimod::Vartype::BINARY. |
References BINARY, declare_BQM(), and SPIN.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().


| void cimod::insert_or_assign | ( | std::unordered_map< C_key, C_value, Hash > & | um, |
| const C_key & | key, | ||
| const C_value & | val | ||
| ) |
Insert or assign a element of unordered_map (for C++14 or C++11)
| C_key | |
| C_value |
| um | |
| key | |
| val |
References declare_BQM().
Referenced by cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_interaction(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::add_variable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::binary_to_spin(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::from_serializable(), cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::spin_to_binary(), and cimod::BinaryQuadraticModel< IndexType, FloatType, Dict >::to_qubo().


| cimod::Vartype cimod::ToCimodVartype | ( | const std::string & | vartype_str | ) |
Convert vartype from string to cimod::Vartype.
| vartype_str | "SPIN" or "BINARY" |
References BINARY, declare_BQM(), and SPIN.

|
private |
|
private |