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