22template<
typename FloatType>
24 static_assert(std::is_floating_point<FloatType>::value,
25 "Template parameter FloatType must be floating point type");
47 std::unordered_set<IndexType, IndexHash>
index_set;
49 for (std::size_t i = 0; i <
key_list.size(); ++i) {
50 if (std::abs(
value_list[i]) > std::numeric_limits<ValueType>::epsilon()) {
52 const std::int32_t
key_size =
static_cast<std::int32_t
>(
key_list[i].size()) - 1;
83 for (std::size_t i = 0; i <
key_list.size(); ++i) {
84 if (std::abs(
value_list[i]) > std::numeric_limits<ValueType>::epsilon()) {
86 for (std::size_t
j = 0;
j <
key_list[i].size(); ++
j) {
97 for (
const auto &
it:
poly) {
105 return a.first < b.first;
157 return static_cast<std::int32_t
>(
index_list_.size());
168 const std::unordered_map<IndexType, std::int32_t, IndexHash> &
GetIndexMap()
const {
202 throw std::runtime_error(
"The size of variables is not equal to the system size");
208 prod *= variables[index];
227 std::unordered_map<IndexType, std::int32_t, IndexHash>
index_map_;
Definition ising_polynomial_model.hpp:23
const ValueType min_max_energy_difference_ratio_
The ratio of minimum and maximum energy difference set by 1e-08.
Definition ising_polynomial_model.hpp:244
std::vector< std::pair< std::vector< std::int32_t >, ValueType > > key_value_list_
The integer key and value list as pair.
Definition ising_polynomial_model.hpp:230
std::int32_t GetSystemSize() const
Get the system size.
Definition ising_polynomial_model.hpp:156
ValueType estimated_max_energy_difference_
The estimated maximum energy difference.
Definition ising_polynomial_model.hpp:240
ValueType GetEstimatedMaxEnergyDifference() const
Get estimated maximum energy difference.
Definition ising_polynomial_model.hpp:193
const std::vector< IndexType > & GetIndexList() const
Get the index list of the polynomial interactions.
Definition ising_polynomial_model.hpp:162
const std::vector< std::vector< std::size_t > > & GetAdjacencyList() const
Get the adjacency list, which stored the integer index of the polynomial interaction specified by the...
Definition ising_polynomial_model.hpp:181
const std::unordered_map< IndexType, std::int32_t, IndexHash > & GetIndexMap() const
Get the mapping from the index to the integer.
Definition ising_polynomial_model.hpp:168
IsingPolynomialModel(std::vector< std::vector< IndexType > > &key_list, std::vector< ValueType > &value_list)
Definition ising_polynomial_model.hpp:41
std::int32_t GetDegree() const
Get the degree of the polynomial interactions.
Definition ising_polynomial_model.hpp:150
std::vector< IndexType > index_list_
The index list of the interactions.
Definition ising_polynomial_model.hpp:224
utility::IndexType IndexType
The index type.
Definition ising_polynomial_model.hpp:32
std::int8_t VariableType
The variable type, which here represents binary variables .
Definition ising_polynomial_model.hpp:38
ValueType estimated_min_energy_difference_
The estimated minimum energy difference.
Definition ising_polynomial_model.hpp:237
std::vector< std::vector< std::size_t > > adjacency_list_
The adjacency list, which stored the integer index of the polynomial interaction specified by the sit...
Definition ising_polynomial_model.hpp:234
const std::vector< std::pair< std::vector< std::int32_t >, ValueType > > & GetKeyValueList() const
Get the integer key and value list as pair.
Definition ising_polynomial_model.hpp:174
ValueType GetEstimatedMinEnergyDifference() const
Get estimated minimum energy difference.
Definition ising_polynomial_model.hpp:187
FloatType ValueType
The value type.
Definition ising_polynomial_model.hpp:29
std::int32_t system_size_
The system size.
Definition ising_polynomial_model.hpp:221
std::int32_t degree_
The degree of the interactions.
Definition ising_polynomial_model.hpp:218
ValueType CalculateEnergy(const std::vector< VariableType > &variables) const
Calculate energy corresponding to the variable configuration.
Definition ising_polynomial_model.hpp:200
std::unordered_map< IndexType, std::int32_t, IndexHash > index_map_
The mapping from the index to the integer.
Definition ising_polynomial_model.hpp:227
auto json_parse(const json &obj, bool relabel=true)
parse json object from bqm.to_serializable
Definition parse.hpp:50
std::variant< std::int32_t, std::string, AnyTupleType > IndexType
The index type of binary variables.
Definition index_type.hpp:28
Definition algorithm.hpp:24
double FloatType
Note:
Definition compile_config.hpp:37
Hash struct of IndexType.
Definition pairhash.hpp:49
Hash struct of std::vector<T>.
Definition pairhash.hpp:92