-
Notifications
You must be signed in to change notification settings - Fork 7
Update LTZ parmeter #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I converted to draft due to unexpected behavior in testing. |
mdonaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug fixes and minor error countermeasures have been added.
|
A following patch may help you. Click to toggle contents of patch and details of failed testdiff --git a/src/ComputationContainer/FixedPoint/FixedPoint.hpp b/src/ComputationContainer/FixedPoint/FixedPoint.hpp
index e25b2f1d..0d496935 100644
--- a/src/ComputationContainer/FixedPoint/FixedPoint.hpp
+++ b/src/ComputationContainer/FixedPoint/FixedPoint.hpp
@@ -103,7 +103,18 @@ public:
ret = std::numeric_limits<D>::max();
}
ret /= shift;
- return ret.str(20, std::ios_base::fixed);
+ return ret.str(0, std::ios_base::fixed); // optional, it prints all decimal points template because type `D` has 50 decimal places. using other serializations may better choice.
+ }
+ T getRoundValue() const
+ {
+ D ret{this->getVal<D>()};
+ if (boost::math::isinf(ret))
+ {
+ ret = std::numeric_limits<D>::max();
+ }
+ ret /= shift;
+ ret = mp::round(ret);
+ return static_cast<T>(ret);
}
double getDoubleVal() const
{
diff --git a/src/ComputationContainer/Share/Compare.cpp b/src/ComputationContainer/Share/Compare.cpp
index ca1e48d5..2c0a4132 100644
--- a/src/ComputationContainer/Share/Compare.cpp
+++ b/src/ComputationContainer/Share/Compare.cpp
@@ -57,8 +57,8 @@ bool operator==(const Share<FixedPoint> &left, const Share<FixedPoint> &right)
{
// |x-y|<ep <=> (x-y<ep)&(y-x<ep)
auto epsilon = 0.0001;
- auto x_ret = (left < right + epsilon);
- auto y_ret = (right < left + epsilon);
+ auto x_ret = (left < right);
+ auto y_ret = (right < left);
auto ret = (FixedPoint(1) - x_ret) * (FixedPoint(1) - y_ret);
if (ret.getDoubleVal() > 0.95)
diff --git a/src/ComputationContainer/Share/Share.hpp b/src/ComputationContainer/Share/Share.hpp
index 29ba1faf..63342d77 100644
--- a/src/ComputationContainer/Share/Share.hpp
+++ b/src/ComputationContainer/Share/Share.hpp
@@ -489,7 +489,7 @@ Share<T> getLSBShare(const Share<T> &y)
Share<T> t = y + r0 + T(2) * r_dash;
open(t);
T c = recons(t);
- c = T(std::round(c.getDoubleVal())) % T(2);
+ c = T(c.getRoundValue()) % T(2);
Share<T> b = c + r0 - T(2) * c * r0;
return b;
}
@@ -506,7 +506,7 @@ std::vector<Share<T>> getLSBShare(const std::vector<Share<T>> &y)
b.reserve(y.size());
for (int j = 0; j < static_cast<int>(c.size()); ++j)
{
- c[j] = T(std::round(c[j].getDoubleVal())) % T(2);
+ c[j] = T(c[j].getRoundValue()) % T(2);
b.emplace_back(c[j] + r0[j] - T(2) * c[j] * r0[j]);
}
diff --git a/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp b/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp
index 77346c28..9bd47d4f 100644
--- a/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp
+++ b/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp
@@ -544,6 +544,9 @@ TEST(ShareTest, EqualityEpsilonTest)
auto val_d1 = static_cast<double>(val1) / (1LL << m) / n_parties;
auto val_d2 = static_cast<double>(val2) / (1LL << m) / n_parties;
+ std::cerr << val_d1 << " == " << val_d2 << " : " << (val_d1 == val_d2) << std::endl;
+ std::cerr << "\t" << std::abs(val_d1 - val_d2) << std::endl;
+
auto s1 = Share(FixedPoint(std::to_string(val_d1)));
auto s2 = Share(FixedPoint(std::to_string(val_d2))); |
|
@mdonaka |
|
The test passed, but the internal 1000 rows of data do not guarantee 100% accuracy. |
|
Parameter tuning is completed. The internal data confirmed 100% accuracy. |
arukuka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdonaka Thank you for your contribution!
I left a comment because I had some concerns.
I would appreciate it if you could confirm it.
1cf8366 to
fa1c97e
Compare
fa1c97e to
71d01a0
Compare
`std::to_string` outs 6 decimal points
71d01a0 to
45bc76c
Compare
Summary
Update LTZ parmeter
Purpose
Allow larger values to be used to avoid ID collisions
Contents
Testing Methods Performed
Etc
collision probability
Assuming 1 million data, at least less than 1%. calculation
speed
Since it should be linear with respect to k, it can be estimated to be 1.5 times. But it was faster than I expected.
Larger sizes may produce different results, but this is time consuming and will be omitted here.
k is LTZ parameter. H is table row size.