Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlkiviadisAleiferis committed Jan 12, 2025
1 parent a9f4523 commit 8dece5e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions hyperpack/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,11 @@ def _get_initial_vertical_segments(self, container_width, container_length):
def _get_initial_point(self, potential_points, **kwargs):
return potential_points["O"], "O"

def calculate_objective_value(self, obj_value, w, l, W, L, Xo, Yo, horizontals, verticals, container_coords):
def calculate_objective_value(
self, obj_value, w, l, W, L, Xo, Yo, horizontals, verticals, container_coords
):
return obj_value + (w * l) / (W * L)


def _construct_solution(self, cont_id, container, items, debug=False) -> tuple:
"""
Point generation construction heuristic
Expand All @@ -475,7 +476,7 @@ def _construct_solution(self, cont_id, container, items, debug=False) -> tuple:
L = self._get_initial_container_length(container)
W = container["W"]

total_surface = W * L
W * L
# obj_value is the container utilization
# obj_value = Area(Placed Items)/Area(Container)
obj_value = self.init_obj_value
Expand Down Expand Up @@ -538,15 +539,15 @@ def _construct_solution(self, cont_id, container, items, debug=False) -> tuple:

if not strip_pack:
obj_value = self.calculate_objective_value(
obj_value,
w,
l,
W,
L,
Xo,
Yo,
horizontals,
verticals,
obj_value,
w,
l,
W,
L,
Xo,
Yo,
horizontals,
verticals,
container_coords,
)

Expand Down Expand Up @@ -578,7 +579,9 @@ def _construct_solution(self, cont_id, container, items, debug=False) -> tuple:

if strip_pack:
height_of_solution = max(set(horizontals)) or 1
items_area = sum([item["w"]*item["l"] for _, item in current_solution.items()])
items_area = sum(
[item["w"] * item["l"] for _, item in current_solution.items()]
)
obj_value = items_area / (W * height_of_solution)

return items, obj_value, current_solution
Expand All @@ -592,9 +595,9 @@ def _get_container_solution(self, current_solution):
for _id in current_solution:
item = current_solution[_id]
solution[_id] = [
item["Xo"],
item["Yo"],
item["w"] if not item["rotated"] else item["l"],
item["Xo"],
item["Yo"],
item["w"] if not item["rotated"] else item["l"],
item["l"] if not item["rotated"] else item["w"],
]
return solution
Expand Down

0 comments on commit 8dece5e

Please sign in to comment.