openjij
Framework for the Ising model and QUBO.
Loading...
Searching...
No Matches
k_local_polynomial.hpp
Go to the documentation of this file.
1// Copyright 2023 Jij Inc.
2
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6
7// http://www.apache.org/licenses/LICENSE-2.0
8
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <sstream>
18
19#include <nlohmann/json.hpp>
20
21#include "openjij/graph/all.hpp"
24
25namespace openjij {
26namespace system {
27
32template <class GraphType> class KLocalPolynomial;
33
35template <typename FloatType>
36class KLocalPolynomial<graph::Polynomial<FloatType>> {
37
38public:
41
43 const int64_t num_binaries;
44
46 int rate_call_k_local = 10;
47
49 int64_t count_call_updater = 0;
50
53
55 const cimod::Vartype vartype = cimod::Vartype::BINARY;
56
62 KLocalPolynomial(const graph::Binaries &init_binaries,
63 const graph::Polynomial<FloatType> &poly_graph)
64 : num_binaries(init_binaries.size()), binaries(init_binaries),
65 binaries_v_(init_binaries) {
66
67 cimod::CheckVariables(binaries, vartype);
68
69 const auto &poly_key_list = poly_graph.get_keys();
70 const auto &poly_value_list = poly_graph.get_values();
71
72 if (poly_key_list.size() != poly_value_list.size()) {
73 throw std::runtime_error(
74 "The sizes of key_list and value_list must match each other");
75 }
76 if (poly_key_list.size() == 0) {
77 throw std::runtime_error("The interaction is empty.");
78 }
79
80 std::unordered_set<graph::Index> active_binary_set;
81
82 poly_key_list_.clear();
83 poly_value_list_.clear();
84
85 for (std::size_t i = 0; i < poly_key_list.size(); ++i) {
86 if (poly_value_list[i] != 0.0) {
87 poly_key_list_.push_back(poly_key_list[i]);
88 poly_value_list_.push_back(poly_value_list[i]);
89 for (const auto &it : poly_key_list[i]) {
90 active_binary_set.emplace(it);
91 }
92 }
93 }
94 num_interactions_ = static_cast<int64_t>(poly_key_list_.size());
95 SortInteractions();
96 active_binaries_ = std::vector<graph::Index>(active_binary_set.begin(),
97 active_binary_set.end());
98 std::sort(active_binaries_.begin(), active_binaries_.end());
99 SetAdj();
100 ResetZeroCount();
101 reset_dE();
102 const FloatType thres_hold =
103 std::abs(FindMaxInteraction().second * utility::THRESHOLD<FloatType>);
104 min_effective_dE_ = std::abs(FindMinInteraction(thres_hold).second);
105 }
106
111 KLocalPolynomial(const graph::Binaries &init_binaries,
112 const nlohmann::json &j)
113 : num_binaries(init_binaries.size()), binaries(init_binaries),
114 binaries_v_(init_binaries) {
115
116 cimod::CheckVariables(binaries, vartype);
117
118 if (j.at("vartype") != "BINARY") {
119 throw std::runtime_error("Only binary variables are supported");
120 }
121
122 const auto &v_k_v = graph::json_parse_polynomial<FloatType>(j);
123 const auto &poly_key_list = std::get<0>(v_k_v);
124 const auto &poly_value_list = std::get<1>(v_k_v);
125
126 if (poly_key_list.size() != poly_value_list.size()) {
127 throw std::runtime_error(
128 "The sizes of key_list and value_list must match each other");
129 }
130 if (poly_key_list.size() == 0) {
131 throw std::runtime_error("The interaction is empty.");
132 }
133
134 num_interactions_ = static_cast<int64_t>(poly_key_list.size());
135
136 poly_key_list_.resize(num_interactions_);
137 poly_value_list_.resize(num_interactions_);
138
139#pragma omp parallel for
140 for (int64_t i = 0; i < num_interactions_; ++i) {
141 poly_key_list_[i] = poly_key_list[i];
142 poly_value_list_[i] = poly_value_list[i];
143 }
144 SortInteractions();
145
146 active_binaries_.resize(num_binaries);
147 std::iota(active_binaries_.begin(), active_binaries_.end(), 0);
148
149 SetAdj();
150 ResetZeroCount();
151 reset_dE();
152 const FloatType thres_hold =
153 std::abs(FindMaxInteraction().second * utility::THRESHOLD<FloatType>);
154 min_effective_dE_ = std::abs(FindMinInteraction(thres_hold).second);
155 }
156
159 void reset_binaries(const graph::Binaries &init_binaries) {
160
161 cimod::CheckVariables(init_binaries, vartype);
162
163 if (init_binaries.size() != binaries.size()) {
164 throw std::runtime_error(
165 "The size of initial binaries does not equal to system size");
166 }
167 for (const auto &index_binary : active_binaries_) {
168 if (binaries[index_binary] != init_binaries[index_binary]) {
169 update_system_single(index_binary);
170 }
171 if (binaries[index_binary] != init_binaries[index_binary]) {
172 std::stringstream ss;
173 ss << "Unknown error detected in " << __func__;
174 throw std::runtime_error(ss.str());
175 }
176 }
177 }
178
181 void reset_dE() {
182 dE_.clear();
183 dE_v_.clear();
184 dE_.resize(num_binaries);
185 dE_v_.resize(num_binaries);
186
187 // Initialize
188 max_effective_dE_ = std::abs(poly_value_list_.front());
189
190 for (const auto &index_binary : active_binaries_) {
191 FloatType val = 0.0;
192 FloatType abs_val = 0.0;
193 bool flag = false;
194 const graph::Binary binary = binaries[index_binary];
195 for (const auto &index_key : adj_[index_binary]) {
196 if (zero_count_[index_key] + binary == 1) {
197 val += poly_value_list_[index_key];
198 }
199 flag = true;
200 abs_val += std::abs(poly_value_list_[index_key]);
201 }
202 dE_[index_binary] = (-2 * binary + 1) * val;
203 dE_v_[index_binary] = dE_[index_binary];
204
205 if (flag && max_effective_dE_ < abs_val) {
206 max_effective_dE_ = abs_val;
207 }
208 }
209 }
210
214 inline FloatType dE_single(const graph::Index index_binary) const {
215 return dE_[index_binary];
216 }
217
224 FloatType dE_k_local(const std::size_t index_key) {
225 FloatType dE = 0.0;
226 for (const auto &index_binary : poly_key_list_[index_key]) {
227 if (binaries_v_[index_binary] == 0) {
228 dE += dE_v_[index_binary];
229 virtual_update_system_single(index_binary);
230 }
231 if (dE < 0.0) {
232 break;
233 }
234 }
235 return dE;
236 }
237
240 for (const auto &index_binary : update_index_binaries_v_) {
241 binaries[index_binary] = binaries_v_[index_binary];
242 }
243 for (const auto &index_zero_count : update_index_zero_count_v_) {
244 zero_count_[index_zero_count] = zero_count_v_[index_zero_count];
245 }
246 for (const auto &index_dE : update_index_dE_v_) {
247 dE_[index_dE] = dE_v_[index_dE];
248 }
249 update_index_binaries_v_.clear();
250 update_index_zero_count_v_.clear();
251 update_index_dE_v_.clear();
252 }
253
256 void update_system_single(const graph::Index index_update_binary) {
257 const graph::Binary update_binary = binaries[index_update_binary];
258 const int coeef = -2 * update_binary + 1;
259 const int count = +2 * update_binary - 1;
260 for (const auto &index_key : adj_[index_update_binary]) {
261 const FloatType val = poly_value_list_[index_key];
262 for (const auto &index_binary : poly_key_list_[index_key]) {
263 const graph::Binary binary = binaries[index_binary];
264 if (zero_count_[index_key] + update_binary + binary == 2 &&
265 index_binary != index_update_binary) {
266 dE_[index_binary] += coeef * (-2 * binary + 1) * val;
267 dE_v_[index_binary] = dE_[index_binary];
268 }
269 }
270 zero_count_[index_key] += count;
271 zero_count_v_[index_key] = zero_count_[index_key];
272 }
273 dE_[index_update_binary] *= -1;
274 dE_v_[index_update_binary] = dE_[index_update_binary];
275 binaries[index_update_binary] = 1 - binaries[index_update_binary];
276 binaries_v_[index_update_binary] = binaries[index_update_binary];
277 }
278
281 void virtual_update_system_single(const graph::Index index_update_binary) {
282 const graph::Binary update_binary = binaries_v_[index_update_binary];
283 const int coeef = -2 * update_binary + 1;
284 const int count = +2 * update_binary - 1;
285 for (const auto &index_key : adj_[index_update_binary]) {
286 const FloatType val = poly_value_list_[index_key];
287 for (const auto &index_binary : poly_key_list_[index_key]) {
288 const graph::Binary binary = binaries_v_[index_binary];
289 if (zero_count_v_[index_key] + update_binary + binary == 2 &&
290 index_binary != index_update_binary) {
291 dE_v_[index_binary] += coeef * (-2 * binary + 1) * val;
292 update_index_dE_v_.emplace(index_binary);
293 }
294 }
295 zero_count_v_[index_key] += count;
296 update_index_zero_count_v_.push_back(index_key);
297 }
298 dE_v_[index_update_binary] *= -1;
299 update_index_dE_v_.emplace(index_update_binary);
300 binaries_v_[index_update_binary] = 1 - binaries_v_[index_update_binary];
301 update_index_binaries_v_.push_back(index_update_binary);
302 }
303
306 for (const auto &index_binary : update_index_binaries_v_) {
307 binaries_v_[index_binary] = binaries[index_binary];
308 }
309 for (const auto &index_zero_count : update_index_zero_count_v_) {
310 zero_count_v_[index_zero_count] = zero_count_[index_zero_count];
311 }
312 for (const auto &index_dE : update_index_dE_v_) {
313 dE_v_[index_dE] = dE_[index_dE];
314 }
315 update_index_binaries_v_.clear();
316 update_index_zero_count_v_.clear();
317 update_index_dE_v_.clear();
318 }
319
323 void set_rate_call_k_local(int rate_k_local) {
324 if (rate_k_local <= 0) {
325 throw std::runtime_error("rate_k_local must be larger than zero");
326 }
327 rate_call_k_local = rate_k_local;
328 }
329
331 inline int64_t GetNumInteractions() const { return num_interactions_; }
332
337 inline int64_t GetZeroCount(const std::size_t index_key) const {
338 return zero_count_[index_key];
339 }
340
344 inline FloatType GetPolyValue(const std::size_t index_key) const {
345 return poly_value_list_[index_key];
346 }
347
352 inline const std::vector<graph::Index> &
353 get_adj(const std::size_t index_binary) const {
354 return adj_[index_binary];
355 }
356
360 inline const std::vector<graph::Index> &get_active_binaries() const {
361 return active_binaries_;
362 }
363
366 FloatType get_max_effective_dE() const { return max_effective_dE_; }
367
371 FloatType get_min_effective_dE() const { return min_effective_dE_; }
372
376 const cimod::PolynomialValueList<FloatType> &get_values() const {
377 return poly_value_list_;
378 }
379
383 const cimod::PolynomialKeyList<graph::Index> &get_keys() const {
384 return poly_key_list_;
385 }
386
390 const std::vector<std::vector<graph::Index>> &get_adj() const { return adj_; }
391
394 std::string get_vartype_string() const { return "BINARY"; }
395
400 /*
401 void print_dE() const {
402 for (std::size_t i = 0; i < dE_.size(); ++i) {
403 printf("dE[%2ld]=%+.15lf\n", i, dE_[i]);
404 }
405 }
406
407 void print_zero_count() const {
408 for (int64_t i = 0; i < num_interactions_; ++i) {
409 printf("zero_count[");
410 for (const auto &index_binary: poly_key_list_[i]) {
411 printf("%ld, ", index_binary);
412 }
413 printf("]=%lld\n", zero_count_[i]);
414 }
415 }
416
417 void print_adj() const {
418 for (int64_t i = 0; i < num_binaries; ++i) {
419 printf("adj[%lld]=", i);
420 for (const auto &index_key: adj_[i]) {
421 printf("%ld(%+lf), ", index_key, poly_value_list_[index_key]);
422 }
423 printf("\n");
424 }
425 }
426
427 void print_active_binaries() const {
428 for (std::size_t i = 0; i < active_binaries_.size(); ++i) {
429 printf("%d, ", binaries[active_binaries_[i]]);
430 }
431 printf("\n");
432 }
433
434 void print_interactions() const {
435 for (int64_t i = 0; i < num_interactions_; ++i) {
436 printf("%lld: size:%ld val: %lf\n", i, poly_key_list_[i].size(),
437 poly_value_list_[i]);
438 }
439 }
440 */
442
443private:
446
448 std::vector<FloatType> dE_;
449
451 std::vector<int64_t> zero_count_;
452
455 std::vector<std::vector<graph::Index>> adj_;
456
459 cimod::PolynomialKeyList<graph::Index> poly_key_list_;
460
463 cimod::PolynomialValueList<FloatType> poly_value_list_;
464
466 std::vector<graph::Index> active_binaries_;
467
470
473
480 std::vector<FloatType> dE_v_;
481
485
488 std::unordered_set<std::size_t> update_index_dE_v_;
489
492 std::vector<std::size_t> update_index_zero_count_v_;
493
496 std::vector<std::size_t> update_index_binaries_v_;
497
500 std::vector<int64_t> zero_count_v_;
502
506
507 std::vector<graph::Index> index(num_interactions_);
508#pragma omp parallel for
509 for (int64_t i = 0; i < num_interactions_; ++i) {
510 index[i] = i;
511 }
512
513 auto compare_value = [this](const std::size_t i1, const std::size_t i2) {
514 return poly_value_list_[i1] < poly_value_list_[i2];
515 };
516 auto compare_size = [this](const std::size_t i1, const std::size_t i2) {
517 return poly_key_list_[i1].size() < poly_key_list_[i2].size();
518 };
519
520 std::stable_sort(index.begin(), index.end(), compare_size);
521 std::stable_sort(index.begin(), index.end(), compare_value);
522
523 cimod::PolynomialValueList<FloatType> vv = poly_value_list_;
524
525#pragma omp parallel for
526 for (int64_t i = 0; i < num_interactions_; ++i) {
527 poly_value_list_[i] = vv[index[i]];
528 }
529
530 cimod::PolynomialValueList<FloatType>().swap(vv);
531
532 cimod::PolynomialKeyList<graph::Index> ii = poly_key_list_;
533
534#pragma omp parallel for
535 for (int64_t i = 0; i < num_interactions_; ++i) {
536 poly_key_list_[i] = ii[index[i]];
537 }
538 }
539
542 void SetAdj() {
543 adj_.clear();
544 adj_.resize(num_binaries);
545 for (int64_t i = 0; i < num_interactions_; ++i) {
546 for (const auto &index : poly_key_list_[i]) {
547 adj_[index].push_back(i);
548 }
549 }
550
551 // sort by value and key size
552 auto compare_size = [this](const int64_t i1, const int64_t i2) {
553 return poly_key_list_[i1].size() < poly_key_list_[i2].size();
554 };
555 auto compare_value = [this](const int64_t i1, const int64_t i2) {
556 return poly_value_list_[i1] < poly_value_list_[i2];
557 };
558
559 int64_t adj_size = static_cast<int64_t>(adj_.size());
560#pragma omp parallel for
561 for (int64_t i = 0; i < adj_size; ++i) {
562 std::stable_sort(adj_[i].begin(), adj_[i].end(), compare_size);
563 std::stable_sort(adj_[i].begin(), adj_[i].end(), compare_value);
564 }
565 }
566
569 zero_count_.resize(num_interactions_);
570 zero_count_v_.resize(num_interactions_);
571#pragma omp parallel for
572 for (int64_t i = 0; i < num_interactions_; ++i) {
573 int64_t zero_count = 0;
574 for (const auto &index : poly_key_list_[i]) {
575 if (binaries[index] == 0) {
576 zero_count++;
577 }
578 }
579 zero_count_[i] = zero_count;
580 zero_count_v_[i] = zero_count;
581 }
582 }
583
587 std::pair<std::vector<graph::Index>, FloatType> FindMaxInteraction() const {
588 if (poly_key_list_.size() == 0) {
589 throw std::runtime_error("Interactions are empty.");
590 }
591 FloatType max_val = 0.0;
592 std::vector<graph::Index> max_key = {};
593 for (std::size_t i = 0; i < poly_key_list_.size(); ++i) {
594 if (std::abs(max_val) < std::abs(poly_value_list_[i])) {
595 max_val = poly_value_list_[i];
596 max_key = poly_key_list_[i];
597 }
598 }
599 return std::pair<std::vector<graph::Index>, FloatType>(max_key, max_val);
600 }
601
605 std::pair<std::vector<graph::Index>, FloatType>
606 FindMinInteraction(const FloatType threshold = 0.0) const {
607 if (poly_key_list_.size() == 0) {
608 throw std::runtime_error("Interactions are empty.");
609 }
610 FloatType min_val = poly_value_list_[0];
611 std::vector<graph::Index> min_key = poly_key_list_[0];
612 for (std::size_t i = 0; i < poly_key_list_.size(); ++i) {
613 if (poly_value_list_[i] != 0.0 &&
614 std::abs(poly_value_list_[i]) < std::abs(min_val) &&
615 threshold < std::abs(poly_value_list_[i])) {
616 min_val = poly_value_list_[i];
617 min_key = poly_key_list_[i];
618 }
619 }
620
621 if (std::abs(min_val) <= threshold) {
622 throw std::runtime_error("No minimum value in interactions");
623 }
624 return std::pair<std::vector<graph::Index>, FloatType>(min_key, min_val);
625 }
626};
627
632template <typename GraphType>
633auto make_k_local_polynomial(const graph::Binaries &init_binaries,
634 const GraphType &init_interaction) {
635 return KLocalPolynomial<GraphType>(init_binaries, init_interaction);
636}
637
643auto make_k_local_polynomial(const graph::Binaries &init_binaries,
644 const nlohmann::json &init_obj) {
645 return KLocalPolynomial<graph::Polynomial<double>>(init_binaries, init_obj);
646}
647
648} // namespace system
649} // namespace openjij
Polynomial graph class, which can treat many-body interactions.
Definition polynomial.hpp:47
const cimod::PolynomialKeyList< Index > & get_keys() const
Get the PolynomialKeyList object (all the keys of polynomial interactions).
Definition polynomial.hpp:180
const cimod::PolynomialValueList< FloatType > & get_values() const
Get the PolynomialValueList object (all the values of polynomial interactions).
Definition polynomial.hpp:187
const std::vector< graph::Index > & get_adj(const std::size_t index_binary) const
Get the adjacency list (the index of interactions) of the binary specified by "index_binary".
Definition k_local_polynomial.hpp:353
int64_t GetNumInteractions() const
Get the number of interactions.
Definition k_local_polynomial.hpp:331
FloatType dE_single(const graph::Index index_binary) const
Return the energy difference of single spin flip update.
Definition k_local_polynomial.hpp:214
graph::Binaries binaries_v_
Virtually updated binary configulations, which is used to implement k-local update.
Definition k_local_polynomial.hpp:484
void virtual_update_system_single(const graph::Index index_update_binary)
Virtually flip specified binary by single spin flip.
Definition k_local_polynomial.hpp:281
cimod::PolynomialValueList< FloatType > poly_value_list_
The list of the values of the polynomial interactions as std::vector<FloatType>.
Definition k_local_polynomial.hpp:463
void ResetZeroCount()
Set zero_count_ and zero_count_v_.
Definition k_local_polynomial.hpp:568
std::vector< graph::Index > active_binaries_
The list of the binaries connected by at least one interaction.
Definition k_local_polynomial.hpp:466
const cimod::PolynomialKeyList< graph::Index > & get_keys() const
Get the PolynomialKeyList object, which is the list of the indices of the polynomial interactions as ...
Definition k_local_polynomial.hpp:383
KLocalPolynomial(const graph::Binaries &init_binaries, const nlohmann::json &j)
Constructor of KLocalPolynomial system class.
Definition k_local_polynomial.hpp:111
KLocalPolynomial(const graph::Binaries &init_binaries, const graph::Polynomial< FloatType > &poly_graph)
Constructor of KLocalPolynomial system class.
Definition k_local_polynomial.hpp:62
FloatType get_min_effective_dE() const
Get "min_effective_dE_", which is a rough lower bound of energy gap.
Definition k_local_polynomial.hpp:371
int64_t GetZeroCount(const std::size_t index_key) const
Return the number of variables taking the zero in the interaction specified by "index_key".
Definition k_local_polynomial.hpp:337
std::vector< int64_t > zero_count_
The number of variables taking the zero in each interaction.
Definition k_local_polynomial.hpp:451
void SortInteractions()
Sort interactions in accordance with its value and the degree of interactions (ascending order).
Definition k_local_polynomial.hpp:505
const cimod::PolynomialValueList< FloatType > & get_values() const
Get the PolynomialValueList object, which is the list of the values of the polynomial interactions as...
Definition k_local_polynomial.hpp:376
FloatType dE_k_local(const std::size_t index_key)
Return the energy difference of k-local update.
Definition k_local_polynomial.hpp:224
FloatType min_effective_dE_
Rough lower bound of energy gap.
Definition k_local_polynomial.hpp:472
void reset_dE()
Reset energy differences (dE), which is used to determine whether to flip the binary or not.
Definition k_local_polynomial.hpp:181
std::vector< std::size_t > update_index_zero_count_v_
The list of virtually updated index of zero_count_v_, which is used to implement k-local update.
Definition k_local_polynomial.hpp:492
std::vector< std::size_t > update_index_binaries_v_
The list of virtually updated index of binaries_v_, which is used to implement k-local update.
Definition k_local_polynomial.hpp:496
std::vector< FloatType > dE_v_
The energy differences when flipping a binary, which is used to implement k-local update.
Definition k_local_polynomial.hpp:480
std::unordered_set< std::size_t > update_index_dE_v_
The list of virtually updated delta E's, which is used to implement k-local update.
Definition k_local_polynomial.hpp:488
void update_system_single(const graph::Index index_update_binary)
Flip specified binary by single spin flip.
Definition k_local_polynomial.hpp:256
std::vector< FloatType > dE_
The energy differences when flipping a binary.
Definition k_local_polynomial.hpp:448
const int64_t num_binaries
The number of binaries.
Definition k_local_polynomial.hpp:43
void SetAdj()
Set adjacency list.
Definition k_local_polynomial.hpp:542
void reset_virtual_system()
Reset binary configurations virtually updated by k-local update.
Definition k_local_polynomial.hpp:305
graph::Binaries binaries
Binary configurations.
Definition k_local_polynomial.hpp:52
void set_rate_call_k_local(int rate_k_local)
Set "rate_call_k_local".
Definition k_local_polynomial.hpp:323
std::pair< std::vector< graph::Index >, FloatType > FindMinInteraction(const FloatType threshold=0.0) const
Return the key and value of the absolute minimum interaction.
Definition k_local_polynomial.hpp:606
const std::vector< std::vector< graph::Index > > & get_adj() const
Get the adjacency list, which is the list of the indices of polynomial interactions including specifi...
Definition k_local_polynomial.hpp:390
const std::vector< graph::Index > & get_active_binaries() const
Get "active_binaries_", which is the list of the binaries connected by at least one interaction.
Definition k_local_polynomial.hpp:360
void reset_binaries(const graph::Binaries &init_binaries)
Reset KLocalPolynomial system with new binary configurations.
Definition k_local_polynomial.hpp:159
cimod::PolynomialKeyList< graph::Index > poly_key_list_
The list of the indices of the polynomial interactions as std::vector<std::vector<graph::Index>>.
Definition k_local_polynomial.hpp:459
std::vector< std::vector< graph::Index > > adj_
Adjacency list, which is the list of the indices of polynomial interactions including specific binary...
Definition k_local_polynomial.hpp:455
std::string get_vartype_string() const
Get the vartype as std::string, which must be "BINARY".
Definition k_local_polynomial.hpp:394
void update_system_k_local()
Update binary configurations by k-local update.
Definition k_local_polynomial.hpp:239
FloatType get_max_effective_dE() const
Get "max_effective_dE_", which is a upper bound of energy gap.
Definition k_local_polynomial.hpp:366
FloatType GetPolyValue(const std::size_t index_key) const
Get the value of the interaction specified by "index_key".
Definition k_local_polynomial.hpp:344
std::vector< int64_t > zero_count_v_
The list of virtually updated the number of variables taking the zero in each interaction,...
Definition k_local_polynomial.hpp:500
FloatType max_effective_dE_
Upper bound of energy gap.
Definition k_local_polynomial.hpp:469
std::pair< std::vector< graph::Index >, FloatType > FindMaxInteraction() const
Return the key and value of the absolute maximum interaction.
Definition k_local_polynomial.hpp:587
int64_t num_interactions_
The number of the interactions.
Definition k_local_polynomial.hpp:445
KLocalPolynomial class, which is a system to solve higher order unconstrained binary optimization (HU...
Definition k_local_polynomial.hpp:32
std::vector< Binary > Binaries
Definition graph.hpp:29
auto json_parse(const json &obj, bool relabel=true)
parse json object from bqm.to_serializable
Definition parse.hpp:50
int Binary
Definition graph.hpp:28
std::size_t Index
Definition graph.hpp:30
auto make_k_local_polynomial(const graph::Binaries &init_binaries, const GraphType &init_interaction)
Helper function for ClassicalIsingPolynomial constructor.
Definition k_local_polynomial.hpp:633
Definition algorithm.hpp:24
double FloatType
Note:
Definition compile_config.hpp:37
classical monte carlo system (using beta (inverse temperature) for annealing parameter)
Definition system.hpp:31