diff --git a/cxx/clean_relation.hh b/cxx/clean_relation.hh index e5625d3..0131c6f 100644 --- a/cxx/clean_relation.hh +++ b/cxx/clean_relation.hh @@ -518,7 +518,7 @@ class CleanRelation : public Relation { } } - ValueType nearest(const ValueType& x, const T_items& items, std::mt19937* prng) const { + ValueType nearest(std::mt19937* prng, const ValueType& x, const T_items& items) const { std::vector z = get_cluster_assignment(items); if (clusters.contains(z)) { return clusters.at(z)->nearest(x); diff --git a/cxx/clean_relation_test.cc b/cxx/clean_relation_test.cc index 3fa2d08..895a7e6 100644 --- a/cxx/clean_relation_test.cc +++ b/cxx/clean_relation_test.cc @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(test_clean_relation) { BOOST_TEST(z1[0] == 0); BOOST_TEST(z1[1] == 0); BOOST_TEST(z1[2] == 0); - BOOST_TEST(R1.nearest(1, {1, 1, 3}, &prng) == 1); + BOOST_TEST(R1.nearest(&prng, 1, {1, 1, 3}) == 1); auto z2 = R1.get_cluster_assignment_gibbs({0, 1, 3}, D2, 1, 191); BOOST_TEST(z2.size() == 3); @@ -222,6 +222,6 @@ BOOST_AUTO_TEST_CASE(test_nearest) { R1.incorporate(&prng, {1, 1}, "911"); R1.incorporate(&prng, {2, 2}, "8675309"); - BOOST_TEST(R1.nearest("1234", {0, 1}, &prng) == "1234"); - BOOST_TEST(R1.nearest("jj9jddd322", {1, 2}, &prng) == "9322"); + BOOST_TEST(R1.nearest(&prng, "1234", {0, 1}) == "1234"); + BOOST_TEST(R1.nearest(&prng, "jj9jddd322", {1, 2}) == "9322"); } diff --git a/cxx/noisy_relation_test.cc b/cxx/noisy_relation_test.cc index 7e5bd93..628138d 100644 --- a/cxx/noisy_relation_test.cc +++ b/cxx/noisy_relation_test.cc @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(test_noisy_relation) { BOOST_TEST(z1[0] == 0); BOOST_TEST(z1[1] == 0); BOOST_TEST(z1[2] == 0); - BOOST_TEST(NR1.nearest(1, {1, 1, 3}, &prng) == 1); + BOOST_TEST(NR1.nearest(&prng, 1, {1, 1, 3}) == 1); double lpg __attribute__((unused)); lpg = NR1.logp_gibbs_approx(D1, 0, 1, &prng); @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(test_noisy_relation) { NR2.set_cluster_assignment_gibbs(D3, 3, 1, &prng); D1.set_cluster_assignment_gibbs(0, 1); - BOOST_TEST(NR2.nearest("cat", {1, 3}, &prng) == "cat"); + BOOST_TEST(NR2.nearest(&prng, "cat", {1, 3}) == "cat"); } BOOST_AUTO_TEST_CASE(test_unincorporate) { diff --git a/cxx/relation.hh b/cxx/relation.hh index ef48d68..f3f090d 100644 --- a/cxx/relation.hh +++ b/cxx/relation.hh @@ -133,7 +133,7 @@ class Relation { // Return the value nearest to x that has non-zero probability under the // Relation's distribution for the items. - virtual ValueType nearest(const ValueType& x, const T_items& items, std::mt19937* prng) const { + virtual ValueType nearest(std::mt19937* prng, const ValueType& x, const T_items& items) const { return x; }; diff --git a/cxx/transition_latent_value.hh b/cxx/transition_latent_value.hh index 6354ef7..7e7338e 100644 --- a/cxx/transition_latent_value.hh +++ b/cxx/transition_latent_value.hh @@ -58,7 +58,7 @@ void transition_latent_value( // > 0 probability. A better solution would involve rewritting the // propose_clean methods to take the base_relation's Distribution as // a parameter. - candidate = base_relation->nearest(candidate, base_items, prng); + candidate = base_relation->nearest(prng, candidate, base_items); latent_value_candidates.push_back(candidate); } }