def decode_geometry_msg(request_geometries): product_boxes = [] for sp in request_geometries: product_boxes.append( Cuboid(Point(sp.dimensions)) ) return product_boxes
class DFTRCStrategy(PlacementStrategy): def __init__(self, container_spec: Cuboid): self.container_spec = container_spec self.container_upper_right = Point( self.container_spec.dimensions.coords) # DFTRC-2 Distance to the Front Top Right Corner def find_best_placement_space(self, container: Container, product_box: Cuboid) -> Space: max_dist = -1.0 best_ems = None orientations = product_box.get_rotation_permutations() for ems in container.empty_space_list: if ems.volume() >= product_box.volume(): max_dist, best_ems = self._find_best_ems_for_orientations( max_dist, best_ems, ems, orientations) return best_ems def _find_best_ems_for_orientations(self, max_dist, best_ems, ems: Space, orientations: []) -> (float, Space): fitting_orientations = (o for o in orientations if o.can_fit_in(ems)) for orientation in fitting_orientations: box_upper_right = Space.from_placement(ems.origin(), orientation).upper_right dist = self.container_upper_right.squared_distance_from( box_upper_right) if dist > max_dist: max_dist = dist best_ems = ems return max_dist, best_ems
def __calculate_genetic_parameters(parameters: dict, num_items: int): parameters['population_size'] = parameters['population_factor'] * num_items parameters['num_elites'] = int(parameters['elites_percentage'] * parameters['population_size']) parameters['num_mutants'] = int(parameters['mutants_percentage'] * parameters['population_size']) if parameters['delivery_bin_spec'] is None: parameters['delivery_bin_spec'] = [30, 30, 30] parameters['delivery_bin_spec'] = Cuboid( Point(np.array(parameters['delivery_bin_spec']))) return parameters
def read_csv_data(file="data/product_boxes.csv"): product_boxes = [] with open(file, 'r') as csvfile: reader = csv.DictReader(csvfile, delimiter=',') for row in reader: count = int(row['count']) index = 0 while index < count: product_boxes.append( Cuboid( Point.from_scalars(int(row['width']), int(row['depth']), int(row['height'])))) index += 1 return product_boxes
def create_vertices(cuboid): o = Point.new_origin().coords u = cuboid.dimensions.coords return create_vertices_from_points(o, u)
float(placement_solution.box_id) / len(delivery_bins[del_bin]), float(placement_solution.box_id) / len(delivery_bins[del_bin]), 1)) plt.show() def plot_placements(container_bin, placements, plot_spaces=False): g = plot_container(container_bin) for i, product_placement in enumerate(placements): if product_placement: draw_placement(g, product_placement, ((float(i + 1) / len(placements)), 0, 0, 0)) if plot_spaces: for empty_space in container_bin.empty_space_list: if empty_space: draw_space(g, empty_space, empty_color) plt.show() if __name__ == '__main__': spec = Cuboid(Point.from_scalars(30, 30, 30)) container_ = Container(spec) g = plot_container(container_) g.view_init(elev=30., azim=60) b = Point(np.array([5, 5, 5])) d = Point(np.array([3, 2, 3])) s = Space(d, b) draw_space(g, s, product_color) plt.show()
def __init__(self, specification: Cuboid): self.specification = specification self.used_volume: int = 0 self.empty_space_list = [Space.from_placement(Point.new_origin(), specification)]
def __init__(self, container_spec: Cuboid): self.container_spec = container_spec self.container_upper_right = Point( self.container_spec.dimensions.coords)