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. More... | |
BinaryPolynomialModel (PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype) | |
BinaryPolynomialModel constructor. More... | |
BinaryPolynomialModel (const PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype) | |
BinaryPolynomialModel constructor. More... | |
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. More... | |
Polynomial< IndexType, FloatType > | GetPolynomial () const |
Get the Polynomial object. More... | |
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. More... | |
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. More... | |
const std::unordered_map< IndexType, int64_t > & | GetVariablesToIntegers () |
Get variables_to_integers object. More... | |
std::unordered_map< IndexType, int64_t > | GetVariablesToIntegers () const |
Get variables_to_integers object. More... | |
int64_t | GetVariablesToIntegers (const IndexType &index) |
Get the specific integer number corresponding to the input variable (index). More... | |
int64_t | GetVariablesToIntegers (const IndexType &index) const |
Get the specific integer number corresponding to the input variable (index). More... | |
const PolynomialKeyList< IndexType > & | GetKeyList () const |
Get the PolynomialKeyList object. More... | |
const PolynomialValueList< FloatType > & | GetValueList () const |
Get the PolynomialValueList object. More... | |
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_. More... | |
const std::unordered_set< IndexType > & | GetVariables () const |
Return the variables as std::unordered_set. More... | |
const std::vector< IndexType > & | GetSortedVariables () |
Return the sorted variables as std::vector. More... | |
std::vector< IndexType > | GetSortedVariables () const |
Return the sorted variables as std::vector. More... | |
std::size_t | GetDegree () const |
Return the maximum degree of interaction. More... | |
FloatType | GetOffset () const |
Return the offset. More... | |
Vartype | GetVartype () const |
Return the vartype. More... | |
std::size_t | GetNumInteractions () const |
Return the number of the interactions. More... | |
std::size_t | GetNumVariables () const |
Return the number of variables. More... | |
BinaryPolynomialModel | Empty (const Vartype vartype) const |
Create an empty BinaryPolynomialModel. More... | |
void | Clear () |
Clear the BinaryPolynomialModel. More... | |
void | RemoveInteraction (std::vector< IndexType > &key) |
Remove the specified interaction from the BinaryPolynomialModel. More... | |
void | RemoveInteraction (const std::vector< IndexType > &key) |
Remove the specified interaction from the BinaryPolynomialModel. More... | |
void | RemoveInteractionsFrom (PolynomialKeyList< IndexType > &key_list) |
Remove the specified interactions from the BinaryPolynomialModel. More... | |
void | RemoveInteractionsFrom (const PolynomialKeyList< IndexType > &key_list) |
Remove the specified interactions from the BinaryPolynomialModel. More... | |
void | RemoveOffset () |
Set the offset of the BinaryPolynomialModel to zero. More... | |
void | RemoveVariable (const IndexType &index) |
Remove a variable from the BinaryPolynomialModel. More... | |
void | RemoveVariablesFrom (const std::vector< IndexType > &key) |
Remove the specified variables from the BinaryPolynomialModel. More... | |
void | AddInteraction (std::vector< IndexType > &key, const FloatType &value, const Vartype vartype=Vartype::NONE) |
Add an interaction to the BinaryPolynomialModel. More... | |
void | AddInteraction (const std::vector< IndexType > &key, const FloatType &value, const Vartype vartype=Vartype::NONE) |
Add an interaction to the BinaryPolynomialModel. More... | |
void | AddInteractionsFrom (const Polynomial< IndexType, FloatType > &poly_map, const Vartype vartype=Vartype::NONE) |
Add interactions to the BinaryPolynomialModel. More... | |
void | AddInteractionsFrom (PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype=Vartype::NONE) |
Add interactions to the BinaryPolynomialModel. More... | |
void | AddInteractionsFrom (const PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list, const Vartype vartype=Vartype::NONE) |
Add interactions to the BinaryPolynomialModel. More... | |
void | AddOffset (FloatType offset) |
Add specified value to the offset of the BinaryPolynomialModel. More... | |
FloatType | Energy (const Sample< IndexType > &sample, bool omp_flag=true) const |
Determine the energy of the specified sample of the BinaryPolynomialModel. More... | |
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. More... | |
PolynomialValueList< FloatType > | Energies (const std::vector< Sample< IndexType >> &samples) const |
Determine the energies of the given samples. More... | |
PolynomialValueList< FloatType > | Energies (const std::vector< std::vector< int32_t >> &samples_vec) |
Determine the energies of the given samples_vec. More... | |
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. More... | |
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). More... | |
BinaryPolynomialModel | ChangeVartype (const Vartype vartype, const bool inplace) |
Create a BinaryPolynomialModel with the specified vartype. More... | |
void | ChangeVartype (const Vartype vartype) |
Change the vartype of the BinaryPolynomialModel. More... | |
bool | HasVariable (const IndexType &index) |
Check if the specified index is in the BinaryPolynomialModel. More... | |
Polynomial< IndexType, FloatType > | ToHubo () const |
Generate the polynomial interactions corresponding to the vartype being BINARY from the BinaryPolynomialModel. More... | |
Polynomial< IndexType, FloatType > | ToHising () const |
Generate the polynomial interactions corresponding to the vartype being SPIN from the BinaryPolynomialModel. More... | |
nlohmann::json | ToSerializable () const |
Convert the BinaryPolynomialModel to a serializable object. More... | |
Static Public Member Functions | |
template<typename IndexType_serial = IndexType, typename FloatType_serial = FloatType> | |
static BinaryPolynomialModel< IndexType_serial, FloatType_serial > | FromSerializable (const nlohmann::json &input) |
Create a BinaryPolynomialModel instance from a serializable object. More... | |
static BinaryPolynomialModel | FromHubo (const Polynomial< IndexType, FloatType > &poly_map) |
Create a BinaryPolynomialModel from a Hubo model. More... | |
static BinaryPolynomialModel | FromHubo (const PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list) |
Create a BinaryPolynomialModel from a Hubo model. More... | |
static BinaryPolynomialModel | FromHubo (PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list) |
Create a BinaryPolynomialModel from a Hubo model. More... | |
static BinaryPolynomialModel | FromHising (const Polynomial< IndexType, FloatType > &poly_map) |
Create a BinaryPolynomialModel from a higher ordere Ising model. More... | |
static BinaryPolynomialModel | FromHising (const PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list) |
Create a BinaryPolynomialModel from a higher ordere Ising model. More... | |
static BinaryPolynomialModel | FromHising (PolynomialKeyList< IndexType > &key_list, const PolynomialValueList< FloatType > &value_list) |
Create a BinaryPolynomialModel from a higher ordere Ising model. More... | |
Protected Member Functions | |
void | SetKeyAndValue (const std::vector< IndexType > &key, const FloatType &value) |
Set key and value. More... | |
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). More... | |
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. More... | |
BinaryPolynomialModel | ToSpin () const |
Generate BinaryPolynomialModel with the vartype being SPIN. More... | |
BinaryPolynomialModel | ToBinary () const |
Generate BinaryPolynomialModel with the vartype being BINARY. More... | |
void | UpdateVariablesToIntegers () |
Update sorted_variables_ and variables_to_integers_. More... | |
std::unordered_map< IndexType, int64_t > | GenerateVariablesToIntegers () const |
Generate variables_to_integers. More... | |
std::vector< IndexType > | GenerateSortedVariables () const |
Generate sorted variables. More... | |
Protected Attributes | |
std::unordered_set< IndexType > | variables_ |
Variable list as std::unordered_set. More... | |
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. More... | |
std::unordered_map< IndexType, int64_t > | variables_to_integers_ |
The correspondence from variables to the integer numbers. More... | |
std::vector< IndexType > | sorted_variables_ |
Sorted variables is represents the correspondence from integer numbers.to the variables. More... | |
bool | relabel_flag_for_variables_to_integers_ = true |
If true variable_to_index must be relabeled. More... | |
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>>. More... | |
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. More... | |
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_. More... | |
Vartype | vartype_ = Vartype::NONE |
The model's type. SPIN or BINARY. More... | |
Class for BinaryPolynomialModel.
IndexType | |
FloatType |
|
inline |
BinaryPolynomialModel constructor.
poly_map | |
vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::UpdateVariablesToIntegers(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::Empty(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToBinary(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin().
|
inline |
BinaryPolynomialModel constructor.
key_list | |
value_list | |
vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteractionsFrom(), 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(), 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 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 cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Add an interaction to the BinaryPolynomialModel.
key | |
value | |
vartype |
References cimod::BINARY, cimod::FormatPolynomialKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateChangedKey(), cimod::BinaryPolynomialModel< IndexType, FloatType >::IntegerPower(), cimod::NONE, cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue(), cimod::SPIN, cimod.model.legacy.binary_quadratic_model::vartype, and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), 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 cimod.model.legacy.binary_quadratic_model::vartype.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel().
|
inline |
Add interactions to the BinaryPolynomialModel.
key_list | |
value_list | |
vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), and cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Add interactions to the BinaryPolynomialModel.
key_list | |
value_list | |
vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), and cimod.model.legacy.binary_quadratic_model::vartype.
|
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(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin(), and cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Create a BinaryPolynomialModel with the specified vartype.
vartype | |
inplace |
References cimod::BINARY, cimod::SPIN, cimod::BinaryPolynomialModel< IndexType, FloatType >::ToBinary(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToSpin(), and cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Clear the BinaryPolynomialModel.
References 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 |
Create an empty BinaryPolynomialModel.
vartype |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), and cimod.model.legacy.binary_quadratic_model::vartype.
|
inline |
Determine the energies of the given samples.
samples |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::Energy().
|
inline |
Determine the energies of the given samples_vec.
samples_vec |
References 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 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().
|
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 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 cimod::SPIN.
|
inlinestatic |
Create a BinaryPolynomialModel from a higher ordere Ising model.
key_list | |
value_list |
References cimod::SPIN.
|
inlinestatic |
Create a BinaryPolynomialModel from a higher ordere Ising model.
key_list | |
value_list |
References cimod::SPIN.
|
inlinestatic |
Create a BinaryPolynomialModel from a Hubo model.
poly_map |
References cimod::BINARY.
|
inlinestatic |
Create a BinaryPolynomialModel from a Hubo model.
key_list | |
value_list |
References cimod::BINARY.
|
inlinestatic |
Create a BinaryPolynomialModel from a Hubo model.
key_list | |
value_list |
References cimod::BINARY.
|
inlinestatic |
Create a BinaryPolynomialModel instance from a serializable object.
IndexType_serial | |
FloatType_serial |
input |
References cimod::BINARY, cimod::SPIN, and cimod.model.legacy.binary_quadratic_model::vartype.
|
inlineprotected |
Generate the num_of_key-th the key when the vartype is changed.
original_key | |
num_of_key |
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::AddInteraction(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo().
|
inlineprotected |
Generate sorted variables.
References 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 cimod::BinaryPolynomialModel< IndexType, FloatType >::GenerateSortedVariables().
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::GetVariablesToIntegers().
|
inline |
Return the maximum degree of interaction.
References 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 >::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().
|
inline |
Return the offset.
References cimod::BinaryPolynomialModel< IndexType, FloatType >::GetPolynomial().
|
inline |
Get the Polynomial object.
References 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 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 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 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 |
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 cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().
|
inline |
Remove the specified interaction from the BinaryPolynomialModel.
key |
References 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 >::RemoveOffset(), cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveVariable(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::SetKeyAndValue().
|
inline |
Remove the specified interactions from the BinaryPolynomialModel.
key_list |
References cimod::BinaryPolynomialModel< IndexType, FloatType >::RemoveInteraction().
|
inline |
Remove the specified interactions from the BinaryPolynomialModel.
key_list |
References 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 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 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 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 >::BinaryPolynomialModel(), cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHubo(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::ChangeVartype().
|
inline |
Generate the polynomial interactions corresponding to the vartype being SPIN from the BinaryPolynomialModel.
References 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, 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, 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::BinaryPolynomialModel< IndexType, FloatType >::BinaryPolynomialModel(), cimod::SPIN, cimod::BinaryPolynomialModel< IndexType, FloatType >::ToHising(), and cimod::BinaryPolynomialModel< IndexType, FloatType >::vartype_.
Referenced by cimod::BinaryPolynomialModel< IndexType, FloatType >::ChangeVartype().
|
inlineprotected |
Update sorted_variables_ and variables_to_integers_.
References 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 >::Energy(), cimod::BinaryPolynomialModel< IndexType, FloatType >::GetSortedVariables(), 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 >::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 >::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 >::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(), 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(), 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 >::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().