Exemplo n.º 1
0
 def Generate(self,
              matrix,
              noBuilding=50,
              maxLength=100,
              minLength=10,
              maxWidth=100,
              minWidth=10,
              maxHeight=500,
              minHeight=10):
     for i in range(noBuilding):
         length = random.randint(minLength, maxLength)
         width = random.randint(minWidth, maxWidth)
         height = random.randint(minHeight, maxHeight)
         lon = random.randint(np.ceil(length / 2),
                              matrix.cellWidth * matrix.indexRange[0])
         lat = random.randint(np.ceil(width / 2),
                              matrix.cellLength * matrix.indexRange[1])
         self.AddObstacle(
             MatrixBuilder.Building(lon, lat, length, width, height))
Exemplo n.º 2
0
import networkx as nx
from Matrix import MatrixBuilder, BuildingGenerator
import time

airmatrix = MatrixBuilder.Matrix((1000, 1000, 500), 100, 50)

obstacle = BuildingGenerator.BuildingGenerator()
obstacle.Generate(airmatrix, 15, 100, 10, 100, 10, 100, 10)
airmatrix.NodeListConstructor(obstacle)
airmatrix.MatrixConstructor()

graph = nx.Graph()
graph.add_nodes_from(airmatrix.nodeList)

edges = list()

for node in airmatrix.nodeList:
    index = int(node.x + node.y * airmatrix.indexRange[0] + node.z * airmatrix.indexRange[0] * airmatrix.indexRange[1])
    for neighbour in airmatrix.FindInNetwork(index):
        edges.append((node, airmatrix.FindInNodelist(neighbour[0])))

graph.add_edges_from(edges)

time_start = time.time()
edgeConnectivity = nx.edge_connectivity(graph)
time_end = time.time()
print('time cost', time_end-time_start, 's')
Exemplo n.º 3
0
from Matrix import MatrixBuilder
from PathFinder import AStarWithHolding
from SimulationEngine import TrafficGenerator
from SimulationEngine import RandomAircraftCreator
import time
import copy

aircraftList = RandomAircraftCreator.AircraftDataBase()
airmatrix = MatrixBuilder.Matrix((3000, 3000, 2000))
airmatrix.NodeListConstructor()
airmatrix.MatrixConstructor()
traffic = TrafficGenerator.TrafficGenerator(airmatrix, aircraftList, 100)

planner = AStarWithHolding.AStarWithHolding(airmatrix, traffic)

time_start = time.time()
planner.InitialPlan()
time_end = time.time()
print('time cost', time_end-time_start, 's')
backup = copy.deepcopy(planner.initPlanner.planResult)

time_start = time.time()
planner.ConflictSolver()
time_end = time.time()
print('time cost', time_end-time_start, 's')
from Matrix import MatrixBuilder
from PathFinder import AStar
from PathFinder import Dijkstra
from SimulationEngine import TrafficGenerator
from SimulationEngine import RandomAircraftCreator
from Matrix import BuildingGenerator
import time

# no obstacle case
aircraftList = RandomAircraftCreator.AircraftDataBase()
airmatrix = MatrixBuilder.Matrix((3000, 3000, 2000), 100, 50)
airmatrix.NodeListConstructor()
airmatrix.MatrixConstructor()
traffic = TrafficGenerator.TrafficGenerator(airmatrix, aircraftList, 100)

# Dijkstra Algorithm
finder = Dijkstra.MultiDij(airmatrix, traffic.trafficPlan)
time_start = time.time()
finder.MultiSearch()
dijkstra_result = finder.planResult
time_end = time.time()
print('time cost', time_end-time_start, 's')

# AStar Algorithm
finder = AStar.AStarMultiple(airmatrix, traffic.trafficPlan)
time_start = time.time()
finder.MultiSearch()
astar_result = finder.planResult
time_end = time.time()
print('time cost', time_end-time_start, 's')
Exemplo n.º 5
0
'''
Testing A Star with Obstacles
'''
from Matrix import MatrixBuilder
from PathFinder import AStarwObstacle
from SimulationEngine import TrafficGenerator
from SimulationEngine import RandomAircraftCreator
import time

aircraftList = RandomAircraftCreator.AircraftDataBase()
airmatrix = MatrixBuilder.Matrix((5000, 5000, 2000))
airmatrix.NodeListConstructor()
airmatrix.MatrixConstructor()

traffic = TrafficGenerator.TrafficGenerator(airmatrix, aircraftList, 100)
solver = AStarwObstacle.MultiASwO(airmatrix, traffic, 3600)

time_start = time.time()
solver.MultiSearch()
time_end = time.time()
print('time cost', time_end - time_start, 's')

# printing result
for result in solver.planResult:
    duration = result.trajectory[len(result.trajectory) -
                                 1][2] - result.trajectory[0][2]
    print(duration)