Пример #1
0
def move_turbines_within_boundary(turb_pos_x: list,
                                  turb_pos_y: list,
                                  boundary: Polygon,
                                  valid_region: Polygon
                                  ) -> (np.ndarray, float):
    """
    :param turb_pos_x: list of x coordinates
    :param turb_pos_y: list of y coordinates
    :param boundary: site boundary
    :param valid_region: region to move turbines into
    :return: adjusted x and y coordinates
    """
    squared_error: float = 0.0
    num_turbines = len(turb_pos_x)
    
    for i in range(num_turbines):
        point = Point(turb_pos_x[i], turb_pos_y[i])
        distance = valid_region.distance(point)
        
        if distance > 0:
            point = boundary.interpolate(boundary.project(point))
            
            squared_error += distance ** 2
        
        turb_pos_x[i] = point.x
        turb_pos_y[i] = point.y
    
    return turb_pos_x, turb_pos_y, squared_error
Пример #2
0
	#pretty_print_poly(P1)
	#pretty_print_poly(P2)


	# Stability test where a lot of cuts are performed on one polygon
	P = [[(0.9285714285714286, 1.785714285714285), (0.8333333333333334, 0.1666666666666667), (1.0, 0.0), (2.0, 0.0), (1.681818181818182, 1.863636363636363), (3.0, 2.0), (2.0, 3.0), (1.0, 3.0), (0.9285714285714286, 1.785714285714285)], []]
	e = [(2.711344240884324, 1.970139059401827), (1.722081099006799, 1.627810705817321)]
	
	polyExterior = Polygon(*P).exterior
	from numpy import linspace
	from itertools import product
	searchDistances = list(linspace(0, polyExterior.length, 0))

	searchSpace = []
	for distance in searchDistances:
		solutionCandidate = polyExterior.interpolate(distance)
		searchSpace.append((solutionCandidate.x, solutionCandidate.y))
	for cutEdge in product(searchSpace, repeat=2):

		result = polygon_split(P, cutEdge)



	# Stability test where a lot of cuts are performed on one polygon
	P = [[(0, 0),
		  (3, 1),
		  (3, 0),
		  (4, 1),
		  (5, 0),
		  (5, 1),
		  (7, 1),