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
Exemple #2
0
def decode_geometry_msg(request_geometries):
    product_boxes = []
    for sp in request_geometries:
        product_boxes.append(
            Cuboid(Point(sp.dimensions))
        )
    return product_boxes
    def place_product(self, box_idx: int, box_cuboid: Cuboid,
                      chromosome: Chromosome, container_space: Space) -> Space:
        orientations = box_cuboid.get_rotation_permutations()
        orientations = [
            o for o in orientations if o.can_fit_in(container_space)
        ]

        orientation = chromosome.decode_orientation(box_idx, orientations)

        return Space.from_placement(container_space.origin(), orientation)
Exemple #4
0
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 find_best_placement_space(self, container: Container,
                               product_box: Cuboid):
     max_dist = -1
     best_ems = None
     if len(container.empty_space_list) == 0:
         return best_ems
     orientations = product_box.get_rotation_permutations()
     bottom_sorted = container.empty_space_list[:]
     bottom_sorted.sort(key=lambda s: self.__axis_value(s))
     z_level = self.__axis_value(bottom_sorted[0])
     for ems in bottom_sorted:
         current_z_level = self.__axis_value(ems)
         # TODO rb: this is pretty hard-edge, works for equal ground level,
         #  but for values > 0 maybe a more interval based approach?
         if z_level < current_z_level and best_ems is not None:
             break
         if ems.volume() >= product_box.volume():
             max_dist, best_ems = self._find_best_ems_for_orientations(
                 max_dist, best_ems, ems, orientations)
         z_level = current_z_level
     return best_ems
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
Exemple #7
0
                        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, cuboid: Cuboid):
     self.cuboid = cuboid
     self.smallest_dimension: int = min(cuboid.dimensions)
     self.volume: int = cuboid.volume()