コード例 #1
0
 def test_dominateProbability1(self):
     tData1 = Data("t_1", 2)
     tData1.insertLocation(0.5, [8, 2])
     tData1.insertLocation(0.5, [4, 8])
     tData2 = Data("t_2", 2)
     tData2.insertLocation(0.3, [7, 9])
     tData2.insertLocation(0.4, [2, 4])
     self.assertEqual(dominateProbability(tData1, tData2), 0.15)
コード例 #2
0
 def test_dominateProbability2(self):
     tData3 = Data("t_3", 2)
     tData3.insertLocation(0.2, [1, 3, 5])
     tData3.insertLocation(0.8, [2, 4, 5])
     tData4 = Data("t_4", 2)
     tData4.insertLocation(0.4, [2, 4, 6])
     tData4.insertLocation(0.6, [1, 5, 7])
     self.assertEqual(dominateProbability(tData3, tData4), 0.52)
コード例 #3
0
 def test_Data_getProb(self):
     d_gp = Data('d_gp', 3)
     d_gp.insertLocation(0.1, [3, 5])
     d_gp.insertLocation(0.4, [4, 6])
     d_gp.insertLocation(0.5, [8, 7])
     self.assertEqual(d_gp.getProb(0), 0.1)
     self.assertEqual(d_gp.getProb(1), 0.4)
     self.assertEqual(d_gp.getProb(2), 0.5)
     self.assertEqual(d_gp.getProb(3), None)
コード例 #4
0
 def test_Data_getLocation(self):
     d_glo = Data('d_glo', 2)
     d_glo.insertLocation(0.7, [3, 6, 2])
     d_glo.insertLocation(0.3, [4, 1, 8])
     self.assertEqual(d_glo.getLocation(0), [3, 6, 2])
     self.assertEqual(d_glo.getLocation(1), [4, 1, 8])
     self.assertEqual(d_glo.getLocation(2), [])
コード例 #5
0
# No class implemented in this file. Test only.
import os, sys
sys.path.append(os.path.abspath(os.pardir))

from rtree import index
from data.dataClass import Data

if __name__ == '__main__':
    p = index.Property()
    p.dimension = 2
    p.dat_extension = 'data'
    p.idx_extension = 'index'
    idx3d = index.Index('3d_index', properties=p)
    test = Data('t1', 2)
    test.insertLocation(0.4, [6, 4])
    test.insertLocation(0.6, [3, 5])
    #               (d1min,d2min,...,dnmin,d1max,d2max,...,dnmax)
    # idx3d.insert(1, test.getMinMaxTuple(),obj=test)
    idx3d.insert(1, test.getMinMaxTuple(), obj=test)

    # idx3d.insert(1, (2, 60, 23, 4, 61, 25), obj='h1')
    # idx3d.insert(2, (2, 3, 22, 4, 5, 24),obj='h2')
    # idx3d.insert(3, (2, 51, 30, 4, 54, 31),obj='h3')
    # idx3d.insert(4, (2, 51, 23, 4, 65, 45),obj='h4')

    #                              (d1min,d2min,...,dnmin,d1max,d2max,...,dnmax)
    h = [i.object for i in (idx3d.intersection((0, 0, 10, 10), objects=True))]

    # h = list(idx3d.intersection( (0, 50, 22, 3, 62, 43) ,objects=True))

    for i in h:
コード例 #6
0
 def test_Data_insertLocation(self):
     d_til = Data('d_til', 1)
     d_til.insertLocation(1, [2, 3, 4])
     self.assertEqual(d_til.getLocation(0), [2, 3, 4])
コード例 #7
0
 def test_Data_getMinMaxTuple(self):
     d_gmmt = Data('d_gmmt', 2)
     d_gmmt.insertLocation(0.7, [8, 3, 9])
     d_gmmt.insertLocation(0.3, [4, 7, 2])
     self.assertEqual(d_gmmt.getMinMaxTuple(), (4, 3, 2, 8, 7, 9))
コード例 #8
0
 def test_Data_getLocationMin(self):
     d_glmi = Data('d_glmi', 3)
     d_glmi.insertLocation(0.2, [4, 5, 9])
     d_glmi.insertLocation(0.2, [6, 2, 3])
     d_glmi.insertLocation(0.2, [7, 0, 5])
     self.assertEqual(d_glmi.getLocationMin(), [4, 0, 3])
コード例 #9
0
 def test_Data_getLocationMax(self):
     d_glm = Data('d_glm', 3)
     d_glm.insertLocation(0.2, [4, 5, 9])
     d_glm.insertLocation(0.2, [6, 2, 3])
     d_glm.insertLocation(0.2, [7, 0, 5])
     self.assertEqual(d_glm.getLocationMax(), [7, 5, 9])
コード例 #10
0
 def test_Data_getProbLocSet(self):
     d_gpls = Data('d_gpls', 1)
     d_gpls.insertLocation(1, [4, 4])
     self.assertEqual(d_gpls.getProbLocSet(0), [1, [4, 4]])
     self.assertEqual(d_gpls.getProbLocSet(1), [None, []])
コード例 #11
0
 def test_Data_getPCount(self):
     d_gpc = Data('d_gpc', 2)
     d_gpc.insertLocation(0.2, [2, 3])
     d_gpc.insertLocation(0.8, [5, 4])
     self.assertEqual(d_gpc.getPCount(), 2)
コード例 #12
0
 def test_Data_getLabel(self):
     d_gl = Data('d_gl', 2)
     self.assertEqual(d_gl.getLabel(), 'd_gl')
コード例 #13
0
    l1eql2 = 0
    l2doml1 = 0
    for i in range(axis):
        if loc1[i] < loc2[i]:
            l1doml2 += 1
        elif loc1[i] > loc2[i]:
            l2doml1 += 1
        else:
            l1eql2 += 1
    if l1doml2 == 0 and l2doml1 != 0:
        return False
    elif l2doml1 == 0 and l1doml2 != 0:
        return True
    else:
        return None

if __name__ == '__main__':
    data = batchImport('test_30_dim2_pos3_rad2_0100.csv', 3)
    lbl = str(input('input the lable of data point: '))
    index = -1
    data1 = Data('tmp',2)
    for i,d in enumerate(data):
        if d.getLabel() == lbl:
            data1 = d
            index = i
            break
    del data[index]

    for d in data:
        print('Probability that '+ lbl + ' dominates ' + d.getLabel() + ' is: ' + str(dominateProbability(data1, d)))