Esempio n. 1
0
class ArfMAin:
    """
    This class is a simple implementation of the ARF. It is not suppose to be a scalable implementation.
    Args :
    :param dim: int that represent the dimension of the vector space.
    :param domain: int that represent the domain of the vector space.
    :param size: int that is the size of the ARF in bits.
    """
    def __init__(self,
                 path_file_feed,
                 path_file_test,
                 dim=1,
                 domain=1000,
                 size=1000,
                 delta_error=1,
                 methode_discretize=Constants.DIS_TESTS):
        self.discretizor = RectangleDiscretisator(delta_error,
                                                  methode_discretize)
        # get data for feed
        self.data_vector_feed = DataVector(dim, path_file_feed)
        # get data for test
        self.data_vector_test = DataVector(dim, path_file_test)
        if methode_discretize == Constants.DIS_DOUBLE:
            min_range_size = delta_error
        else:
            min_range_size = 2 * delta_error
        self.arf = ARF(dim, domain, min_range_size, size)

    def feed(self):
        """

        :return:
        """
        points = self.data_vector_feed.get_points()
        d_points = self.discretizor.discretise_points_to_insert(points)
        self.arf.insert_set_of_points(d_points)
        self.arf.erase()

    def test(self):
        """
        :return:
        """
        points = self.data_vector_test.get_points()
        d_points = self.discretizor.discretise_points_to_test(points)
        return self.arf.test_set_of_points(d_points)
Esempio n. 2
0
 def __init__(self,
              path_file_feed,
              path_file_test,
              dim=1,
              domain=1000,
              size=1000,
              delta_error=1,
              methode_discretize=Constants.DIS_TESTS):
     self.discretizor = RectangleDiscretisator(delta_error,
                                               methode_discretize)
     # get data for feed
     self.data_vector_feed = DataVector(dim, path_file_feed)
     # get data for test
     self.data_vector_test = DataVector(dim, path_file_test)
     if methode_discretize == Constants.DIS_DOUBLE:
         min_range_size = delta_error
     else:
         min_range_size = 2 * delta_error
     self.arf = ARF(dim, domain, min_range_size, size)
Esempio n. 3
0
 def test_arf1_pile(self):
     arf1 = ARF(dim=2, domain=32, min_range_size=4)
     arf1.insert_one_point(Point([3, 5]))
     res = arf1.test_one_point(Point([3, 5]))
     self.assertEqual(res, True, "ARF test exact same value")
Esempio n. 4
0
 def test_arf_dim3_or(self):
     arf1 = ARF(dim=3, domain=32, min_range_size=4)
     arf1.insert_one_point(Point([3, 5, 3]))
     res, _ = arf1.test_set_of_points([[Point([3, 5, 3]), Point([8, 5, 3])]])
     self.assertEqual(res, [True], "Problem with ARF dim = 3")
Esempio n. 5
0
 def test_erase(self):
     myArf = ARF(dim=1, domain=32, min_range_size=4, size=9)
     myArf.insert_one_point(Point([1]))
     myArf.erase()
     assert myArf.get_bit_size() == 7, "Problem with erase"
Esempio n. 6
0
 def test_arf_dim4(self):
     arf1 = ARF(dim=4, domain=32, min_range_size=4)
     arf1.insert_one_point(Point([3, 5, 3, 5]))
     res, _ = arf1.test_set_of_points([[Point([3, 5, 3, 5])], [Point([7, 12, 3, 5])]])
     self.assertEqual(res, [True, False], "Problem with ARF dim = 4")
Esempio n. 7
0
 def test_arf_collision(self):
     arf1 = ARF(dim=2, domain=32, min_range_size=4)
     arf1.insert_one_point(Point([3, 5]))
     arf1.insert_one_point(Point([3, 5]))
     res = arf1.test_one_point(Point([3, 5]))
     self.assertEqual(res, True, "Problem with ARF with collision inside inputs")
Esempio n. 8
0
 def test_arf_mrs_1(self):
     arf1 = ARF(dim=2, domain=32, min_range_size=1)
     arf1.insert_one_point(Point([3, 5]))
     res = arf1.test_one_point(Point([3, 5]))
     self.assertEqual(res, True, "Problem with ARF with min range size = 1")
Esempio n. 9
0
 def test_arf1_domaine(self):
     arf1 = ARF(dim=2, domain=30, min_range_size=4)
     self.assertEqual(32, arf1.domain), "ARF don't have the correct domaine"
Esempio n. 10
0
 def test_arf1_almost(self):
     arf1 = ARF(dim=2, domain=32, min_range_size=4)
     arf1.insert_one_point(Point([3, 5]))
     res = arf1.test_one_point(Point([2, 6]))
     self.assertEqual(res, True, "ARF don't match on almost sames values")