|
openjij
Framework for the Ising model and QUBO.
|
Polynomial graph class, which can treat many-body interactions. The Hamiltonian is like. More...
#include <polynomial.hpp>


Public Types | |
| using | value_type = FloatType |
| Floating-point type. | |
Public Member Functions | |
| Polynomial (const std::size_t num_variables) | |
| Constructor of Polynomial class to initialize variables and vartype. | |
| Polynomial (const nlohmann::json &j) | |
| Constructor of Polynomial class to initialize num_variables, and interactions from json. | |
| FloatType & | J (std::vector< Index > &key) |
| Access the interaction corresponding to the input argument to set an interaction. | |
| FloatType & | J (const std::vector< Index > &key) |
| Access the interaction corresponding to the input argument to set an interaction. | |
| FloatType | J (std::vector< Index > &key) const |
| Return the interaction corresponding to the input argument. | |
| FloatType | J (const std::vector< Index > &key) const |
| Return the interaction corresponding to the input argument. | |
| template<typename... Args> | |
| FloatType & | J (Args... args) |
| Access the interaction corresponding to the input argument to set an interaction. | |
| template<typename... Args> | |
| FloatType | J (Args... args) const |
| Access the interaction corresponding to the input argument to set an interaction. | |
| cimod::Polynomial< Index, FloatType > | get_polynomial () const |
| Generate and return all the polynomial interactions as std::unordered_map<std::vector<Index>, FloatType>. | |
| const cimod::PolynomialKeyList< Index > & | get_keys () const |
| Get the PolynomialKeyList object (all the keys of polynomial interactions). | |
| const cimod::PolynomialValueList< FloatType > & | get_values () const |
| Get the PolynomialValueList object (all the values of polynomial interactions). | |
| std::size_t | get_num_interactions () const |
| Return the number of all the interactions. | |
| FloatType | energy (const Spins &spins, const bool omp_flag=true) const |
| Return the total energy corresponding to the input variables, Spins or Binaries. | |
| FloatType | calc_energy (const Spins &spins, const bool omp_flag=true) const |
| Return the total energy corresponding to the input variables, Spins or Binaries. | |
| Public Member Functions inherited from openjij::graph::Graph | |
| Graph (std::size_t num_spins) | |
| Graph constructor. | |
| template<typename RandomNumberEngine> | |
| const Spins | gen_spin (RandomNumberEngine &random_numder_engine) const |
| generate spins randomly. | |
| template<typename RandomNumberEngine> | |
| const Binaries | gen_binary (RandomNumberEngine &random_numder_engine) const |
| generate spins randomly. | |
| std::size_t | get_num_spins () const noexcept |
| get number of spins | |
| std::size_t | size () const noexcept |
| get number of spins | |
Private Member Functions | |
| void | CheckKeyValid (const std::vector< Index > &key) const |
| Check if the input keys are valid. | |
Private Attributes | |
| cimod::PolynomialKeyList< Index > | poly_key_list_ |
| The list of the indices of the polynomial interactions (namely, the list of key of the polynomial interactions as std::unordered_map) as std::vector<std::vector<Index>>. | |
| cimod::PolynomialValueList< FloatType > | poly_value_list_ |
| The list of the values of the polynomial interactions (namely, the list of value of the polynomial interactions as std::unordered_map) as std::vecto<FloatType>. | |
| std::unordered_map< std::vector< Index >, std::size_t, cimod::vector_hash > | poly_key_inv_ |
| The inverse key list, which indicates the index of the poly_key_list_ and poly_value_list_. | |
Polynomial graph class, which can treat many-body interactions. The Hamiltonian is like.
\[H=\sum_{i \neq j} Q_{ij} x_i x_j + \sum_{i \neq j \neq k} Q_{ijk} x_i x_j x_k + \ldots \]
Note here that \( x_i \in \{0, 1\} \) or \( x_i \in \{-1, +1\} \).
| FloatType | floating-point type |
| using openjij::graph::Polynomial< FloatType >::value_type = FloatType |
Floating-point type.
|
inlineexplicit |
Constructor of Polynomial class to initialize variables and vartype.
| num_variables | std::size_t |
References openjij::graph::Graph::Graph().

|
inlineexplicit |
Constructor of Polynomial class to initialize num_variables, and interactions from json.
| j | JSON object |
References openjij::graph::Graph::Graph(), openjij::graph::json_parse_polynomial(), poly_key_inv_, poly_key_list_, poly_value_list_, and openjij::graph::Graph::size().

|
inline |
|
inlineprivate |
Check if the input keys are valid.
References openjij::graph::Graph::size().


|
inline |
Return the total energy corresponding to the input variables, Spins or Binaries.
| spins | const Spins& or const Binaries& (both are the same type) |
| omp_flag | if true OpenMP is enabled. |
References energy(), poly_key_list_, poly_value_list_, and openjij::graph::Graph::size().
Referenced by calc_energy(), and energy().


|
inline |
Get the PolynomialKeyList object (all the keys of polynomial interactions).
References poly_key_list_.
Referenced by openjij::system::KLocalPolynomial< graph::Polynomial< FloatType > >::KLocalPolynomial(), and openjij::system::ClassicalIsingPolynomial< graph::Polynomial< FloatType > >::SetInteractions().

|
inline |
Return the number of all the interactions.
References poly_key_list_.
|
inline |
Generate and return all the polynomial interactions as std::unordered_map<std::vector<Index>, FloatType>.
References poly_key_list_, and poly_value_list_.
|
inline |
Get the PolynomialValueList object (all the values of polynomial interactions).
References poly_value_list_.
Referenced by openjij::system::KLocalPolynomial< graph::Polynomial< FloatType > >::KLocalPolynomial(), and openjij::system::ClassicalIsingPolynomial< graph::Polynomial< FloatType > >::SetInteractions().

|
inline |
Access the interaction corresponding to the input argument to set an interaction.
If the interaction specified by "args" is empty, the zero will be added to the polynomial graph.
| args | parameter pack |
References J().

|
inline |
Access the interaction corresponding to the input argument to set an interaction.
If the interaction specified by "args" is empty, this function returns the zero.
| args | parameter pack |
References J().

|
inline |
Access the interaction corresponding to the input argument to set an interaction.
If the interaction specified by "key" is empty, the zero will be added to the polynomial graph.
| key | const std::vector<Index>& |
References J().

|
inline |
Return the interaction corresponding to the input argument.
If the interaction specified by "key" is empty, this function returns the zero.
| key | const std::vector<Index>& |
References J().

|
inline |
Access the interaction corresponding to the input argument to set an interaction.
Note that the input argument "key" will be sorted. If the interaction specified by "key" is empty, the zero will be added to the polynomial graph.
| key | std::vector<Index>& |
References CheckKeyValid(), poly_key_inv_, poly_key_list_, and poly_value_list_.
Referenced by J(), J(), J(), and J().


|
inline |
Return the interaction corresponding to the input argument.
Note that the input argument "key" will be sorted. If the interaction specified by "key" is empty, this function returns the zero.
| key | std::vector<Index>& |
References CheckKeyValid(), poly_key_inv_, and poly_value_list_.

|
private |
The inverse key list, which indicates the index of the poly_key_list_ and poly_value_list_.
Referenced by J(), J(), and Polynomial().
|
private |
The list of the indices of the polynomial interactions (namely, the list of key of the polynomial interactions as std::unordered_map) as std::vector<std::vector<Index>>.
Referenced by energy(), get_keys(), get_num_interactions(), get_polynomial(), J(), and Polynomial().
|
private |
The list of the values of the polynomial interactions (namely, the list of value of the polynomial interactions as std::unordered_map) as std::vecto<FloatType>.
Referenced by energy(), get_polynomial(), get_values(), J(), J(), and Polynomial().