コード例 #1
0
ファイル: testangularchoice.py プロジェクト: e-kotov/PST
	def test_ach_square(self):
		line_count = 4
		line_length = 3
		graph = CreateSegmentSquareGraph(line_length)
		self.doTest(graph, line_count, Radii(), False, [1,1,1,1], [line_count]*line_count, [4]*line_count, None)
		self.doTest(graph, line_count, Radii(angular=80), False, None, [1]*line_count, [0]*line_count, None)
		self.doTest(graph, line_count, Radii(angular=100), False, None, [3]*line_count, [2]*line_count, None)
		self.doTest(graph, line_count, Radii(), True, [36,36,36,36], [line_count]*line_count, [4,4,4,4], [12,12,12,12])
		pstalgo.FreeSegmentGraph(graph)
コード例 #2
0
	def test_arch_region_attr(self):
		count = 5
		length = 3
		g = CreateRegionOriginChainGraph(count, length)
		attraction_points = array.array('d', [-2, 0, -1, 0, -1, -1, -2, -1, length*count+1, 0, length*count+2, 0, length*count+2, -1, length*count+1, -1])  # One region left of and another right of graph
		points_per_attraction_polygon = array.array('I', [4, 4])
		attraction_polygon_point_interval = 0.5
		attraction_values = array.array('f', [4, 3])
		collect_func = pstalgo.AttractionCollectionFunc.AVARAGE
		distr_func   = pstalgo.AttractionDistributionFunc.DIVIDE
		self.doTest(g, count, OriginType.POINT_GROUPS, DistanceType.UNDEFINED, Radii(), AttractionWeightFunction.CONSTANT, 0, attraction_points, points_per_attraction_polygon, attraction_polygon_point_interval, attraction_values, distr_func, collect_func, [4+3]*count)
		distr_func   = pstalgo.AttractionDistributionFunc.COPY
		self.doTest(g, count, OriginType.POINT_GROUPS, DistanceType.UNDEFINED, Radii(), AttractionWeightFunction.CONSTANT, 0, attraction_points, points_per_attraction_polygon, attraction_polygon_point_interval, attraction_values, distr_func, collect_func, [4+3]*count)
		pstalgo.FreeGraph(g)
コード例 #3
0
	def test_arch_point_origin(self):
		count = 5
		length = 3
		g = CreatePointOriginChainGraph(count, length)
		attraction_points = array.array('d', [-1, 0, length*count+1, 0])  # One point left of and another right of graph
		attraction_values = array.array('f', [4, 3])
		collect_func = pstalgo.AttractionCollectionFunc.AVARAGE  # Redundant here
		distr_func   = pstalgo.AttractionDistributionFunc.DIVIDE  # Redundant here
		self.doTest(g, count, OriginType.POINTS,    DistanceType.UNDEFINED, Radii(),        AttractionWeightFunction.CONSTANT, 0, attraction_points, None, 0, attraction_values, distr_func, collect_func, [4+3]*count)
		self.doTest(g, count, OriginType.LINES,     DistanceType.UNDEFINED, Radii(),        AttractionWeightFunction.CONSTANT, 0, attraction_points, None, 0, attraction_values, distr_func, collect_func, [4+3]*count)
		self.doTest(g, count, OriginType.JUNCTIONS, DistanceType.UNDEFINED, Radii(),        AttractionWeightFunction.CONSTANT, 0, attraction_points, None, 0, attraction_values, distr_func, collect_func, [4+3]*(count-1))
		self.doTest(g, count, OriginType.POINTS,    DistanceType.UNDEFINED, Radii(steps=2), AttractionWeightFunction.CONSTANT, 0, attraction_points, None, 0, attraction_values, distr_func, collect_func, [4,4,4+3,3,3])
		self.doTest(g, count, OriginType.POINTS,    DistanceType.STEPS,     Radii(steps=2), AttractionWeightFunction.DIVIDE,   1, attraction_points, None, 0, attraction_values, distr_func, collect_func, [4,2,4.0/3+1,1.5,3])
		pstalgo.FreeGraph(g)
コード例 #4
0
 def test_aint_square(self):
     count = 4
     length = 3
     g = CreateSegmentSquareGraph(length)
     self.doTest(g, count, False, Radii(), [count] * count, [4] * count,
                 None, [float(count - 1) / 5] * count,
                 [math.pow(count, 1.2) / 5] * count, None)
     self.doTest(g, count, True, Radii(), [count] * count, [4] * count,
                 None, [9.0 / 13.0] * count,
                 [math.pow(9, 1.2) / 13.0] * count, None)
     self.doTest(g, count, False, Radii(angular=80), [1] * count,
                 [0] * count, None, None, None, None)
     self.doTest(g, count, False, Radii(angular=100), [3] * count,
                 [2] * count, None, None, None, None)
     pstalgo.FreeSegmentGraph(g)
コード例 #5
0
	def test_reach_square(self):
		line_count = 4
		line_length = 3
		graph = CreateSquareGraph(line_length)

		tests = [
			(Radii(), [4, 4, 4, 4], [line_length*line_count]*line_count, [line_length*line_length]*line_count),
			(Radii(angular=80), [1, 1, 1, 1], [line_length*1]*line_count, [0]*line_count),
			(Radii(angular=100), [3, 3, 3, 3], [line_length*3]*line_count, [line_length*line_length]*line_count),
			(Radii(angular=190), [4, 4, 4, 4], [line_length*line_count]*line_count, [line_length*line_length]*line_count),
		]

		self.runTests(graph, tests, line_count)

		pstalgo.FreeGraph(graph)
コード例 #6
0
 def test_sgint_crshr(self):
     count = 12
     gcount = 8
     seg_graph = CreateCrosshairSegmentGraph()
     group_arr = array.array('I', [0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7])
     group_graph = pstalgo.CreateSegmentGroupGraph(seg_graph, group_arr,
                                                   gcount)
     self.doTest(group_graph, gcount, Radii(), None, [gcount] * gcount,
                 [11, 11, 11, 11, 10, 10, 10, 10])
     self.doTest(group_graph, gcount, Radii(steps=1), None,
                 [4, 4, 4, 4, 5, 5, 5, 5], [3, 3, 3, 3, 4, 4, 4, 4])
     self.doTest(group_graph, gcount, Radii(walking=1), None,
                 [7, 7, 7, 7, 8, 8, 8, 8], [9, 9, 9, 9, 10, 10, 10, 10])
     pstalgo.FreeSegmentGroupGraph(group_graph)
     pstalgo.FreeSegmentGraph(seg_graph)
コード例 #7
0
	def test_NInt_single(self):
		line_count = 1
		line_length = 3
		graph = CreateChainGraph(line_count, line_length)
		tests = [
			(Radii(), [-1], [1], [0]),
		]
		self.runTests(graph, tests, line_count)
		pstalgo.FreeGraph(graph)
コード例 #8
0
	def test_arch_region_origin(self):
		count = 5
		length = 3
		g = CreateRegionOriginChainGraph(count, length)
		attraction_points = array.array('d', [-1, 0, length*count+1, 0])  # One point left of and another right of graph
		attraction_values = array.array('f', [4, 3])
		collect_func = pstalgo.AttractionCollectionFunc.AVARAGE
		distr_func   = pstalgo.AttractionDistributionFunc.DIVIDE  # Redundant here
		self.doTest(g, count, OriginType.POINT_GROUPS, DistanceType.UNDEFINED, Radii(), AttractionWeightFunction.CONSTANT, 0, attraction_points, None, 0, attraction_values, distr_func, collect_func, [4+3]*count)
		pstalgo.FreeGraph(g)
コード例 #9
0
ファイル: testodbetweenness.py プロジェクト: e-kotov/PST
 def test_odb_dest_weights(self):
     g = CreateTestGraph()
     self.doTest(
         graph_handle=g,
         origin_points=array.array('d', [-0.5, 0]),
         origin_weights=array.array('f', [10]),
         destination_weights=array.array('f', [4, 1]),
         destination_mode=ODBDestinationMode.ALL_REACHABLE_DESTINATIONS,
         distance_type=DistanceType.WALKING,
         radius=Radii(),
         scores_check=[10, 10, 2])
     pstalgo.FreeGraph(g)
コード例 #10
0
ファイル: testodbetweenness.py プロジェクト: e-kotov/PST
 def test_odb_radius(self):
     g = CreateTestGraph()
     self.doTest(
         graph_handle=g,
         origin_points=array.array('d', [-0.5, 0]),
         origin_weights=None,
         destination_weights=None,
         destination_mode=ODBDestinationMode.ALL_REACHABLE_DESTINATIONS,
         distance_type=DistanceType.WALKING,
         radius=Radii(walking=3.9),
         scores_check=[1, 1, 0])
     self.doTest(
         graph_handle=g,
         origin_points=array.array('d', [-0.5, 0]),
         origin_weights=None,
         destination_weights=None,
         destination_mode=ODBDestinationMode.ALL_REACHABLE_DESTINATIONS,
         distance_type=DistanceType.WALKING,
         radius=Radii(walking=4.1),
         scores_check=[1, 1, .5])
     pstalgo.FreeGraph(g)
コード例 #11
0
ファイル: testodbetweenness.py プロジェクト: e-kotov/PST
 def test_odb_closest(self):
     g = CreateTestGraph()
     self.doTest(
         graph_handle=g,
         origin_points=array.array('d', [-0.5, 0]),
         origin_weights=None,
         destination_weights=None,
         destination_mode=ODBDestinationMode.CLOSEST_DESTINATION_ONLY,
         distance_type=DistanceType.WALKING,
         radius=Radii(),
         scores_check=[1, 1, 0])
     pstalgo.FreeGraph(g)
コード例 #12
0
ファイル: testangularchoice.py プロジェクト: e-kotov/PST
	def test_ach_line_weight(self):
		line_count = 5
		line_length = 3
		graph = CreateSegmentChainGraph(line_count, line_length)
		choice = array.array('f', [0])*line_count
		pstalgo.AngularChoice(
			graph_handle = graph,
			radius = Radii(), 
			weigh_by_length = True,
			angle_threshold = 0,
			angle_precision = 1, 
			out_choice = choice)
		self.assertEqual(choice, array.array('f', [36, 90, 108, 90, 36]))
		pstalgo.FreeSegmentGraph(graph)
コード例 #13
0
	def test_NInt_chain(self):
		line_count = 5
		line_length = 3
		graph = CreateChainGraph(line_count, line_length)
		tests = [
			(Radii(), [0.352, 0.704, 1.056, 0.704, 0.352], [line_count]*line_count, [10, 7, 6, 7, 10]),
			(Radii(straight=0), None, [1]*line_count, None),
			(Radii(straight=1), None, [1]*line_count, None),
			(Radii(straight=line_length), None, [2, 3, 3, 3, 2], None),
			(Radii(walking=0), None, [1]*line_count, None),
			(Radii(walking=1), None, [1]*line_count, None),
			(Radii(walking=3), None, [2, 3, 3, 3, 2], None),
			(Radii(steps=0), None, [1]*line_count, None),
			(Radii(steps=1), None, [2, 3, 3, 3, 2], None),
			(Radii(steps=2), None, [3, 4, 5, 4, 3], None),
			(Radii(angular=1), None, [line_count]*line_count, None),
		]
		self.runTests(graph, tests, line_count)
		pstalgo.FreeGraph(graph)
コード例 #14
0
	def test_reach_chain(self):
		line_count = 3
		line_length = 3
		graph = CreateChainGraph(line_count, line_length)

		tests = [
			(Radii(), [3, 3, 3], [9, 9, 9], [0, 0, 0]),
			(Radii(straight=0), [1, 1, 1], [3, 3, 3], [0, 0, 0]),
			(Radii(straight=1), [1, 1, 1], [3, 3, 3], [math.pi]*3),
			(Radii(straight=3), [2, 3, 2], [6, 9, 6], [3*3*math.pi]*3),
			(Radii(walking=0), [1, 1, 1], [3, 3, 3], [0, 0, 0]),
			(Radii(walking=1), [1, 1, 1], [3, 3, 3], [0, 0, 0]),
			(Radii(walking=3), [2, 3, 2], [6, 9, 6], [0, 0, 0]),
			(Radii(steps=0), [1, 1, 1], [3, 3, 3], [0, 0, 0]),
			(Radii(steps=1), [2, 3, 2], [6, 9, 6], [0, 0, 0]),
			(Radii(steps=2), [3, 3, 3], [9, 9, 9], [0, 0, 0]),
			(Radii(angular=1), [3, 3, 3], [9, 9, 9], [0, 0, 0]),
		]

		self.runTests(graph, tests, line_count)

		pstalgo.FreeGraph(graph)
コード例 #15
0
ファイル: testangularchoice.py プロジェクト: e-kotov/PST
	def test_ach_five_chain(self):
		line_count = 5
		line_length = 3
		graph = CreateSegmentChainGraph(line_count, line_length)
		self.doTest(graph, line_count, Radii(), False, [0, 6, 8, 6, 0], [line_count]*line_count, [0, 0, 0, 0, 0], None)
		self.doTest(graph, line_count, Radii(straight=0), False, None, [1]*line_count, None, None)
		self.doTest(graph, line_count, Radii(straight=1), False, None, [1]*line_count, None, None)
		self.doTest(graph, line_count, Radii(straight=line_length), False, None, [2, 3, 3, 3, 2], None, None)
		self.doTest(graph, line_count, Radii(walking=0), False, None, [1]*line_count, None, None)
		self.doTest(graph, line_count, Radii(walking=1), False, None, [1]*line_count, None, None)
		self.doTest(graph, line_count, Radii(walking=3), False, None, [2, 3, 3, 3, 2], None, None)
		self.doTest(graph, line_count, Radii(steps=0), False, None, [1]*line_count, None, None)
		self.doTest(graph, line_count, Radii(steps=1), False, None, [2, 3, 3, 3, 2], None, None)
		self.doTest(graph, line_count, Radii(steps=2), False, None, [3, 4, 5, 4, 3], None, None)
		self.doTest(graph, line_count, Radii(angular=1), False, None, [line_count]*line_count, None, None)
		self.doTest(graph, line_count, Radii(), True, [36.0, 90.0, 108.0, 90.0, 36.0], [line_count]*line_count, [0, 0, 0, 0, 0], [0, 0, 0, 0, 0])
		pstalgo.FreeSegmentGraph(graph)
コード例 #16
0
 def test_aint_five_chain(self):
     count = 5
     length = 3
     g = CreateSegmentChainGraph(count, length)
     self.doTest(g, count, False, Radii(), [count] * count, [0] * count,
                 None, [4] * count, [math.pow(count, 1.2)] * count,
                 [count * count] * count)
     self.doTest(g, count, True, Radii(), [count] * count, [0] * count,
                 None, None, None, None)
     self.doTest(g, count, False, Radii(straight=0), [1] * count, None,
                 None, None, None, None)
     self.doTest(g, count, False, Radii(straight=1), [1] * count, None,
                 None, None, None, None)
     self.doTest(g, count, False, Radii(straight=length), [2, 3, 3, 3, 2],
                 None, None, None, None, None)
     self.doTest(g, count, False, Radii(walking=0), [1] * count, None, None,
                 None, None, None)
     self.doTest(g, count, False, Radii(walking=1), [1] * count, None, None,
                 None, None, None)
     self.doTest(g, count, False, Radii(walking=3), [2, 3, 3, 3, 2], None,
                 None, None, None, None)
     self.doTest(g, count, False, Radii(steps=0), [1] * count, None, None,
                 None, None, None)
     self.doTest(g, count, False, Radii(steps=1), [2, 3, 3, 3, 2], None,
                 None, None, None, None)
     self.doTest(g, count, False, Radii(steps=2), [3, 4, 5, 4, 3], None,
                 None, None, None, None)
     self.doTest(g, count, False, Radii(angular=1), [count] * count, None,
                 None, None, None, None)
     pstalgo.FreeSegmentGraph(g)
コード例 #17
0
    def test_sgint_chain(self):
        count = 5
        length = 3
        seg_graph = CreateSegmentChainGraph(count, length)

        group_arr = array.array('I', [i for i in range(count)])
        group_graph = pstalgo.CreateSegmentGroupGraph(seg_graph, group_arr,
                                                      count)
        self.doTest(group_graph, count, Radii(),
                    [0.352, 0.704, 1.056, 0.704, 0.352], [count] * count,
                    [10, 7, 6, 7, 10])
        self.doTest(group_graph, count, Radii(walking=0), None,
                    [2, 3, 3, 3, 2], None)
        self.doTest(group_graph, count, Radii(walking=1), None,
                    [2, 3, 3, 3, 2], None)
        self.doTest(group_graph, count, Radii(walking=3), None,
                    [3, 4, 5, 4, 3], None)
        self.doTest(group_graph, count, Radii(steps=0), None, [1, 1, 1, 1, 1],
                    None)
        self.doTest(group_graph, count, Radii(steps=1), None, [2, 3, 3, 3, 2],
                    None)
        self.doTest(group_graph, count, Radii(steps=2), None, [3, 4, 5, 4, 3],
                    None)
        self.doTest(group_graph, count, Radii(walking=3, steps=0), None,
                    [1] * count, None)
        self.doTest(group_graph, count, Radii(walking=0, steps=2), None,
                    [2, 3, 3, 3, 2], None)
        pstalgo.FreeSegmentGroupGraph(group_graph)

        group_arr = array.array('I', [0, 1, 1, 1, 2])
        group_graph = pstalgo.CreateSegmentGroupGraph(seg_graph, group_arr, 3)
        self.doTest(group_graph, 3, Radii(), None, [3, 3, 3], [3, 2, 3])
        self.doTest(group_graph, 3, Radii(steps=0), None, [1, 1, 1], [0, 0, 0])
        self.doTest(group_graph, 3, Radii(steps=1), None, [2, 3, 2], [1, 2, 1])
        self.doTest(group_graph, 3, Radii(walking=0), None, [2, 3, 2],
                    [1, 2, 1])
        self.doTest(group_graph, 3, Radii(walking=5), None, [2, 3, 2],
                    [1, 2, 1])
        self.doTest(group_graph, 3, Radii(walking=9), None, [3, 3, 3],
                    [3, 2, 3])
        pstalgo.FreeSegmentGroupGraph(group_graph)

        pstalgo.FreeSegmentGraph(seg_graph)