Skip to content

Commit 92e041f

Browse files
authored
Bug fix for suwa-todo method (#493)
# Change 諏訪藤堂法のアルゴリズムにバグがあったので直したました。 オーバーフローを避けるために確率を定数倍していたことを考慮できていなかったので直しました。
1 parent 6d2fc77 commit 92e041f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/openjij/updater/single_integer_move.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ struct SuwaTodoUpdater {
176176
}
177177

178178
double prob_sum = 0.0;
179-
const double rand = dist(sa_system.random_number_engine);
179+
const double rand = dist(sa_system.random_number_engine) * weight_list[now_state];
180180

181181
for (std::int64_t j = 0; j < var.num_states; ++j) {
182182
const double d_ij = sum_weight_list[now_state + 1] - sum_weight_list[j] +
183183
sum_weight_list[1];
184-
prob_sum += std::max(0.0, std::min({d_ij, 1.0 + weight_list[j] - d_ij,
185-
1.0, weight_list[j]}));
184+
prob_sum += std::max(0.0, std::min({d_ij, weight_list[now_state] + weight_list[j] - d_ij,
185+
weight_list[now_state], weight_list[j]}));
186186
if (rand < prob_sum) {
187187
std::int64_t new_state;
188188
if (j == max_weight_state) {

0 commit comments

Comments
 (0)