@jetta/blocks-allocator 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/README.md +103 -2
  2. package/package.json +67 -5
  3. package/src/Allocation_Attempt.js +135 -0
  4. package/src/Allocation_Error_Handler.js +69 -0
  5. package/src/Allocation_Flow.js +162 -0
  6. package/src/Allocation_Optimization/Allocation_LP.js +150 -0
  7. package/src/Allocation_Optimization/Block_Allocator.js +129 -0
  8. package/src/Allocation_Optimization/Block_Layer_Order.js +50 -0
  9. package/src/Allocation_Optimization/Block_Potential_Weight.js +54 -0
  10. package/src/Allocation_Optimization/Chosen_Blocks_Stock_Cap.js +82 -0
  11. package/src/Allocation_Optimization/block_builder/Allocation_Item_Creator.js +37 -0
  12. package/src/Allocation_Optimization/block_builder/Block_Item_List_Validator.js +18 -0
  13. package/src/Allocation_Optimization/block_builder/Block_Wall_Builder.js +303 -0
  14. package/src/Allocation_Optimization/block_builder/Blocks_Builder.js +40 -0
  15. package/src/Allocation_Optimization/block_builder/Next_Block_Position.js +33 -0
  16. package/src/Allocation_Optimization/block_builder/Slot_Item_Assigner.js +45 -0
  17. package/src/Allocation_Optimization/block_builder/Stacking_Validation.js +30 -0
  18. package/src/Allocation_Optimization/block_builder/assert_tie_ratio_block_matches_orientation_below.js +44 -0
  19. package/src/Allocation_Optimization/block_builder/block_shape_stock.js +129 -0
  20. package/src/Allocation_Optimization/block_builder/exceptions/Empty_Block_Item_List_Exception.js +21 -0
  21. package/src/Allocation_Optimization/block_builder/exceptions/Invalid_Stacking_Exception.js +14 -0
  22. package/src/Allocation_Optimization/block_builder/exceptions/No_Suitable_Item_Exception.js +16 -0
  23. package/src/Allocation_Optimization/block_builder/exceptions/Restricted_Block_Exception.js +21 -0
  24. package/src/Allocation_Optimization/block_builder/should_omit_block_group_id.js +29 -0
  25. package/src/Allocation_Optimization/block_builder/snap_elevated_block_wall_items.js +34 -0
  26. package/src/Allocation_Optimization/block_builder/stacking_rules_input.js +52 -0
  27. package/src/Allocation_Optimization/cap_chosen_blocks_by_shape_stock.js +110 -0
  28. package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Preparer.js +21 -0
  29. package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Selector.js +55 -0
  30. package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Threshold_Resolver.js +28 -0
  31. package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Thresholds.js +23 -0
  32. package/src/Allocation_Optimization/density_groups/Container_Utilization.js +67 -0
  33. package/src/Allocation_Optimization/density_groups/Density_Group_Partitioner.js +74 -0
  34. package/src/Allocation_Optimization/density_groups/Density_Group_Scheduler.js +168 -0
  35. package/src/Allocation_Optimization/density_groups/Density_Group_Stock.js +49 -0
  36. package/src/Allocation_Optimization/density_groups/Density_Groups_Strategy.js +26 -0
  37. package/src/Allocation_Optimization/density_groups/Item_Density_Calculator.js +20 -0
  38. package/src/Allocation_Optimization/density_groups/Lock_Weight_Ahead_Release.js +75 -0
  39. package/src/Allocation_Optimization/exceptions/Invalid_Item_Amount_Exception.js +17 -0
  40. package/src/Allocation_Optimization/exceptions/No_Valid_Allocation_Exception.js +14 -0
  41. package/src/Allocation_Optimization/exceptions/Optimization_Infeasible_Exception.js +14 -0
  42. package/src/Allocation_Optimization/functions/Measure_Reader.js +20 -0
  43. package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Cobination_Mode.js +25 -0
  44. package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Cobination_Strategies.js +8 -0
  45. package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Combination_Mode_Checkers.js +70 -0
  46. package/src/Allocation_Optimization/functions/Weight_Getter/Translation.js +22 -0
  47. package/src/Allocation_Optimization/functions/Weight_Getter/Variable_Weight_Getter.js +85 -0
  48. package/src/Allocation_Optimization/functions/Weight_Getter/constants.js +16 -0
  49. package/src/Allocation_Optimization/functions/measure_to_optimize.js +6 -0
  50. package/src/Allocation_Optimization/item_consumption_heuristic/Capacity_Bias_Item_Order.js +76 -0
  51. package/src/Allocation_Optimization/item_consumption_heuristic/Choose_Item_Heuristic_Context.js +63 -0
  52. package/src/Allocation_Optimization/item_consumption_heuristic/Item_Chooser.js +159 -0
  53. package/src/Allocation_Optimization/item_consumption_heuristic/Item_For_Slot_Chooser.js +49 -0
  54. package/src/Allocation_Optimization/item_consumption_heuristic/Slot_Compatible_Items_Finder.js +88 -0
  55. package/src/Allocation_Optimization/item_consumption_heuristic/Slots_Items_Assigner.js +182 -0
  56. package/src/Allocation_Optimization/item_consumption_heuristic/Stack_Slot_Calculator.js +87 -0
  57. package/src/Allocation_Optimization/item_consumption_heuristic/Weight_Slot_Distribution.js +72 -0
  58. package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/Empty_Slot_Exception.js +17 -0
  59. package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/Item_Taller_Than_Limit_Exception.js +21 -0
  60. package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/No_Available_Items_Exception.js +14 -0
  61. package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/No_Slots_For_Items_Exception.js +14 -0
  62. package/src/Allocation_Optimization/lp_model/Block_Weight_Calculator.js +31 -0
  63. package/src/Allocation_Optimization/lp_model/LP_Data_Processor.js +42 -0
  64. package/src/Allocation_Optimization/lp_model/LP_Item_Slot_Assignment.js +93 -0
  65. package/src/Allocation_Optimization/lp_model/LP_Result_Mapper.js +47 -0
  66. package/src/Allocation_Optimization/lp_model/model_builder/Dimension_Range_Helper.js +49 -0
  67. package/src/Allocation_Optimization/lp_model/model_builder/Item_Assignment_Variables.js +133 -0
  68. package/src/Allocation_Optimization/lp_model/model_builder/LP_Model_Builder.js +132 -0
  69. package/src/Allocation_Optimization/lp_model/model_builder/exceptions/Missing_Item_Stock_Exception.js +18 -0
  70. package/src/Allocation_Optimization/lp_model/model_builder/goal_function/Goal_Function_Creator.js +83 -0
  71. package/src/Allocation_Optimization/lp_model/model_builder/item_dimension_hashes.js +31 -0
  72. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Block_Item_Amount_Restriction.js +53 -0
  73. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Coherence_Restriction.js +65 -0
  74. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Container_Supported_Weight_Restriction.js +42 -0
  75. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Relational_Exact_Pass_Amount_Restriction.js +62 -0
  76. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Relational_Group_Restriction.js +97 -0
  77. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Single_Item_Type_Restriction.js +79 -0
  78. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Space_Restriction.js +47 -0
  79. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Unavailable_Block_Restriction.js +27 -0
  80. package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Uniform_Block_Measure_Restriction.js +92 -0
  81. package/src/Allocation_Optimization/next_group_id_after_preloaded.js +30 -0
  82. package/src/Allocation_Optimization/preferential_blocks/Preferential_Block_Identifier.js +74 -0
  83. package/src/Allocation_Optimization/preferential_blocks/key_item/Key_Item_Mapper.js +49 -0
  84. package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Almost_Unique_Item.js +31 -0
  85. package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Cant_Stack_It_Self.js +68 -0
  86. package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Rule_Interface.js +26 -0
  87. package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Intercalation_State.js +49 -0
  88. package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Orientation_Filter.js +33 -0
  89. package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Vertical_Stack_Filter.js +20 -0
  90. package/src/Allocation_Optimization/tie_ratio/collect_tie_ratio_orientations_below_footprint.js +64 -0
  91. package/src/Allocation_Optimization/tie_ratio/filter_blocks_by_orientation.js +17 -0
  92. package/src/Allocation_Optimization/tie_ratio/find_orientation_below_space.js +77 -0
  93. package/src/Allocation_Optimization/tie_ratio/loose_on_block/allocated_item_penetrates_any.js +31 -0
  94. package/src/Allocation_Optimization/tie_ratio/loose_on_block/apply_loose_placement_to_allocated_item.js +94 -0
  95. package/src/Allocation_Optimization/tie_ratio/loose_on_block/axis_overlap_length.js +16 -0
  96. package/src/Allocation_Optimization/tie_ratio/loose_on_block/block_local_origin.js +18 -0
  97. package/src/Allocation_Optimization/tie_ratio/loose_on_block/box_fits_inside_container.js +39 -0
  98. package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_allocated_item_at_placement.js +18 -0
  99. package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_placement_on_generic_supporter.js +64 -0
  100. package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_slot_grid_from_cluster.js +66 -0
  101. package/src/Allocation_Optimization/tie_ratio/loose_on_block/compare_group_ids.js +20 -0
  102. package/src/Allocation_Optimization/tie_ratio/loose_on_block/container_with_pending_wall_items.js +26 -0
  103. package/src/Allocation_Optimization/tie_ratio/loose_on_block/empty_space_is_on_floor.js +16 -0
  104. package/src/Allocation_Optimization/tie_ratio/loose_on_block/finalize_loose_item_placement.js +58 -0
  105. package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_best_generic_supporter_placement.js +58 -0
  106. package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_next_free_slot_index.js +119 -0
  107. package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_supporter_directly_below.js +51 -0
  108. package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_tie_ratio_supporter_cluster.js +57 -0
  109. package/src/Allocation_Optimization/tie_ratio/loose_on_block/footprint_xz_overlap_area.js +26 -0
  110. package/src/Allocation_Optimization/tie_ratio/loose_on_block/item_fits_supporter_slot.js +22 -0
  111. package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_footprint_region_from_options.js +24 -0
  112. package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_item_fits_inside_container.js +21 -0
  113. package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_item_has_geometric_support.js +21 -0
  114. package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_on_block_slot_state.js +88 -0
  115. package/src/Allocation_Optimization/tie_ratio/loose_on_block/placement_coords_fit_inside_container.js +34 -0
  116. package/src/Allocation_Optimization/tie_ratio/loose_on_block/read_empilhar_area_igual_from_allocation_item.js +12 -0
  117. package/src/Allocation_Optimization/tie_ratio/loose_on_block/realigned_loose_geometry_gates.js +25 -0
  118. package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_loose_on_generic_supporter.js +65 -0
  119. package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_loose_placement_position.js +68 -0
  120. package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_placement_y_at_slot.js +45 -0
  121. package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_without_tie_ratio_cluster.js +79 -0
  122. package/src/Allocation_Optimization/tie_ratio/loose_on_block/select_tie_ratio_slot_placement.js +84 -0
  123. package/src/Allocation_Optimization/tie_ratio/loose_on_block/slot_footprint_collision.js +105 -0
  124. package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_cluster_selection.js +119 -0
  125. package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_footprint_overlap.js +56 -0
  126. package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_placement_plane.js +109 -0
  127. package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_supporter_predicate.js +23 -0
  128. package/src/Allocation_Optimization/tie_ratio/loose_on_block/try_tie_ratio_slot_placement.js +62 -0
  129. package/src/Allocation_Optimization/tie_ratio/snap_stacked_items_to_floor_footprints.js +138 -0
  130. package/src/Allocation_Optimization/tie_ratio/supporters_by_top_y_index.js +78 -0
  131. package/src/Allocation_Optimization/tie_ratio/tie_ratio_orientation_below_empty_space.js +89 -0
  132. package/src/Allocation_Optimization/tie_ratio/tie_ratio_orientation_from_group.js +48 -0
  133. package/src/Block_Management.js +34 -0
  134. package/src/Blocks_Preparation/Cube_Map_Function.js +27 -0
  135. package/src/Blocks_Wall_Allocation.js +3 -0
  136. package/src/IO/Answer_Status.js +4 -0
  137. package/src/IO/Output_Builder.js +35 -0
  138. package/src/IO/count_allocated_items.js +31 -0
  139. package/src/IO/create_error_response.js +62 -0
  140. package/src/IO/format_allocation_error_message.js +25 -0
  141. package/src/Item_Continuation_Lock.js +129 -0
  142. package/src/Item_Picking_Continuity.js +41 -0
  143. package/src/allocation_flow/chooser_session_state.js +21 -0
  144. package/src/allocation_flow/compound_probe_fallback.js +17 -0
  145. package/src/allocation_flow/container_remaining_capacity.js +23 -0
  146. package/src/allocation_flow/density_group_item_filter.js +31 -0
  147. package/src/allocation_flow/effective_item_fingerprint.js +14 -0
  148. package/src/allocation_flow/item_continuation_lock_gate.js +38 -0
  149. package/src/allocation_flow/no_space_left_recovery.js +48 -0
  150. package/src/allocation_flow/run_allocation_iteration.js +155 -0
  151. package/src/allocation_flow/space_skip_state.js +91 -0
  152. package/src/allocation_flow/try_no_space_left_recovery.js +50 -0
  153. package/src/exceptions/Invalid_Parameter_Exception.js +17 -0
  154. package/src/exceptions/Relational_Allocation_Incomplete_Exception.js +24 -0
  155. package/src/exceptions/Relational_Colocation_Violation_Exception.js +23 -0
  156. package/src/exceptions/Relational_Config_Mismatch_Exception.js +17 -0
  157. package/src/exceptions/There_Is_No_Block_Options_To_Allocate_Exception.js +14 -0
  158. package/src/index.js +6 -0
  159. package/src/input_preparation/Block_Formatter.js +179 -0
  160. package/src/input_preparation/Input_Creator.js +76 -0
  161. package/src/input_preparation/Input_State_Preparation.js +47 -0
  162. package/src/input_preparation/State_Builder.js +27 -0
  163. package/src/input_preparation/block_formatter/align_flush_axis_config.js +36 -0
  164. package/src/input_preparation/block_formatter/align_flush_axis_single_round.js +112 -0
  165. package/src/input_preparation/block_formatter/align_flush_stacked_slots.js +67 -0
  166. package/src/input_preparation/block_formatter/overlapped_slots.js +24 -0
  167. package/src/input_preparation/block_formatter/parallelepiped_shell.js +38 -0
  168. package/src/input_preparation/block_formatter/rectangle_coverage.js +112 -0
  169. package/src/input_preparation/block_formatter/shell_face_coverage.js +64 -0
  170. package/src/input_preparation/block_formatter/shell_snap_convergence.js +104 -0
  171. package/src/input_preparation/block_preparation/Block_Data_To_Object_Transformer.js +57 -0
  172. package/src/input_preparation/block_preparation/Block_Module_Name.js +17 -0
  173. package/src/input_preparation/block_preparation/Blocks_Creator.js +101 -0
  174. package/src/input_preparation/block_preparation/Blocksmith.js +19 -0
  175. package/src/input_preparation/block_preparation/block_modules/create_block_candidates.js +41 -0
  176. package/src/input_preparation/block_preparation/block_modules/manual_blocks.js +10 -0
  177. package/src/input_preparation/block_preparation/block_modules/module_registry.js +20 -0
  178. package/src/input_preparation/block_preparation/block_modules/run_creator.js +34 -0
  179. package/src/input_preparation/block_preparation/block_modules/single_item_blocks.js +12 -0
  180. package/src/input_preparation/block_preparation/block_modules/spiral_blocks.js +12 -0
  181. package/src/input_preparation/block_preparation/block_modules/tie_ratio_blocks.js +12 -0
  182. package/src/input_preparation/block_preparation/block_modules/tower_blocks.js +12 -0
  183. package/src/input_preparation/block_preparation/exceptions/Failed_To_Create_Block_Exception.js +14 -0
  184. package/src/input_preparation/block_preparation/exceptions/Failed_To_Retrieve_Block_Exception.js +17 -0
  185. package/src/input_preparation/block_preparation/exceptions/Missing_Object_Store_Exception.js +10 -0
  186. package/src/input_preparation/block_preparation/exceptions/No_Blocks_Were_Created_Exception.js +14 -0
  187. package/src/input_preparation/block_preparation/input/Input_Creator.js +96 -0
  188. package/src/input_preparation/block_preparation/manual_blocks/Manual_Blocks.js +95 -0
  189. package/src/input_preparation/build_empty_space_finder_options.js +43 -0
  190. package/src/input_preparation/item_preparation/Items_Reader.js +27 -0
  191. package/src/input_preparation/min_extents_from_items.js +29 -0
  192. package/src/input_preparation/stackability_index/Blocks_Stackability_Index_Calculator.js +58 -0
  193. package/src/input_preparation/stackability_index/Slots_Stackability_index_Calculator.js +28 -0
  194. package/src/input_preparation/stackability_index/Stackability_Input_Creator.js +27 -0
  195. package/src/input_preparation/stackability_index/stackability_index_pop_stack.js +81 -0
  196. package/src/input_preparation/stacking_constraints/Weight_Stacking_Validation.js +15 -0
  197. package/src/lp_optimizer_result_status.js +20 -0
  198. package/src/messages/Allocator_Message.js +42 -0
  199. package/src/messages/resolve_error_message_entry.js +57 -0
  200. package/src/models/Allocated_Item.js +136 -0
  201. package/src/models/Allocation_Item.js +219 -0
  202. package/src/models/Block.js +198 -0
  203. package/src/models/Cargo_Profile.js +418 -0
  204. package/src/models/Preloaded_Allocated_Item.js +132 -0
  205. package/src/models/Slot.js +67 -0
  206. package/src/models/Stacking_Rules.js +58 -0
  207. package/src/models/auxiliaryFunctions/Available_Block_Module_List_Creator.js +9 -0
  208. package/src/models/auxiliaryFunctions/Measure_Translator.js +24 -0
  209. package/src/models/auxiliaryFunctions/item_json_reader.js +44 -0
  210. package/src/models/item_json_reader.js +71 -0
  211. package/src/models/placed_item_record.js +70 -0
  212. package/src/models/preloaded_rotation_helpers.js +38 -0
  213. package/src/models/slots_have_same_measure.js +45 -0
  214. package/src/models/transport/Container.js +162 -0
  215. package/src/models/transport/Transport.js +62 -0
  216. package/src/models/transport/build_stacking_feasibility_checker.js +64 -0
  217. package/src/models/transport/container_stacking_checkpoint.js +42 -0
  218. package/src/models/transport/factory/Container_Factory.js +46 -0
  219. package/src/models/transport/factory/Corner_Casting_Factory.js +62 -0
  220. package/src/models/transport/factory/Previously_Allocated_Item_Factory.js +28 -0
  221. package/src/models/transport/factory/Transport_Factory.js +13 -0
  222. package/src/models/transport/items_for_empty_space_finder.js +91 -0
  223. package/src/models/transport/resolve_container_stacking_inputs.js +23 -0
  224. package/src/models/transport/stacking_input_from_wire.js +58 -0
  225. package/src/optimizer_connection_errors.js +50 -0
  226. package/src/relational/Relational_Error_Codes.js +7 -0
  227. package/src/relational/finalize_relational_allocation.js +20 -0
  228. package/src/relational/has_relational_items.js +11 -0
  229. package/src/relational/is_relational_error_code.js +15 -0
  230. package/src/relational/resolve_relational_container_sequences.js +29 -0
  231. package/src/run_core_allocation.js +118 -0
  232. package/src/space_and_block_chooser/Space_And_Blocks_Chooser.js +115 -0
  233. package/src/space_and_block_chooser/blocks_filters/Block_Filter_Interface.js +19 -0
  234. package/src/space_and_block_chooser/blocks_filters/Filter_Runner.js +46 -0
  235. package/src/space_and_block_chooser/blocks_filters/initial_blocks_filter/Block_With_Overlapped_Slots_Filter.js +14 -0
  236. package/src/space_and_block_chooser/blocks_filters/initial_blocks_filter/Initial_Blocks_Filter_List.js +19 -0
  237. package/src/space_and_block_chooser/blocks_filters/pos_selection_filters/Blocks_Bigger_Than_Space_Filter.js +17 -0
  238. package/src/space_and_block_chooser/blocks_filters/pos_selection_filters/Post_Selection_Filter_List.js +9 -0
  239. package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/Insuficient_Items_Filter.js +81 -0
  240. package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/Pre_Selection_Filter_List.js +8 -0
  241. package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/max_tower_height/Blocks_Lower_Than_Max_Tower_Height.js +23 -0
  242. package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/max_tower_height/Max_Tower_Height.js +82 -0
  243. package/src/space_and_block_chooser/build_allocated_item_snapshots.js +19 -0
  244. package/src/space_and_block_chooser/compound_first_empty_space_branch.js +61 -0
  245. package/src/space_and_block_chooser/compound_first_with_leftover_fill.js +142 -0
  246. package/src/space_and_block_chooser/compound_first_without_leftover_fill.js +56 -0
  247. package/src/space_and_block_chooser/empty_spaces_where_post_selection_keeps_blocks.js +83 -0
  248. package/src/space_and_block_chooser/exceptions/Invalid_Space_To_Allocate_Exception.js +14 -0
  249. package/src/space_and_block_chooser/leftover_space_memory.js +113 -0
  250. package/src/space_and_block_chooser/leftover_unitary_blocks.js +153 -0
  251. package/src/space_and_block_chooser/leftover_unitary_empty_spaces.js +135 -0
  252. package/src/space_and_block_chooser/probe_set_pool.js +35 -0
  253. package/src/space_and_block_chooser/run_space_and_block_selection_attempt.js +88 -0
  254. package/src/tools/Array_Validator.js +6 -0
  255. package/src/tools/Clone.js +27 -0
  256. package/src/tools/Hash.js +8 -0
  257. package/src/tools/Rounder.js +5 -0
  258. package/src/tools/String_To_Boolean.js +12 -0
  259. package/src/tools/cargo_profile/Cargo_Profile_Field_Value_Resolver.js +44 -0
  260. package/src/tools/compact_items_with_stock.js +9 -0
  261. package/src/tools/mm_to_allocation_domain.js +14 -0
  262. package/src/tracing/Allocation_Tracer.js +52 -0
  263. package/src/tracing/Trace_Context.js +18 -0
  264. package/src/tracing/trace_outcome.js +18 -0
  265. package/src/tracing/traced_step.js +57 -0
  266. package/src/validation/Item_Continuation_Lock_Flag.js +52 -0
  267. package/src/validation/Item_Validation.js +29 -0
  268. package/src/validation/Relational_Colocation_Validator.js +60 -0
  269. package/src/validation/Relational_Completeness_Validator.js +146 -0
  270. package/src/validation/Relational_Continuation_Lock_Validation.js +37 -0
  271. package/src/validation/Relational_Proportional_Normalizer.js +194 -0
  272. package/src/validation/Validation.js +9 -0
  273. package/src/validation/Validation_Runner.js +20 -0
  274. package/src/validation/exceptions/Invalid_Block_Module_Config_Exception.js +14 -0
  275. package/src/validation/exceptions/Invalid_Input_Exception.js +14 -0
  276. package/src/validation/exceptions/Invalid_Input_Type_Exception.js +14 -0
  277. package/src/validation/schemas/allocated_item_schema.js +18 -0
  278. package/src/validation/schemas/allocation_request_schema.js +178 -0
  279. package/src/validation/schemas/container_row_schema.js +16 -0
  280. package/src/validation/schemas/item_schema.js +60 -0
  281. package/src/validation/schemas/transport_env_schema.js +19 -0
  282. package/src/validation/validate_block_module_config.js +147 -0
@@ -0,0 +1,132 @@
1
+ const { PositionedCube } = require('@jetta/empty-spaces-manager')
2
+ const {
3
+ build_placed_item_record,
4
+ build_stacking_info,
5
+ read_placed_position
6
+ } = require('./placed_item_record')
7
+ const { read_current_rotation, read_rotation_id } = require('./preloaded_rotation_helpers')
8
+
9
+ function read_wire_dimensions(wire)
10
+ {
11
+ return {
12
+ width: wire.w ?? wire.largura ?? wire.width,
13
+ height: wire.h ?? wire.altura ?? wire.height,
14
+ length: wire.d ?? wire.comprimento ?? wire.length
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Lightweight in-memory model for a previously placed item (no rotation machinery).
20
+ */
21
+ class Preloaded_Allocated_Item extends PositionedCube
22
+ {
23
+ #record
24
+ #stacking_info
25
+ #current_rotation
26
+ #rotation_id
27
+
28
+ /**
29
+ * @param {object} wire - Raw placed item from `container.items`.
30
+ */
31
+ constructor(wire)
32
+ {
33
+ const position = read_placed_position(wire)
34
+ const dimensions = read_wire_dimensions(wire)
35
+ super({
36
+ x: position.x,
37
+ y: position.y,
38
+ z: position.z,
39
+ width: dimensions.width,
40
+ height: dimensions.height,
41
+ length: dimensions.length
42
+ })
43
+ this.#record = build_placed_item_record(wire)
44
+ this.#stacking_info = build_stacking_info(wire)
45
+ this.#current_rotation = read_current_rotation(wire)
46
+ this.#rotation_id = read_rotation_id(wire)
47
+ }
48
+
49
+ get_stacking_info()
50
+ {
51
+ return this.#stacking_info
52
+ }
53
+
54
+ set_group_id(group_id)
55
+ {
56
+ this.#record.groupId = group_id
57
+ }
58
+
59
+ get_group_id()
60
+ {
61
+ return this.#record.groupId
62
+ }
63
+
64
+ get_weight()
65
+ {
66
+ return this.#record.peso
67
+ }
68
+
69
+ get_id()
70
+ {
71
+ return this.#record._id
72
+ }
73
+
74
+ /**
75
+ * User-facing SKU id for relational counting (matches {@link Allocation_Item#get_user_id}).
76
+ * @returns {string|number|undefined}
77
+ */
78
+ get_user_id()
79
+ {
80
+ return this.#record.id
81
+ }
82
+
83
+ /**
84
+ * @returns {string|undefined}
85
+ */
86
+ get_relational_group_id()
87
+ {
88
+ return this.#record.relational_group_id
89
+ }
90
+
91
+ get_amount()
92
+ {
93
+ return 0
94
+ }
95
+
96
+ get_current_rotation()
97
+ {
98
+ return this.#current_rotation
99
+ }
100
+
101
+ get_current_rotation_id()
102
+ {
103
+ return this.#rotation_id
104
+ }
105
+
106
+ get_json()
107
+ {
108
+ return { ...this.#record }
109
+ }
110
+
111
+ /**
112
+ * Preloaded items are immutable; returns a new instance with the same wire shape.
113
+ * @returns {Preloaded_Allocated_Item}
114
+ */
115
+ copy()
116
+ {
117
+ const wire = {
118
+ ...this.#record,
119
+ x: this.get_x(),
120
+ y: this.get_z(),
121
+ z: this.get_y(),
122
+ w: this.get_width(),
123
+ h: this.get_height(),
124
+ d: this.get_length(),
125
+ current_rotation: this.#current_rotation,
126
+ rotation: this.#rotation_id
127
+ }
128
+ return new Preloaded_Allocated_Item(wire)
129
+ }
130
+ }
131
+
132
+ module.exports = Preloaded_Allocated_Item
@@ -0,0 +1,67 @@
1
+ const assert = require('assert')
2
+ const {PositionedCube} = require('@jetta/empty-spaces-manager')
3
+ const round = require('../tools/Rounder')
4
+ const clone = require('../tools/Clone')
5
+ const {eq} = require('@jetta/number-compare')
6
+
7
+
8
+ module.exports = class Slot extends PositionedCube
9
+ {
10
+ #stackability_index = -1
11
+ #volume
12
+ constructor(x, y, z, width, height, length)
13
+ {
14
+ super({ x, y, z, width, height, length })
15
+ this.#volume = round(width * height * length)
16
+ }
17
+
18
+ get_stackability_index()
19
+ {
20
+ assert(this.#stackability_index >= 0,'stackability index has not been set.')
21
+ return this.#stackability_index
22
+ }
23
+
24
+ set_stackability_index(stackability_index)
25
+ {
26
+ assert(stackability_index >= 0,'stackability index must be bigger or equal zero.')
27
+ this.#stackability_index = stackability_index
28
+ }
29
+
30
+ get_volume()
31
+ {
32
+ return clone(this.#volume)
33
+ }
34
+
35
+ to_string()
36
+ {
37
+ return `${this.get_width()};${this.get_height()};${this.get_length()}`
38
+ }
39
+
40
+ get_hash()
41
+ {
42
+ return `${this.get_x()};${this.get_y()};${this.get_z()};${this.to_string()}`
43
+ }
44
+
45
+ rotated_item_fits_perfectly(item)
46
+ {
47
+
48
+ const fit_width = eq(item.get_width(), this.get_width())
49
+ const fit_height = eq(item.get_height(), this.get_height())
50
+ const fit_length = eq(item.get_length(), this.get_length())
51
+
52
+ return fit_width && fit_height && fit_length
53
+ }
54
+
55
+ some_rotation_fits_perfectly(item)
56
+ {
57
+ const rotations = item.get_rotations()
58
+ const compatible_rotations = rotations
59
+ .map(rotation =>
60
+ {
61
+ return this.rotated_item_fits_perfectly(item.get_rotated_item(rotation))
62
+ })
63
+ .filter( result => result )
64
+
65
+ return compatible_rotations.length > 0
66
+ }
67
+ }
@@ -0,0 +1,58 @@
1
+
2
+ const SAME_PACKAGE = 'EMBALAGENS_IGUAIS'
3
+ const SAME_AREA = 'AREAS_IGUAIS'
4
+ const ALLOWED_FAMILIES = 'ALLOWED_FAMILIES'
5
+ const ALLOWED_FAMILIES_WITH_SAME_AREA = 'ALLOWED_FAMILIES_WITH_SAME_AREA'
6
+ const NO_DEFINED_RULE = 'SEM_REGRA_DEFINIDA'
7
+ const stacking_rules = {
8
+ SAME_PACKAGE,
9
+ SAME_AREA,
10
+ ALLOWED_FAMILIES,
11
+ ALLOWED_FAMILIES_WITH_SAME_AREA,
12
+ NO_DEFINED_RULE
13
+ }
14
+
15
+
16
+ function read_restrictions(restrictions)
17
+ {
18
+ const same_area = restrictions['empilharAreaIgual'] || false
19
+ const same_package = restrictions['empilharItemIgual'] || false
20
+ const allowed_families = restrictions['empilharFamilias'] || false
21
+
22
+ if (same_package)
23
+ {
24
+ return SAME_PACKAGE
25
+ }
26
+ if (same_area && allowed_families)
27
+ {
28
+ return ALLOWED_FAMILIES_WITH_SAME_AREA
29
+ }
30
+ if (same_area)
31
+ {
32
+ return SAME_AREA
33
+ }
34
+ if (allowed_families)
35
+ {
36
+ return ALLOWED_FAMILIES
37
+ }
38
+ return NO_DEFINED_RULE
39
+ }
40
+
41
+ function read_stacking_rules(item_json)
42
+ {
43
+
44
+ const restrictions = item_json['restricoes']
45
+ if (restrictions != undefined && restrictions != '')
46
+ {
47
+ return read_restrictions(restrictions)
48
+ }
49
+
50
+ const constraint = item_json['constraint']
51
+ if (constraint !== undefined || constraint !== '')
52
+ {
53
+ return constraint || NO_DEFINED_RULE
54
+ }
55
+ return NO_DEFINED_RULE
56
+ }
57
+
58
+ module.exports = {stacking_rules, read_stacking_rules}
@@ -0,0 +1,9 @@
1
+ const {
2
+ build_effective_block_module_list,
3
+ } = require('../../validation/validate_block_module_config')
4
+
5
+ module.exports = function create_block_module_list(config)
6
+ {
7
+ const available_blocks = config.available_blocks
8
+ return build_effective_block_module_list(config, available_blocks)
9
+ }
@@ -0,0 +1,24 @@
1
+ class Translator extends Map
2
+ {
3
+ constructor()
4
+ {
5
+ super()
6
+ const w = ['largura', 'width', 'w']
7
+ const h = ['altura', 'height', 'h']
8
+ const l = ['comprimento', 'length', 'l', 'd']
9
+ const measure_list = [w, h, l]
10
+
11
+ for (const measures of measure_list)
12
+ {
13
+ measures.forEach(measure => this.set(measure, measures))
14
+ }
15
+ }
16
+
17
+ get_measure(measure)
18
+ {
19
+ const measures = this.get(measure)
20
+ return measures
21
+ }
22
+ }
23
+
24
+ module.exports = new Translator()
@@ -0,0 +1,44 @@
1
+ const { Rotations } = require('@jetta/empty-spaces-manager')
2
+ const translator = require('./Measure_Translator')
3
+
4
+ function read_measures(object, measure_list)
5
+ {
6
+ for (const original_measure of measure_list)
7
+ {
8
+ const translated_measures = translator.get_measure(original_measure)
9
+
10
+ for (const measure of translated_measures)
11
+ {
12
+ if (object[measure])
13
+ {
14
+ return object[measure]
15
+ }
16
+ }
17
+ }
18
+ throw new Error('not found field in json whilst allocating blocks')
19
+ }
20
+
21
+ function read_rotations(rotations, defaulty = ['pos1'])
22
+ {
23
+ if (rotations && Object.keys(rotations).length > 0)
24
+ {
25
+ return Object.keys(rotations).filter(rotation=>rotations[rotation])
26
+ }
27
+ return defaulty
28
+ }
29
+
30
+ function item_json_reader(json, rotation = Rotations.POS1)
31
+ {
32
+ const params = [
33
+ read_measures(json, ['largura', 'width']),
34
+ read_measures(json, ['altura', 'height']),
35
+ read_measures(json, ['comprimento', 'length']),
36
+ read_rotations(json.rotacao),
37
+ rotation
38
+ ]
39
+
40
+ return params
41
+ }
42
+
43
+
44
+ module.exports = item_json_reader
@@ -0,0 +1,71 @@
1
+ const { Rotations } = require('@jetta/empty-spaces-manager')
2
+
3
+ function read_possibilities(obj, fields, defaulty = NaN)
4
+ {
5
+ for (const field of fields)
6
+ {
7
+ if (obj[field])
8
+ {
9
+ return obj[field]
10
+ }
11
+ }
12
+ return defaulty
13
+ }
14
+
15
+ function read_rotations(rotations, defaulty = ['pos1'])
16
+ {
17
+ if (rotations && Object.keys(rotations).length > 0)
18
+ {
19
+ return Object.keys(rotations).filter(rotation => rotations[rotation])
20
+ }
21
+ return defaulty
22
+ }
23
+
24
+ function normalize_rotation_id(rotation)
25
+ {
26
+ const r = String(rotation).toLowerCase()
27
+ if (r.startsWith('position'))
28
+ {
29
+ return `pos${r.slice('position'.length)}`
30
+ }
31
+ return r
32
+ }
33
+
34
+ function read_rotations_from_json(json)
35
+ {
36
+ const defaulty = ['pos1']
37
+ if (json.rotacao !== undefined && json.rotacao !== null)
38
+ {
39
+ if (Array.isArray(json.rotacao))
40
+ {
41
+ return json.rotacao.length > 0
42
+ ? json.rotacao.map(normalize_rotation_id)
43
+ : defaulty
44
+ }
45
+ return read_rotations(json.rotacao, defaulty)
46
+ }
47
+ const list = json.rotation_list
48
+ if (Array.isArray(list) && list.length > 0)
49
+ {
50
+ return list.map(normalize_rotation_id)
51
+ }
52
+ return defaulty
53
+ }
54
+
55
+ /**
56
+ * Builds an {@link Item} constructor spec from loose JSON (Portuguese or English field names).
57
+ *
58
+ * @param {object} json - Raw item fields (`largura`/`width`, `rotacao` or `rotation_list`, etc.).
59
+ * @param {string} [rotation=Rotations.POS1] - `current_rotation` for the spec.
60
+ * @returns {{ width: number, height: number, length: number, rotations: string[], current_rotation: string }}
61
+ */
62
+ function item_json_reader(json, rotation = Rotations.POS1)
63
+ {
64
+ const width = read_possibilities(json, ['largura', 'width', 'w'])
65
+ const height = read_possibilities(json, ['altura', 'height', 'h'])
66
+ const length = read_possibilities(json, ['comprimento', 'length', 'd'])
67
+ const rotations = read_rotations_from_json(json)
68
+ return { width, height, length, rotations, current_rotation: rotation }
69
+ }
70
+
71
+ module.exports = item_json_reader
@@ -0,0 +1,70 @@
1
+ const SUPPORTED_WEIGTH_STACKING_STR = 'supportedWeight'
2
+
3
+ /**
4
+ * Builds a compact field bag for a previously placed item wire payload.
5
+ * @param {object} data - Raw placed item from container.items.
6
+ * @returns {object}
7
+ */
8
+ function build_placed_item_record(data)
9
+ {
10
+ return {
11
+ _id: data._id,
12
+ id: data.id,
13
+ tipo: data.tipo ?? data.type,
14
+ peso: data.peso ?? data.wg ?? data.weight,
15
+ wg: data.wg ?? data.peso ?? data.weight,
16
+ pesoMaxSuportado: data.pesoMaxSuportado ?? data.supported_weight,
17
+ supported_weight: data.supported_weight ?? data.pesoMaxSuportado,
18
+ empilhamentoMaximo: data.empilhamentoMaximo ?? data.stacking_limit,
19
+ stacking_limit: data.stacking_limit ?? data.empilhamentoMaximo,
20
+ restricoes: data.restricoes ?? data.restrictions ?? {},
21
+ restrictions: data.restrictions ?? data.restricoes ?? {},
22
+ stacking: data.stacking,
23
+ stackingUnit: data.stackingUnit,
24
+ groupId: data.groupId,
25
+ relational_group_id: data.relational_group_id,
26
+ rotaSequencia: data.rotaSequencia ?? 0,
27
+ priority: data.priority ?? data.prioridade ?? 0,
28
+ prioridade: data.prioridade ?? data.priority ?? 0,
29
+ is_previously_allocated: data.is_previously_allocated,
30
+ embalagem: data.embalagem,
31
+ cliente: data.cliente ?? data.waypoint_id ?? ''
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @param {object} data - Raw placed item payload.
37
+ * @returns {object}
38
+ */
39
+ function build_stacking_info(data)
40
+ {
41
+ return {
42
+ weight: data.peso ?? data.wg ?? data.weight,
43
+ supported_weight: data.pesoMaxSuportado ?? data.supported_weight,
44
+ max_stacking: data.empilhamentoMaximo ?? data.stacking_limit,
45
+ restrictions: data.restricoes ?? data.restrictions ?? {},
46
+ stacking_family: data.stacking?.family,
47
+ stack_by_supported_weight: data.stackingUnit === SUPPORTED_WEIGTH_STACKING_STR,
48
+ supported_families: data.stacking?.supported_families,
49
+ priority: data.prioridade ?? data.priority
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @param {object} data - Raw placed item payload.
55
+ * @returns {{ x: number, y: number, z: number }}
56
+ */
57
+ function read_placed_position(data)
58
+ {
59
+ return {
60
+ x: data.x ?? 0,
61
+ y: data.z ?? 0,
62
+ z: data.y ?? 0
63
+ }
64
+ }
65
+
66
+ module.exports = {
67
+ build_placed_item_record,
68
+ build_stacking_info,
69
+ read_placed_position
70
+ }
@@ -0,0 +1,38 @@
1
+ const { Rotations } = require('@jetta/empty-spaces-manager')
2
+
3
+ const ROTATION_ID_BY_NAME = {
4
+ [Rotations.POS1]: 0,
5
+ [Rotations.POS2]: 1,
6
+ [Rotations.POS3]: 2,
7
+ [Rotations.POS4]: 3,
8
+ [Rotations.POS5]: 4,
9
+ [Rotations.POS6]: 5
10
+ }
11
+
12
+ /**
13
+ * @param {object} wire - Placed item wire payload.
14
+ * @returns {string}
15
+ */
16
+ function read_current_rotation(wire)
17
+ {
18
+ return wire.current_rotation ?? Rotations.POS1
19
+ }
20
+
21
+ /**
22
+ * @param {object} wire - Placed item wire payload.
23
+ * @returns {number}
24
+ */
25
+ function read_rotation_id(wire)
26
+ {
27
+ if (wire.rotation !== undefined && wire.rotation !== null)
28
+ {
29
+ return wire.rotation
30
+ }
31
+ const rotation_name = read_current_rotation(wire)
32
+ return ROTATION_ID_BY_NAME[rotation_name] ?? 0
33
+ }
34
+
35
+ module.exports = {
36
+ read_current_rotation,
37
+ read_rotation_id
38
+ }
@@ -0,0 +1,45 @@
1
+ const { eq } = require('@jetta/number-compare')
2
+
3
+ /**
4
+ * Whether every slot shares the same height and the same footprint, allowing
5
+ * width and length to be swapped (in-plane rotation).
6
+ *
7
+ * @param {Array<object>} slot_list
8
+ * @returns {boolean}
9
+ */
10
+ function slots_have_same_measure(slot_list)
11
+ {
12
+ if (!Array.isArray(slot_list) || slot_list.length < 2)
13
+ {
14
+ return false
15
+ }
16
+ const first_slot = slot_list[0]
17
+ for (let slot_index = 1; slot_index < slot_list.length; slot_index += 1)
18
+ {
19
+ if (!slot_matches_reference_slot(first_slot, slot_list[slot_index]))
20
+ {
21
+ return false
22
+ }
23
+ }
24
+ return true
25
+ }
26
+
27
+ /**
28
+ * @param {object} reference_slot
29
+ * @param {object} slot
30
+ * @returns {boolean}
31
+ */
32
+ function slot_matches_reference_slot(reference_slot, slot)
33
+ {
34
+ if (!eq(reference_slot.get_height(), slot.get_height()))
35
+ {
36
+ return false
37
+ }
38
+ const same_orientation = eq(reference_slot.get_width(), slot.get_width())
39
+ && eq(reference_slot.get_length(), slot.get_length())
40
+ const rotated_orientation = eq(reference_slot.get_width(), slot.get_length())
41
+ && eq(reference_slot.get_length(), slot.get_width())
42
+ return same_orientation || rotated_orientation
43
+ }
44
+
45
+ module.exports = slots_have_same_measure