|
cimod
C++ library for a binary (and polynomial) quadratic model.
|
Class for BinaryPolynomialModel. More...
#include <binary_polynomial_model.hpp>
Public Member Functions | |
| BinaryPolynomialModel (const Polynomial< IndexType, FloatType > &poly_map, const Vartype vartype) | |
| BinaryPolynomialModel constructor. | |
| BinaryPolynomialModel (PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype) | |
| BinaryPolynomialModel constructor. | |
| BinaryPolynomialModel (const PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype) | |
| BinaryPolynomialModel constructor. | |
| BinaryPolynomialModel (const std::vector< IndexType > &variables, const PolynomialKeyList< std::size_t > &poly_key_distance_list, const PolynomialValueList< FloatType > &poly_value_list, const Vartype vartype) | |
| BinaryPolynomialModel constructor. | |
| Polynomial< IndexType, FloatType > | GetPolynomial () const |
| Get the Polynomial object. | |
| FloatType | GetPolynomial (std::vector< IndexType > &key) const |
| Get the specific value of the interaction according to the key representing the indices of the polynomial interactions. | |
| FloatType | GetPolynomial (const std::vector< IndexType > &key) const |
| Get the specific value of the interaction according to the key representing the indices of the polynomial interactions. | |
| const std::unordered_map< IndexType, int64_t > & | GetVariablesToIntegers () |
| Get variables_to_integers object. | |
| std::unordered_map< IndexType, int64_t > | GetVariablesToIntegers () const |
| Get variables_to_integers object. | |
| int64_t | GetVariablesToIntegers (const IndexType &index) |
| Get the specific integer number corresponding to the input variable (index). | |
| int64_t | GetVariablesToIntegers (const IndexType &index) const |
| Get the specific integer number corresponding to the input variable (index). | |
| const PolynomialKeyList< IndexType > & | GetKeyList () const |
| Get the PolynomialKeyList object. | |
| const PolynomialValueList< FloatType > & | GetValueList () const |
| Get the PolynomialValueList object. | |
| const std::unordered_map< std::vector< IndexType >, std::size_t, vector_hash > & | GetKeysInv () const |
| Get The inverse key list, which indicates the index of the poly_key_list_ and poly_value_list_. | |
| const std::unordered_set< IndexType > & | GetVariables () const |
| Return the variables as std::unordered_set. | |
| const std::vector< IndexType > & | GetSortedVariables () |
| Return the sorted variables as std::vector. | |
| std::vector< IndexType > | GetSortedVariables () const |
| Return the sorted variables as std::vector. | |
| std::size_t | GetDegree () const |
| Return the maximum degree of interaction. | |
| FloatType | GetOffset () const |
| Return the offset. | |
| Vartype | GetVartype () const |
| Return the vartype. | |
| std::size_t | GetNumInteractions () const |
| Return the number of the interactions. | |
| std::size_t | GetNumVariables () const |
| Return the number of variables. | |
| BinaryPolynomialModel | Empty (const Vartype vartype) const |
| Create an empty BinaryPolynomialModel. | |
| void | Clear () |
| Clear the BinaryPolynomialModel. | |
| void | RemoveInteraction (std::vector< IndexType > &key) |
| Remove the specified interaction from the BinaryPolynomialModel. | |
| void | RemoveInteraction (const std::vector< IndexType > &key) |
| Remove the specified interaction from the BinaryPolynomialModel. | |
| void | RemoveInteractionsFrom (PolynomialKeyList< IndexType > &key_list) |
| Remove the specified interactions from the BinaryPolynomialModel. | |
| void | RemoveInteractionsFrom (const PolynomialKeyList< IndexType > &key_list) |
| Remove the specified interactions from the BinaryPolynomialModel. | |
| void | RemoveOffset () |
| Set the offset of the BinaryPolynomialModel to zero. | |
| void | RemoveVariable (const IndexType &index) |
| Remove a variable from the BinaryPolynomialModel. | |
| void | RemoveVariablesFrom (const std::vector< IndexType > &key) |
| Remove the specified variables from the BinaryPolynomialModel. | |
| void | AddInteraction (std::vector< IndexType > &key, const FloatType &value, const Vartype vartype=Vartype::NONE) |
| Add an interaction to the BinaryPolynomialModel. | |
| void | AddInteraction (const std::vector< IndexType > &key, const FloatType &value, const Vartype vartype=Vartype::NONE) |
| Add an interaction to the BinaryPolynomialModel. | |
| void | AddInteractionsFrom (const Polynomial< IndexType, FloatType > &poly_map, const Vartype vartype=Vartype::NONE) |
| Add interactions to the BinaryPolynomialModel. | |
| void | AddInteractionsFrom (PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype=Vartype::NONE) |
| Add interactions to the BinaryPolynomialModel. | |
| void | AddInteractionsFrom (const PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype=Vartype::NONE) |
| Add interactions to the BinaryPolynomialModel. | |
| void | AddOffset (FloatType offset) |
| Add specified value to the offset of the BinaryPolynomialModel. | |
| FloatType | Energy (const Sample< IndexType > &sample, bool omp_flag=true) const |
| Determine the energy of the specified sample of the BinaryPolynomialModel. | |
| FloatType | Energy (const std::vector< int32_t > &sample_vec, bool omp_flag=true) |
| Determine the energy of the specified sample_vec (as std::vector) of the BinaryPolynomialModel. | |
| PolynomialValueList< FloatType > | Energies (const std::vector< Sample< IndexType > > &samples) const |
| Determine the energies of the given samples. | |
| PolynomialValueList< FloatType > | Energies (const std::vector< std::vector< int32_t > > &samples_vec) |
| Determine the energies of the given samples_vec. | |
| void | Scale (const FloatType scalar, const PolynomialKeyList< IndexType > &ignored_interactions={}, const bool ignored_offset=false) |
| Multiply by the specified scalar all the values of the interactions of the BinaryPolynomialModel. | |
| void | normalize (const std::pair< FloatType, FloatType > &range={ 1.0, 1.0 }, const PolynomialKeyList< IndexType > &ignored_interactions={}, const bool ignored_offset=false) |
| Normalizes the values of the interactions of the BinaryPolynomialModel such that they fall in the provided range(s). | |
| BinaryPolynomialModel | ChangeVartype (const Vartype vartype, const bool inplace) |
| Create a BinaryPolynomialModel with the specified vartype. | |
| void | ChangeVartype (const Vartype vartype) |
| Change the vartype of the BinaryPolynomialModel. | |
| bool | HasVariable (const IndexType &index) |
| Check if the specified index is in the BinaryPolynomialModel. | |
| Polynomial< IndexType, FloatType > | ToHubo () const |
| Generate the polynomial interactions corresponding to the vartype being BINARY from the BinaryPolynomialModel. | |
| Polynomial< IndexType, FloatType > | ToHising () const |
| Generate the polynomial interactions corresponding to the vartype being SPIN from the BinaryPolynomialModel. | |
| nlohmann::json | ToSerializable () const |
| Convert the BinaryPolynomialModel to a serializable object. | |
Protected Member Functions | |
| void | SetKeyAndValue (const std::vector< IndexType > &key, const FloatType &value) |
| Set key and value. | |
| std::size_t | IntegerPower (std::size_t base, std::size_t exponent) const |
| Caluculate the base to the power of exponent (std::pow(base, exponent) is too slow). | |
| std::vector< IndexType > | GenerateChangedKey (const std::vector< IndexType > &original_key, const std::size_t num_of_key) const |
| Generate the num_of_key-th the key when the vartype is changed. | |
| BinaryPolynomialModel | ToSpin () const |
| Generate BinaryPolynomialModel with the vartype being SPIN. | |
| BinaryPolynomialModel | ToBinary () const |
| Generate BinaryPolynomialModel with the vartype being BINARY. | |
| void | UpdateVariablesToIntegers () |
| Update sorted_variables_ and variables_to_integers_. | |
| std::unordered_map< IndexType, int64_t > | GenerateVariablesToIntegers () const |
| Generate variables_to_integers. | |
| std::vector< IndexType > | GenerateSortedVariables () const |
| Generate sorted variables. | |
Protected Attributes | |
| std::unordered_set< IndexType > | variables_ |
| Variable list as std::unordered_set. | |
| std::unordered_map< IndexType, std::size_t > | each_variable_num_ |
| The list of the number of the variables appeared in the polynomial interactions as std::unordered_map. | |
| std::unordered_map< IndexType, int64_t > | variables_to_integers_ |
| The correspondence from variables to the integer numbers. | |
| std::vector< IndexType > | sorted_variables_ |
| Sorted variables is represents the correspondence from integer numbers.to the variables. | |
| bool | relabel_flag_for_variables_to_integers_ = true |
| If true variable_to_index must be relabeled. | |
| PolynomialKeyList< IndexType > | poly_key_list_ |
| The list of the indices of the polynomial interactions (namely, the list of keys of the polynomial interactions as std::unordered_map) as std::vector<std::vector>>. | |
| PolynomialValueList< FloatType > | poly_value_list_ |
| The list of the values of the polynomial interactions (namely, the list of values of the polynomial interactions as std::unordered_map) as std::vector. | |
| std::unordered_map< std::vector< IndexType >, std::size_t, vector_hash > | poly_key_inv_ |
| The inverse key list, which indicates the index of the poly_key_list_ and poly_value_list_. | |
| Vartype | vartype_ = Vartype::NONE |
| The model's type. SPIN or BINARY. | |
Class for BinaryPolynomialModel.
| IndexType | |
| FloatType |
|
inline |
BinaryPolynomialModel constructor.
| poly_map | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), declare_BQM(), cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.

|
inline |
BinaryPolynomialModel constructor.
| key_list | |
| value_list | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), declare_BQM(), cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.

|
inline |
BinaryPolynomialModel constructor.
| key_list | |
| value_list | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), declare_BQM(), cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.

|
inline |
BinaryPolynomialModel constructor.
This constructor dose not check the input arguments are valid.
| variables | |
| poly_key_distance_list | |
| poly_value_list | |
| vartype |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::each_variable_num_, cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_inv_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.

|
inline |
Add an interaction to the BinaryPolynomialModel.
| key | |
| value | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), and declare_BQM().

|
inline |
Add an interaction to the BinaryPolynomialModel.
| key | |
| value | |
| vartype |
References cimod::BINARY, declare_BQM(), cimod::FormatPolynomialKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateChangedKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::IntegerPower(), cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue(), cimod::SPIN, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::AddOffset().


|
inline |
Add interactions to the BinaryPolynomialModel.
| poly_map | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), and declare_BQM().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel().


|
inline |
Add interactions to the BinaryPolynomialModel.
| key_list | |
| value_list | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), and declare_BQM().

|
inline |
Add interactions to the BinaryPolynomialModel.
| key_list | |
| value_list | |
| vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), and declare_BQM().

|
inline |
Add specified value to the offset of the BinaryPolynomialModel.
| offset |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction().

|
inline |
Change the vartype of the BinaryPolynomialModel.
References cimod::BINARY, cimod::SPIN, cimod::BinaryPolynomialModel< IndexType, FloatType >::ToBinary(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin().

|
inline |
Create a BinaryPolynomialModel with the specified vartype.
| vartype | |
| inplace |
References cimod::BINARY, declare_BQM(), cimod::SPIN, cimod::BinaryPolynomialModel< IndexType, FloatType >::ToBinary(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin().

|
inline |
Clear the BinaryPolynomialModel.
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::each_variable_num_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_inv_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_to_integers_.

|
inline |
|
inline |
Determine the energies of the given samples.
| samples |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy().

|
inline |
Determine the energies of the given samples_vec.
| samples_vec |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy().

|
inline |
Determine the energy of the specified sample of the BinaryPolynomialModel.
When omp_flag is true, the OpenMP is used to calculate the energy in parallel.
| sample | |
| omp_flag |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumInteractions(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::Energies(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::Energies().


|
inline |
Determine the energy of the specified sample_vec (as std::vector) of the BinaryPolynomialModel.
When omp_flag is true, the OpenMP is used to calculate the energy in parallel.
| sample_vec | |
| omp_flag |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumInteractions(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_to_integers_.

|
inlinestatic |
Create a BinaryPolynomialModel from a higher ordere Ising model.
| poly_map |
References declare_BQM(), and cimod::SPIN.

|
inlinestatic |
Create a BinaryPolynomialModel from a higher ordere Ising model.
| key_list | |
| value_list |
References declare_BQM(), and cimod::SPIN.

|
inlinestatic |
Create a BinaryPolynomialModel from a higher ordere Ising model.
| key_list | |
| value_list |
References declare_BQM(), and cimod::SPIN.

|
inlinestatic |
Create a BinaryPolynomialModel from a Hubo model.
| poly_map |
References cimod::BINARY, and declare_BQM().

|
inlinestatic |
Create a BinaryPolynomialModel from a Hubo model.
| key_list | |
| value_list |
References cimod::BINARY, and declare_BQM().

|
inlinestatic |
Create a BinaryPolynomialModel from a Hubo model.
| key_list | |
| value_list |
References cimod::BINARY, and declare_BQM().

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

|
inlineprotected |
Generate the num_of_key-th the key when the vartype is changed.
| original_key | |
| num_of_key |
References declare_BQM().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo().


|
inlineprotected |
Generate sorted variables.
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers().


|
inlineprotected |
Generate variables_to_integers.
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateSortedVariables().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers().


|
inline |
Return the maximum degree of interaction.
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_.

|
inline |
Get the PolynomialKeyList object.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_.
|
inline |
Get The inverse key list, which indicates the index of the poly_key_list_ and poly_value_list_.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_inv_.
|
inline |
Return the number of the interactions.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSerializable().

|
inline |
Return the number of variables.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy().

|
inline |
Return the offset.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial().

|
inline |
Get the Polynomial object.
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::GetOffset(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo().


|
inline |
Get the specific value of the interaction according to the key representing the indices of the polynomial interactions.
If the interaction corresponding to the key dose not exist, return 0
| key |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial().

|
inline |
Get the specific value of the interaction according to the key representing the indices of the polynomial interactions.
If the interaction corresponding to the key dose not exist, return 0
| key |
References declare_BQM(), cimod::FormatPolynomialKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_inv_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.

|
inline |
Return the sorted variables as std::vector.
This function may need O(N) calculation time (N is the number of the variables).
References cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::sorted_variables_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSerializable().


|
inline |
Return the sorted variables as std::vector.
This function may need O(N) calculation time (N is the number of the variables).
References cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::sorted_variables_.

|
inline |
Get the PolynomialValueList object.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_.
|
inline |
Return the variables as std::unordered_set.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_.
|
inline |
Get variables_to_integers object.
This function may need O(N) calculation time (N is the number of the variables).
References cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_to_integers_.

|
inline |
Get variables_to_integers object.
This function may need O(N) calculation time (N is the number of the variables).
References cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_to_integers_.

|
inline |
Get the specific integer number corresponding to the input variable (index).
This function may need O(N) calculation time (N is the number of the variables).
| index |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_to_integers_.

|
inline |
Get the specific integer number corresponding to the input variable (index).
This function may need O(N) calculation time (N is the number of the variables).
| index |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_.

|
inline |
Return the vartype.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
|
inline |
Check if the specified index is in the BinaryPolynomialModel.
| index |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_.
|
inlineprotected |
Caluculate the base to the power of exponent (std::pow(base, exponent) is too slow).
| base | |
| exponent |
References declare_BQM().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo().


|
inline |
Normalizes the values of the interactions of the BinaryPolynomialModel such that they fall in the provided range(s).
| range | |
| ignored_interactions | |
| ignored_offset |
|
inline |
Remove the specified interaction from the BinaryPolynomialModel.
| key |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().

|
inline |
Remove the specified interaction from the BinaryPolynomialModel.
| key |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::each_variable_num_, cimod::FormatPolynomialKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_inv_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteractionsFrom(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteractionsFrom(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveOffset(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveVariable(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue().


|
inline |
Remove the specified interactions from the BinaryPolynomialModel.
| key_list |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().

|
inline |
Remove the specified interactions from the BinaryPolynomialModel.
| key_list |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().

|
inline |
Set the offset of the BinaryPolynomialModel to zero.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().

|
inline |
Remove a variable from the BinaryPolynomialModel.
| index |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveVariablesFrom().


|
inline |
Remove the specified variables from the BinaryPolynomialModel.
| key |
References declare_BQM(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveVariable().

|
inline |
Multiply by the specified scalar all the values of the interactions of the BinaryPolynomialModel.
| scalar | |
| ignored_interactions | |
| ignored_offset |
|
inlineprotected |
Set key and value.
Note that the key is assumed to be sorted.
| key | |
| value |
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::each_variable_num_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_inv_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction().


|
inlineprotected |
Generate BinaryPolynomialModel with the vartype being BINARY.
References cimod::BINARY, cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::ChangeVartype(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ChangeVartype().


|
inline |
Generate the polynomial interactions corresponding to the vartype being SPIN from the BinaryPolynomialModel.
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateChangedKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumInteractions(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::IntegerPower(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::SPIN, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin().


|
inline |
Generate the polynomial interactions corresponding to the vartype being BINARY from the BinaryPolynomialModel.
References cimod::BINARY, declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateChangedKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumInteractions(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::IntegerPower(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::ToBinary().


|
inline |
Convert the BinaryPolynomialModel to a serializable object.
References cimod::BINARY, declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumInteractions(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_key_list_, cimod::BinaryPolynomialModel< IndexType, FloatType >::poly_value_list_, cimod::SPIN, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.

|
inlineprotected |
Generate BinaryPolynomialModel with the vartype being SPIN.
References cimod::SPIN, cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::ChangeVartype(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ChangeVartype().


|
inlineprotected |
Update sorted_variables_ and variables_to_integers_.
References declare_BQM(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::relabel_flag_for_variables_to_integers_, cimod::BinaryPolynomialModel< IndexType, FloatType >::sorted_variables_, and cimod::BinaryPolynomialModel< IndexType, FloatType >::variables_to_integers_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers().


|
protected |
The list of the number of the variables appeared in the polynomial interactions as std::unordered_map.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue().
|
protected |
The inverse key list, which indicates the index of the poly_key_list_ and poly_value_list_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetKeysInv(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue().
|
protected |
The list of the indices of the polynomial interactions (namely, the list of keys of the polynomial interactions as std::unordered_map) as std::vector<std::vector>>.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetDegree(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetKeyList(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumInteractions(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveVariable(), cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSerializable().
|
protected |
The list of the values of the polynomial interactions (namely, the list of values of the polynomial interactions as std::unordered_map) as std::vector.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetValueList(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSerializable().
|
protected |
If true variable_to_index must be relabeled.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers().
|
protected |
Sorted variables is represents the correspondence from integer numbers.to the variables.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers().
|
protected |
Variable list as std::unordered_set.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateSortedVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetNumVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariables(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::HasVariable(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue().
|
protected |
The correspondence from variables to the integer numbers.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::Clear(), cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers().
|
protected |
The model's type. SPIN or BINARY.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVartype(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToBinary(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSerializable(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin().