@jetta/blocks-allocator 0.0.0-stage → 0.1.0-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,155 @@
1
+ const chooser_empty_space_and_blocks = require('../space_and_block_chooser/Space_And_Blocks_Chooser')
2
+ const There_Is_No_Block_Options_To_Allocate_Exception = require('../exceptions/There_Is_No_Block_Options_To_Allocate_Exception')
3
+ const { apply_weight_ahead_lock_release } = require('../Allocation_Optimization/density_groups/Lock_Weight_Ahead_Release')
4
+ const { build_effective_item_fingerprint } = require('./effective_item_fingerprint')
5
+ const { apply_density_group_item_filter } = require('./density_group_item_filter')
6
+ const { should_skip_compound_probe_after_failure } = require('./compound_probe_fallback')
7
+ const {
8
+ apply_item_continuation_lock_gate,
9
+ update_item_continuation_lock
10
+ } = require('./item_continuation_lock_gate')
11
+ const { empty_space_stacks_on_tie_ratio_supporter } = require('../Allocation_Optimization/tie_ratio/tie_ratio_orientation_below_empty_space')
12
+
13
+ /**
14
+ * Runs one allocation iteration: chooser, LP attempt, skip-state update.
15
+ * @param {object} context
16
+ * @param {object} container
17
+ * @param {object|null} locked_item
18
+ * @returns {Promise<boolean>} False when no effective items remain.
19
+ */
20
+ async function run_allocation_iteration(context, container, locked_item)
21
+ {
22
+ locked_item = apply_item_continuation_lock_gate(context, locked_item)
23
+ context.density_scheduler?.prepare_for_iteration(container, context.item_list, locked_item)
24
+ locked_item = apply_weight_ahead_lock_release(
25
+ container,
26
+ context.density_scheduler,
27
+ context.item_lock,
28
+ context.item_list,
29
+ locked_item
30
+ )
31
+ let effective_item_list = context.item_lock.get_effective_item_list(context.item_list, locked_item)
32
+ effective_item_list = apply_density_group_item_filter(
33
+ context.density_scheduler,
34
+ context.item_list,
35
+ effective_item_list,
36
+ locked_item
37
+ )
38
+ if (effective_item_list.length === 0)
39
+ {
40
+ return false
41
+ }
42
+
43
+ const fingerprint = build_effective_item_fingerprint(effective_item_list)
44
+ const spaces_to_avoid = context.space_skip_state.begin_iteration(fingerprint)
45
+ const amounts_before = context.space_skip_state.snapshot_effective_amounts(effective_item_list)
46
+
47
+ const { empty_space, block_list, no_fillable_space_set }
48
+ = await chooser_empty_space_and_blocks(
49
+ container,
50
+ context.block_list,
51
+ effective_item_list,
52
+ spaces_to_avoid,
53
+ context.chooser_session
54
+ )
55
+
56
+ context.preferential_block_identifier.mark_preferential_blocks(block_list)
57
+
58
+ const wall_output = await context.allocation_attempt.try_to_allocate(
59
+ block_list,
60
+ empty_space,
61
+ {},
62
+ container,
63
+ effective_item_list,
64
+ context.picking_continuity.get_seed_item_id()
65
+ )
66
+ update_compound_probe_session(context, block_list, effective_item_list, amounts_before)
67
+ const progressed = update_skip_state_after_attempt(
68
+ context,
69
+ effective_item_list,
70
+ amounts_before,
71
+ empty_space,
72
+ fingerprint
73
+ )
74
+ update_item_continuation_lock(context, wall_output.single_slot_allocated_item_ids)
75
+ context.picking_continuity.update_from_wall(wall_output.last_allocated_item_id)
76
+ if (wall_output.placed_tie_ratio_block)
77
+ {
78
+ const stacks_on_tie_ratio = empty_space_stacks_on_tie_ratio_supporter({
79
+ container,
80
+ empty_space
81
+ })
82
+ if (!stacks_on_tie_ratio)
83
+ {
84
+ context.chooser_session.tie_ratio_intercalation_state.advance_after_tie_ratio_wall()
85
+ }
86
+ }
87
+ if (progressed)
88
+ {
89
+ context.density_scheduler?.on_successful_wall()
90
+ }
91
+ context.space_skip_state.merge_no_fillable(no_fillable_space_set)
92
+ assert_blocks_available(block_list)
93
+ return true
94
+ }
95
+
96
+ /**
97
+ * @param {object} context
98
+ * @param {object[]} block_list
99
+ * @param {object[]} effective_item_list
100
+ * @param {Record<string, number>} amounts_before
101
+ * @returns {void}
102
+ */
103
+ function update_compound_probe_session(context, block_list, effective_item_list, amounts_before)
104
+ {
105
+ const session = context.chooser_session.obligate_compound_session
106
+ const progressed = effective_item_list.some(
107
+ item => item.get_amount() < amounts_before[item.get_id()]
108
+ )
109
+ if (progressed)
110
+ {
111
+ session.skip_compound_probe = false
112
+ return
113
+ }
114
+ if (should_skip_compound_probe_after_failure(block_list))
115
+ {
116
+ session.skip_compound_probe = true
117
+ }
118
+ }
119
+
120
+ /**
121
+ * @param {object} context
122
+ * @param {object[]} effective_item_list
123
+ * @param {Record<string, number>} amounts_before
124
+ * @param {object} empty_space
125
+ * @param {string} fingerprint
126
+ * @returns {boolean} True when any effective item amount decreased.
127
+ */
128
+ function update_skip_state_after_attempt(context, effective_item_list, amounts_before, empty_space, fingerprint)
129
+ {
130
+ const progressed = effective_item_list.some(
131
+ item => item.get_amount() < amounts_before[item.get_id()]
132
+ )
133
+ if (progressed)
134
+ {
135
+ context.space_skip_state.clear_stalls()
136
+ context.recovery_state.count = 0
137
+ return true
138
+ }
139
+ context.space_skip_state.record_stall(empty_space, fingerprint)
140
+ return false
141
+ }
142
+
143
+ /**
144
+ * @param {object[]} block_list
145
+ * @returns {void}
146
+ */
147
+ function assert_blocks_available(block_list)
148
+ {
149
+ if (block_list.length === 0)
150
+ {
151
+ throw new There_Is_No_Block_Options_To_Allocate_Exception()
152
+ }
153
+ }
154
+
155
+ module.exports = { run_allocation_iteration }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Tracks permanent and fingerprint-scoped space skips for the allocation chooser.
3
+ */
4
+ class Space_Skip_State
5
+ {
6
+ #permanent_no_fillable = new Set()
7
+ #stalls_by_fingerprint = new Map()
8
+ #iteration_view = new Set()
9
+
10
+ /**
11
+ * Rebuilds the iteration skip view from permanent skips and stalls for the fingerprint.
12
+ * @param {string} fingerprint - Effective item fingerprint for the current iteration.
13
+ * @returns {Set<object>} Mutable set passed to the space chooser.
14
+ */
15
+ begin_iteration(fingerprint)
16
+ {
17
+ this.#iteration_view.clear()
18
+ this.#permanent_no_fillable.forEach(space => this.#iteration_view.add(space))
19
+ const stalled_spaces = this.#stalls_by_fingerprint.get(fingerprint)
20
+ if (stalled_spaces)
21
+ {
22
+ stalled_spaces.forEach(space => this.#iteration_view.add(space))
23
+ }
24
+ return this.#iteration_view
25
+ }
26
+
27
+ /**
28
+ * Persists spaces where filters eliminated all blocks.
29
+ * @param {Iterable<object>} spaces - Spaces reported by the chooser as permanently unfillable.
30
+ * @returns {void}
31
+ */
32
+ merge_no_fillable(spaces)
33
+ {
34
+ for (const space of spaces)
35
+ {
36
+ this.#permanent_no_fillable.add(space)
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Records a transient stall for a space under the current fingerprint.
42
+ * @param {object} space - Empty space that made no allocation progress.
43
+ * @param {string} fingerprint - Effective item fingerprint for the failed attempt.
44
+ * @returns {void}
45
+ */
46
+ record_stall(space, fingerprint)
47
+ {
48
+ let stalled_spaces = this.#stalls_by_fingerprint.get(fingerprint)
49
+ if (!stalled_spaces)
50
+ {
51
+ stalled_spaces = new Set()
52
+ this.#stalls_by_fingerprint.set(fingerprint, stalled_spaces)
53
+ }
54
+ stalled_spaces.add(space)
55
+ }
56
+
57
+ /**
58
+ * Clears all fingerprint-scoped stalls after a successful allocation.
59
+ * @returns {void}
60
+ */
61
+ clear_stalls()
62
+ {
63
+ this.#stalls_by_fingerprint.clear()
64
+ }
65
+
66
+ /**
67
+ * Clears permanently skipped spaces so chooser can retry them after NoSpaceLeft recovery.
68
+ * @returns {void}
69
+ */
70
+ clear_permanent_no_fillable()
71
+ {
72
+ this.#permanent_no_fillable.clear()
73
+ }
74
+
75
+ /**
76
+ * Snapshots effective item amounts before an allocation attempt.
77
+ * @param {object[]} effective_item_list - Items exposed to the current iteration.
78
+ * @returns {Record<string, number>} Map of item id to amount.
79
+ */
80
+ snapshot_effective_amounts(effective_item_list)
81
+ {
82
+ const amounts = {}
83
+ for (const item of effective_item_list)
84
+ {
85
+ amounts[item.get_id()] = item.get_amount()
86
+ }
87
+ return amounts
88
+ }
89
+ }
90
+
91
+ module.exports = Space_Skip_State
@@ -0,0 +1,50 @@
1
+ const {NoSpaceLeftException} = require('@jetta/empty-spaces-manager')
2
+ const { remaining_items_fit_container } = require('./container_remaining_capacity')
3
+ const {
4
+ apply_no_space_left_recovery,
5
+ compute_max_no_space_left_recoveries,
6
+ is_compound_fallback_engaged
7
+ } = require('./no_space_left_recovery')
8
+
9
+ /**
10
+ * @param {object} params
11
+ * @param {Error} params.error
12
+ * @param {object} params.container
13
+ * @param {object|null} params.locked_item
14
+ * @param {object[]} params.item_list
15
+ * @param {object} params.space_skip_state
16
+ * @param {object} params.chooser_session
17
+ * @param {object|null} params.density_scheduler
18
+ * @param {{ count: number }} params.recovery_state
19
+ * @returns {{ recovered: boolean, item_list: object[] }}
20
+ */
21
+ function try_no_space_left_recovery(params)
22
+ {
23
+ if (!(params.error instanceof NoSpaceLeftException))
24
+ {
25
+ return { recovered: false, item_list: params.item_list }
26
+ }
27
+ const capacity = remaining_items_fit_container(params.item_list, params.container)
28
+ if (!capacity.has_capacity)
29
+ {
30
+ return { recovered: false, item_list: capacity.item_list }
31
+ }
32
+ const max_recoveries = compute_max_no_space_left_recoveries(
33
+ params.density_scheduler?.get_group_count(),
34
+ is_compound_fallback_engaged(params.chooser_session)
35
+ )
36
+ if (params.recovery_state.count >= max_recoveries)
37
+ {
38
+ return { recovered: false, item_list: capacity.item_list }
39
+ }
40
+ params.recovery_state.count += 1
41
+ apply_no_space_left_recovery({
42
+ space_skip_state: params.space_skip_state,
43
+ chooser_session: params.chooser_session,
44
+ density_scheduler: params.density_scheduler,
45
+ locked_item: params.locked_item
46
+ })
47
+ return { recovered: true, item_list: capacity.item_list }
48
+ }
49
+
50
+ module.exports = { try_no_space_left_recovery }
@@ -0,0 +1,17 @@
1
+ const { build_message_entry } = require('../messages/resolve_error_message_entry')
2
+ const { ALLOCATOR_MESSAGE } = require('../messages/Allocator_Message')
3
+
4
+ class Invalid_Parameter_Exception extends Error
5
+ {
6
+ /**
7
+ * @param {string} [detail='']
8
+ */
9
+ constructor(detail = '')
10
+ {
11
+ const message_key = ALLOCATOR_MESSAGE.INVALID_PARAMETER
12
+ super(message_key)
13
+ this.message_entry = build_message_entry(message_key, [String(detail)])
14
+ }
15
+ }
16
+
17
+ module.exports = Invalid_Parameter_Exception
@@ -0,0 +1,24 @@
1
+ const RELATION_ERROR_CODES = require('../relational/Relational_Error_Codes')
2
+ const { build_message_entry } = require('../messages/resolve_error_message_entry')
3
+ const { ALLOCATOR_MESSAGE } = require('../messages/Allocator_Message')
4
+
5
+ class Relational_Allocation_Incomplete_Exception extends Error
6
+ {
7
+ /**
8
+ * @param {object} [details={}]
9
+ */
10
+ constructor(details = {})
11
+ {
12
+ const group_id = String(details.relational_group_id ?? '')
13
+ const message_key = ALLOCATOR_MESSAGE.RELATION_ALLOCATION_INCOMPLETE
14
+ super(message_key)
15
+ this.name = 'Relational_Allocation_Incomplete_Exception'
16
+ this.message_entry = build_message_entry(message_key, [group_id])
17
+ this.code = RELATION_ERROR_CODES.ALLOCATION_INCOMPLETE
18
+ this.relational_group_id = details.relational_group_id
19
+ this.allocated_counts = details.allocated_counts
20
+ this.expected_counts = details.expected_counts
21
+ }
22
+ }
23
+
24
+ module.exports = Relational_Allocation_Incomplete_Exception
@@ -0,0 +1,23 @@
1
+ const RELATION_ERROR_CODES = require('../relational/Relational_Error_Codes')
2
+ const { build_message_entry } = require('../messages/resolve_error_message_entry')
3
+ const { ALLOCATOR_MESSAGE } = require('../messages/Allocator_Message')
4
+
5
+ class Relational_Colocation_Violation_Exception extends Error
6
+ {
7
+ /**
8
+ * @param {object} [details={}]
9
+ */
10
+ constructor(details = {})
11
+ {
12
+ const group_id = String(details.relational_group_id ?? '')
13
+ const message_key = ALLOCATOR_MESSAGE.RELATION_COLOCATION_VIOLATION
14
+ super(message_key)
15
+ this.name = 'Relational_Colocation_Violation_Exception'
16
+ this.message_entry = build_message_entry(message_key, [group_id])
17
+ this.code = RELATION_ERROR_CODES.COLOCATION_VIOLATION
18
+ this.relational_group_id = details.relational_group_id
19
+ this.container_sequences = details.container_sequences
20
+ }
21
+ }
22
+
23
+ module.exports = Relational_Colocation_Violation_Exception
@@ -0,0 +1,17 @@
1
+ const RELATION_ERROR_CODES = require('../relational/Relational_Error_Codes')
2
+ const { build_message_entry } = require('../messages/resolve_error_message_entry')
3
+ const { ALLOCATOR_MESSAGE } = require('../messages/Allocator_Message')
4
+
5
+ class Relational_Config_Mismatch_Exception extends Error
6
+ {
7
+ constructor()
8
+ {
9
+ const message_key = ALLOCATOR_MESSAGE.RELATION_CONFIG_MISMATCH
10
+ super(message_key)
11
+ this.name = 'Relational_Config_Mismatch_Exception'
12
+ this.message_entry = build_message_entry(message_key)
13
+ this.code = RELATION_ERROR_CODES.CONFIG_MISMATCH
14
+ }
15
+ }
16
+
17
+ module.exports = Relational_Config_Mismatch_Exception
@@ -0,0 +1,14 @@
1
+ const { build_message_entry } = require('../messages/resolve_error_message_entry')
2
+ const { ALLOCATOR_MESSAGE } = require('../messages/Allocator_Message')
3
+
4
+ class There_Is_No_Block_Options_To_Allocate_Exception extends Error
5
+ {
6
+ constructor()
7
+ {
8
+ const message_key = ALLOCATOR_MESSAGE.NO_BLOCK_OPTIONS
9
+ super(message_key)
10
+ this.message_entry = build_message_entry(message_key)
11
+ }
12
+ }
13
+
14
+ module.exports = There_Is_No_Block_Options_To_Allocate_Exception
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ const run_core_allocation = require('./run_core_allocation')
2
+ const { resolve_trace_id } = require('./tracing/Allocation_Tracer')
3
+
4
+ run_core_allocation.resolve_trace_id = resolve_trace_id
5
+
6
+ module.exports = run_core_allocation
@@ -0,0 +1,179 @@
1
+ const { Block } = require('../models/Block')
2
+ const Slot = require('../models/Slot')
3
+ const {
4
+ align_flush_stacked_slots_stable,
5
+ are_slot_lists_xyz_equal
6
+ } = require('./block_formatter/align_flush_stacked_slots')
7
+ const { run_shell_snap_convergence } = require('./block_formatter/shell_snap_convergence')
8
+ const {
9
+ has_parallelepiped_shell: shell_is_closed,
10
+ are_all_slots_inside_bounds: slots_are_inside_bounds
11
+ } = require('./block_formatter/parallelepiped_shell')
12
+ const { slot_list_has_overlapped_slots } = require('./block_formatter/overlapped_slots')
13
+ const Cargo_Profile = require('../models/Cargo_Profile')
14
+
15
+ const TOUCH_TOLERANCE = 0.005
16
+ const ALIGN_FLUSH_MAX_ROUNDS = 3
17
+ const SHELL_SNAP_CONVERGENCE_MAX = 8
18
+
19
+ module.exports = function format_block_list(block_list)
20
+ {
21
+ if (!Cargo_Profile.enable_block_formatter())
22
+ {
23
+ return block_list
24
+ }
25
+ const formatted_block_list = []
26
+ for (const block of block_list)
27
+ {
28
+ formatted_block_list.push(format_block(block))
29
+ }
30
+ return formatted_block_list
31
+ }
32
+
33
+ function format_block(block)
34
+ {
35
+ const slot_list = block.get_slot_list()
36
+ if (!is_eligible_block(slot_list))
37
+ {
38
+ return block
39
+ }
40
+ const convergence = run_shell_snap_convergence({
41
+ slot_list,
42
+ max_iterations: SHELL_SNAP_CONVERGENCE_MAX,
43
+ touch_tolerance: TOUCH_TOLERANCE,
44
+ align_flush_max_rounds: ALIGN_FLUSH_MAX_ROUNDS,
45
+ get_bounds,
46
+ anchor_slots_to_bounds,
47
+ align_flush_stacked_slots_stable,
48
+ normalize_slot_list,
49
+ are_all_slots_inside_bounds: (s, b) => slots_are_inside_bounds(s, b, TOUCH_TOLERANCE),
50
+ has_parallelepiped_shell: (s, b) => shell_is_closed(s, b, TOUCH_TOLERANCE),
51
+ are_slot_lists_xyz_equal
52
+ })
53
+ const normalized_slot_list = convergence.normalized_slot_list
54
+ const normalized_bounds = convergence.normalized_bounds
55
+ const slot_list_inside_bounds = slots_are_inside_bounds(normalized_slot_list, normalized_bounds, TOUCH_TOLERANCE)
56
+ const shell_ok = shell_is_closed(normalized_slot_list, normalized_bounds, TOUCH_TOLERANCE)
57
+ const geometry_changed = convergence.anchor_align_changed
58
+ if (!slot_list_inside_bounds || (!shell_ok && !geometry_changed))
59
+ {
60
+ return block
61
+ }
62
+ if (slot_list_has_overlapped_slots(normalized_slot_list))
63
+ {
64
+ return block
65
+ }
66
+ const block_data = block.get_json()
67
+ return new Block({
68
+ ...block_data,
69
+ width: normalized_bounds.max_x - normalized_bounds.min_x,
70
+ height: normalized_bounds.max_y - normalized_bounds.min_y,
71
+ length: normalized_bounds.max_z - normalized_bounds.min_z
72
+ }, normalized_slot_list)
73
+ }
74
+
75
+ function is_eligible_block(slot_list)
76
+ {
77
+ return slot_list.length > 2 || has_same_slot_measures(slot_list)
78
+ }
79
+
80
+ function has_same_slot_measures(slot_list)
81
+ {
82
+ if (slot_list.length === 0)
83
+ {
84
+ return false
85
+ }
86
+ const first_slot = slot_list[0]
87
+ const reference = `${first_slot.get_width()};${first_slot.get_height()};${first_slot.get_length()}`
88
+ for (const slot of slot_list)
89
+ {
90
+ const current = `${slot.get_width()};${slot.get_height()};${slot.get_length()}`
91
+ if (current !== reference)
92
+ {
93
+ return false
94
+ }
95
+ }
96
+ return true
97
+ }
98
+
99
+ function get_bounds(slot_list)
100
+ {
101
+ const first_slot = slot_list[0]
102
+ const first_end = first_slot.get_end_point()
103
+ const bounds = { min_x: first_slot.get_x(), min_y: first_slot.get_y(), min_z: first_slot.get_z(), max_x: first_end.x, max_y: first_end.y, max_z: first_end.z }
104
+ for (const slot of slot_list)
105
+ {
106
+ const slot_end = slot.get_end_point()
107
+ bounds.min_x = Math.min(bounds.min_x, slot.get_x())
108
+ bounds.min_y = Math.min(bounds.min_y, slot.get_y())
109
+ bounds.min_z = Math.min(bounds.min_z, slot.get_z())
110
+ bounds.max_x = Math.max(bounds.max_x, slot_end.x)
111
+ bounds.max_y = Math.max(bounds.max_y, slot_end.y)
112
+ bounds.max_z = Math.max(bounds.max_z, slot_end.z)
113
+ }
114
+ return bounds
115
+ }
116
+
117
+ function anchor_slots_to_bounds(slot_list, bounds)
118
+ {
119
+ const anchored_slot_list = []
120
+ for (const slot of slot_list)
121
+ {
122
+ const anchored_x = calculate_anchored_axis(slot.get_x(), slot.get_width(), bounds.min_x, bounds.max_x)
123
+ const anchored_y = calculate_anchored_axis(slot.get_y(), slot.get_height(), bounds.min_y, bounds.max_y)
124
+ const anchored_z = calculate_anchored_axis(slot.get_z(), slot.get_length(), bounds.min_z, bounds.max_z)
125
+ anchored_slot_list.push(
126
+ new Slot(
127
+ anchored_x,
128
+ anchored_y,
129
+ anchored_z,
130
+ slot.get_width(),
131
+ slot.get_height(),
132
+ slot.get_length()
133
+ )
134
+ )
135
+ }
136
+ return anchored_slot_list
137
+ }
138
+
139
+ function calculate_anchored_axis(start, size, min, max)
140
+ {
141
+ const end = start + size
142
+ const is_anchor_min_candidate = Math.abs(start - min) <= TOUCH_TOLERANCE
143
+ const is_anchor_max_candidate = Math.abs(end - max) <= TOUCH_TOLERANCE
144
+ if (is_anchor_min_candidate && is_anchor_max_candidate)
145
+ {
146
+ return min
147
+ }
148
+ if (is_anchor_min_candidate)
149
+ {
150
+ return min
151
+ }
152
+ if (is_anchor_max_candidate)
153
+ {
154
+ return clamp_to_bounds(max - size, size, min, max)
155
+ }
156
+ return clamp_to_bounds(start, size, min, max)
157
+ }
158
+
159
+ function clamp_to_bounds(start, size, min, max)
160
+ {
161
+ const max_start = max - size
162
+ if (max_start < min)
163
+ {
164
+ return min
165
+ }
166
+ return Math.min(Math.max(start, min), max_start)
167
+ }
168
+
169
+ function normalize_slot_list(slot_list, bounds)
170
+ {
171
+ return slot_list.map(slot => new Slot(
172
+ slot.get_x() - bounds.min_x,
173
+ slot.get_y() - bounds.min_y,
174
+ slot.get_z() - bounds.min_z,
175
+ slot.get_width(),
176
+ slot.get_height(),
177
+ slot.get_length()
178
+ ))
179
+ }
@@ -0,0 +1,76 @@
1
+ const Config = require('../models/Cargo_Profile')
2
+
3
+ module.exports = function create_blocksmith_input(transport, item_list)
4
+ {
5
+ const item_data_list = create_input_item_list(item_list)
6
+
7
+ return {
8
+ container: create_container_data(transport),
9
+ config: Config.get_cargo_profile_as_js_object(),
10
+ item_list: item_data_list
11
+ }
12
+
13
+ }
14
+
15
+ function create_container_data(transport)
16
+ {
17
+ const tallest_container = transport.containers.reduce((acc, cur) => cur.altura > acc.altura ? acc = cur : cur = cur, '')
18
+ return {
19
+ width: tallest_container.largura,
20
+ height: tallest_container.altura,
21
+ length: tallest_container.comprimento,
22
+ }
23
+ }
24
+
25
+
26
+ function create_input_item_list(item_list)
27
+ {
28
+ return item_list.map(item => create_input_item_data(item))
29
+ }
30
+
31
+ function create_input_item_data(item)
32
+ {
33
+ return {
34
+ 'id': item.get_json()._id,
35
+ 'length': item.get_json().length || item.get_json().comprimento,
36
+ 'width': item.get_json().width || item.get_json().largura,
37
+ 'height': item.get_json().height || item.get_json().altura,
38
+ 'weight': item.get_json().weight || item.get_json().peso,
39
+ 'supported_weight': item.get_json().supported_weight || item.get_json().pesoMaxSuportado,
40
+ 'maximum_stacking': item.get_json().maximum_stacking || item.get_json().empilhamentoMaximo,
41
+ 'stacking_rule': get_stacking_unit(item.get_json().stackingUnit),
42
+ 'amount': item.get_json().amount || item.get_json().qtd,
43
+ 'type': item.get_json().type || item.get_json().tipo,
44
+ 'priority': item.get_json().priority || item.get_json().prioridade,
45
+ 'rotation_list': rotation_list(item.get_json().rotacao !== undefined ? item.get_json().rotacao : item.get_json().rotation_list)
46
+ }
47
+ }
48
+
49
+ function get_stacking_unit(value)
50
+ {
51
+ if (value.toLowerCase() === 'supportedweight')
52
+ {
53
+ return 'SUPPORTED_WEIGHT'
54
+ }
55
+ if (value.toLowerCase() === 'maximumStacking')
56
+ {
57
+ return 'MAXIMUM_STACKING'
58
+ }
59
+ return 'BOTH'
60
+ }
61
+
62
+ function rotation_list(rotation_map)
63
+ {
64
+ const rotation_list = []
65
+
66
+ for (const key in rotation_map)
67
+ {
68
+ if (rotation_map[key])
69
+ {
70
+ const rotation = key.replace('pos', 'position')
71
+ rotation_list.push(rotation)
72
+ }
73
+ }
74
+
75
+ return rotation_list
76
+ }