@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.
- package/README.md +103 -2
- package/package.json +67 -5
- package/src/Allocation_Attempt.js +135 -0
- package/src/Allocation_Error_Handler.js +69 -0
- package/src/Allocation_Flow.js +162 -0
- package/src/Allocation_Optimization/Allocation_LP.js +150 -0
- package/src/Allocation_Optimization/Block_Allocator.js +129 -0
- package/src/Allocation_Optimization/Block_Layer_Order.js +50 -0
- package/src/Allocation_Optimization/Block_Potential_Weight.js +54 -0
- package/src/Allocation_Optimization/Chosen_Blocks_Stock_Cap.js +82 -0
- package/src/Allocation_Optimization/block_builder/Allocation_Item_Creator.js +37 -0
- package/src/Allocation_Optimization/block_builder/Block_Item_List_Validator.js +18 -0
- package/src/Allocation_Optimization/block_builder/Block_Wall_Builder.js +303 -0
- package/src/Allocation_Optimization/block_builder/Blocks_Builder.js +40 -0
- package/src/Allocation_Optimization/block_builder/Next_Block_Position.js +33 -0
- package/src/Allocation_Optimization/block_builder/Slot_Item_Assigner.js +45 -0
- package/src/Allocation_Optimization/block_builder/Stacking_Validation.js +30 -0
- package/src/Allocation_Optimization/block_builder/assert_tie_ratio_block_matches_orientation_below.js +44 -0
- package/src/Allocation_Optimization/block_builder/block_shape_stock.js +129 -0
- package/src/Allocation_Optimization/block_builder/exceptions/Empty_Block_Item_List_Exception.js +21 -0
- package/src/Allocation_Optimization/block_builder/exceptions/Invalid_Stacking_Exception.js +14 -0
- package/src/Allocation_Optimization/block_builder/exceptions/No_Suitable_Item_Exception.js +16 -0
- package/src/Allocation_Optimization/block_builder/exceptions/Restricted_Block_Exception.js +21 -0
- package/src/Allocation_Optimization/block_builder/should_omit_block_group_id.js +29 -0
- package/src/Allocation_Optimization/block_builder/snap_elevated_block_wall_items.js +34 -0
- package/src/Allocation_Optimization/block_builder/stacking_rules_input.js +52 -0
- package/src/Allocation_Optimization/cap_chosen_blocks_by_shape_stock.js +110 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Preparer.js +21 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Selector.js +55 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Threshold_Resolver.js +28 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Thresholds.js +23 -0
- package/src/Allocation_Optimization/density_groups/Container_Utilization.js +67 -0
- package/src/Allocation_Optimization/density_groups/Density_Group_Partitioner.js +74 -0
- package/src/Allocation_Optimization/density_groups/Density_Group_Scheduler.js +168 -0
- package/src/Allocation_Optimization/density_groups/Density_Group_Stock.js +49 -0
- package/src/Allocation_Optimization/density_groups/Density_Groups_Strategy.js +26 -0
- package/src/Allocation_Optimization/density_groups/Item_Density_Calculator.js +20 -0
- package/src/Allocation_Optimization/density_groups/Lock_Weight_Ahead_Release.js +75 -0
- package/src/Allocation_Optimization/exceptions/Invalid_Item_Amount_Exception.js +17 -0
- package/src/Allocation_Optimization/exceptions/No_Valid_Allocation_Exception.js +14 -0
- package/src/Allocation_Optimization/exceptions/Optimization_Infeasible_Exception.js +14 -0
- package/src/Allocation_Optimization/functions/Measure_Reader.js +20 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Cobination_Mode.js +25 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Cobination_Strategies.js +8 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Combination_Mode_Checkers.js +70 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Translation.js +22 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Variable_Weight_Getter.js +85 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/constants.js +16 -0
- package/src/Allocation_Optimization/functions/measure_to_optimize.js +6 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Capacity_Bias_Item_Order.js +76 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Choose_Item_Heuristic_Context.js +63 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Item_Chooser.js +159 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Item_For_Slot_Chooser.js +49 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Slot_Compatible_Items_Finder.js +88 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Slots_Items_Assigner.js +182 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Stack_Slot_Calculator.js +87 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Weight_Slot_Distribution.js +72 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/Empty_Slot_Exception.js +17 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/Item_Taller_Than_Limit_Exception.js +21 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/No_Available_Items_Exception.js +14 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/No_Slots_For_Items_Exception.js +14 -0
- package/src/Allocation_Optimization/lp_model/Block_Weight_Calculator.js +31 -0
- package/src/Allocation_Optimization/lp_model/LP_Data_Processor.js +42 -0
- package/src/Allocation_Optimization/lp_model/LP_Item_Slot_Assignment.js +93 -0
- package/src/Allocation_Optimization/lp_model/LP_Result_Mapper.js +47 -0
- package/src/Allocation_Optimization/lp_model/model_builder/Dimension_Range_Helper.js +49 -0
- package/src/Allocation_Optimization/lp_model/model_builder/Item_Assignment_Variables.js +133 -0
- package/src/Allocation_Optimization/lp_model/model_builder/LP_Model_Builder.js +132 -0
- package/src/Allocation_Optimization/lp_model/model_builder/exceptions/Missing_Item_Stock_Exception.js +18 -0
- package/src/Allocation_Optimization/lp_model/model_builder/goal_function/Goal_Function_Creator.js +83 -0
- package/src/Allocation_Optimization/lp_model/model_builder/item_dimension_hashes.js +31 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Block_Item_Amount_Restriction.js +53 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Coherence_Restriction.js +65 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Container_Supported_Weight_Restriction.js +42 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Relational_Exact_Pass_Amount_Restriction.js +62 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Relational_Group_Restriction.js +97 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Single_Item_Type_Restriction.js +79 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Space_Restriction.js +47 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Unavailable_Block_Restriction.js +27 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Uniform_Block_Measure_Restriction.js +92 -0
- package/src/Allocation_Optimization/next_group_id_after_preloaded.js +30 -0
- package/src/Allocation_Optimization/preferential_blocks/Preferential_Block_Identifier.js +74 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/Key_Item_Mapper.js +49 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Almost_Unique_Item.js +31 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Cant_Stack_It_Self.js +68 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Rule_Interface.js +26 -0
- package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Intercalation_State.js +49 -0
- package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Orientation_Filter.js +33 -0
- package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Vertical_Stack_Filter.js +20 -0
- package/src/Allocation_Optimization/tie_ratio/collect_tie_ratio_orientations_below_footprint.js +64 -0
- package/src/Allocation_Optimization/tie_ratio/filter_blocks_by_orientation.js +17 -0
- package/src/Allocation_Optimization/tie_ratio/find_orientation_below_space.js +77 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/allocated_item_penetrates_any.js +31 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/apply_loose_placement_to_allocated_item.js +94 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/axis_overlap_length.js +16 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/block_local_origin.js +18 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/box_fits_inside_container.js +39 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_allocated_item_at_placement.js +18 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_placement_on_generic_supporter.js +64 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_slot_grid_from_cluster.js +66 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/compare_group_ids.js +20 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/container_with_pending_wall_items.js +26 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/empty_space_is_on_floor.js +16 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/finalize_loose_item_placement.js +58 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_best_generic_supporter_placement.js +58 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_next_free_slot_index.js +119 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_supporter_directly_below.js +51 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_tie_ratio_supporter_cluster.js +57 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/footprint_xz_overlap_area.js +26 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/item_fits_supporter_slot.js +22 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_footprint_region_from_options.js +24 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_item_fits_inside_container.js +21 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_item_has_geometric_support.js +21 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_on_block_slot_state.js +88 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/placement_coords_fit_inside_container.js +34 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/read_empilhar_area_igual_from_allocation_item.js +12 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/realigned_loose_geometry_gates.js +25 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_loose_on_generic_supporter.js +65 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_loose_placement_position.js +68 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_placement_y_at_slot.js +45 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_without_tie_ratio_cluster.js +79 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/select_tie_ratio_slot_placement.js +84 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/slot_footprint_collision.js +105 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_cluster_selection.js +119 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_footprint_overlap.js +56 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_placement_plane.js +109 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_supporter_predicate.js +23 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/try_tie_ratio_slot_placement.js +62 -0
- package/src/Allocation_Optimization/tie_ratio/snap_stacked_items_to_floor_footprints.js +138 -0
- package/src/Allocation_Optimization/tie_ratio/supporters_by_top_y_index.js +78 -0
- package/src/Allocation_Optimization/tie_ratio/tie_ratio_orientation_below_empty_space.js +89 -0
- package/src/Allocation_Optimization/tie_ratio/tie_ratio_orientation_from_group.js +48 -0
- package/src/Block_Management.js +34 -0
- package/src/Blocks_Preparation/Cube_Map_Function.js +27 -0
- package/src/Blocks_Wall_Allocation.js +3 -0
- package/src/IO/Answer_Status.js +4 -0
- package/src/IO/Output_Builder.js +35 -0
- package/src/IO/count_allocated_items.js +31 -0
- package/src/IO/create_error_response.js +62 -0
- package/src/IO/format_allocation_error_message.js +25 -0
- package/src/Item_Continuation_Lock.js +129 -0
- package/src/Item_Picking_Continuity.js +41 -0
- package/src/allocation_flow/chooser_session_state.js +21 -0
- package/src/allocation_flow/compound_probe_fallback.js +17 -0
- package/src/allocation_flow/container_remaining_capacity.js +23 -0
- package/src/allocation_flow/density_group_item_filter.js +31 -0
- package/src/allocation_flow/effective_item_fingerprint.js +14 -0
- package/src/allocation_flow/item_continuation_lock_gate.js +38 -0
- package/src/allocation_flow/no_space_left_recovery.js +48 -0
- package/src/allocation_flow/run_allocation_iteration.js +155 -0
- package/src/allocation_flow/space_skip_state.js +91 -0
- package/src/allocation_flow/try_no_space_left_recovery.js +50 -0
- package/src/exceptions/Invalid_Parameter_Exception.js +17 -0
- package/src/exceptions/Relational_Allocation_Incomplete_Exception.js +24 -0
- package/src/exceptions/Relational_Colocation_Violation_Exception.js +23 -0
- package/src/exceptions/Relational_Config_Mismatch_Exception.js +17 -0
- package/src/exceptions/There_Is_No_Block_Options_To_Allocate_Exception.js +14 -0
- package/src/index.js +6 -0
- package/src/input_preparation/Block_Formatter.js +179 -0
- package/src/input_preparation/Input_Creator.js +76 -0
- package/src/input_preparation/Input_State_Preparation.js +47 -0
- package/src/input_preparation/State_Builder.js +27 -0
- package/src/input_preparation/block_formatter/align_flush_axis_config.js +36 -0
- package/src/input_preparation/block_formatter/align_flush_axis_single_round.js +112 -0
- package/src/input_preparation/block_formatter/align_flush_stacked_slots.js +67 -0
- package/src/input_preparation/block_formatter/overlapped_slots.js +24 -0
- package/src/input_preparation/block_formatter/parallelepiped_shell.js +38 -0
- package/src/input_preparation/block_formatter/rectangle_coverage.js +112 -0
- package/src/input_preparation/block_formatter/shell_face_coverage.js +64 -0
- package/src/input_preparation/block_formatter/shell_snap_convergence.js +104 -0
- package/src/input_preparation/block_preparation/Block_Data_To_Object_Transformer.js +57 -0
- package/src/input_preparation/block_preparation/Block_Module_Name.js +17 -0
- package/src/input_preparation/block_preparation/Blocks_Creator.js +101 -0
- package/src/input_preparation/block_preparation/Blocksmith.js +19 -0
- package/src/input_preparation/block_preparation/block_modules/create_block_candidates.js +41 -0
- package/src/input_preparation/block_preparation/block_modules/manual_blocks.js +10 -0
- package/src/input_preparation/block_preparation/block_modules/module_registry.js +20 -0
- package/src/input_preparation/block_preparation/block_modules/run_creator.js +34 -0
- package/src/input_preparation/block_preparation/block_modules/single_item_blocks.js +12 -0
- package/src/input_preparation/block_preparation/block_modules/spiral_blocks.js +12 -0
- package/src/input_preparation/block_preparation/block_modules/tie_ratio_blocks.js +12 -0
- package/src/input_preparation/block_preparation/block_modules/tower_blocks.js +12 -0
- package/src/input_preparation/block_preparation/exceptions/Failed_To_Create_Block_Exception.js +14 -0
- package/src/input_preparation/block_preparation/exceptions/Failed_To_Retrieve_Block_Exception.js +17 -0
- package/src/input_preparation/block_preparation/exceptions/Missing_Object_Store_Exception.js +10 -0
- package/src/input_preparation/block_preparation/exceptions/No_Blocks_Were_Created_Exception.js +14 -0
- package/src/input_preparation/block_preparation/input/Input_Creator.js +96 -0
- package/src/input_preparation/block_preparation/manual_blocks/Manual_Blocks.js +95 -0
- package/src/input_preparation/build_empty_space_finder_options.js +43 -0
- package/src/input_preparation/item_preparation/Items_Reader.js +27 -0
- package/src/input_preparation/min_extents_from_items.js +29 -0
- package/src/input_preparation/stackability_index/Blocks_Stackability_Index_Calculator.js +58 -0
- package/src/input_preparation/stackability_index/Slots_Stackability_index_Calculator.js +28 -0
- package/src/input_preparation/stackability_index/Stackability_Input_Creator.js +27 -0
- package/src/input_preparation/stackability_index/stackability_index_pop_stack.js +81 -0
- package/src/input_preparation/stacking_constraints/Weight_Stacking_Validation.js +15 -0
- package/src/lp_optimizer_result_status.js +20 -0
- package/src/messages/Allocator_Message.js +42 -0
- package/src/messages/resolve_error_message_entry.js +57 -0
- package/src/models/Allocated_Item.js +136 -0
- package/src/models/Allocation_Item.js +219 -0
- package/src/models/Block.js +198 -0
- package/src/models/Cargo_Profile.js +418 -0
- package/src/models/Preloaded_Allocated_Item.js +132 -0
- package/src/models/Slot.js +67 -0
- package/src/models/Stacking_Rules.js +58 -0
- package/src/models/auxiliaryFunctions/Available_Block_Module_List_Creator.js +9 -0
- package/src/models/auxiliaryFunctions/Measure_Translator.js +24 -0
- package/src/models/auxiliaryFunctions/item_json_reader.js +44 -0
- package/src/models/item_json_reader.js +71 -0
- package/src/models/placed_item_record.js +70 -0
- package/src/models/preloaded_rotation_helpers.js +38 -0
- package/src/models/slots_have_same_measure.js +45 -0
- package/src/models/transport/Container.js +162 -0
- package/src/models/transport/Transport.js +62 -0
- package/src/models/transport/build_stacking_feasibility_checker.js +64 -0
- package/src/models/transport/container_stacking_checkpoint.js +42 -0
- package/src/models/transport/factory/Container_Factory.js +46 -0
- package/src/models/transport/factory/Corner_Casting_Factory.js +62 -0
- package/src/models/transport/factory/Previously_Allocated_Item_Factory.js +28 -0
- package/src/models/transport/factory/Transport_Factory.js +13 -0
- package/src/models/transport/items_for_empty_space_finder.js +91 -0
- package/src/models/transport/resolve_container_stacking_inputs.js +23 -0
- package/src/models/transport/stacking_input_from_wire.js +58 -0
- package/src/optimizer_connection_errors.js +50 -0
- package/src/relational/Relational_Error_Codes.js +7 -0
- package/src/relational/finalize_relational_allocation.js +20 -0
- package/src/relational/has_relational_items.js +11 -0
- package/src/relational/is_relational_error_code.js +15 -0
- package/src/relational/resolve_relational_container_sequences.js +29 -0
- package/src/run_core_allocation.js +118 -0
- package/src/space_and_block_chooser/Space_And_Blocks_Chooser.js +115 -0
- package/src/space_and_block_chooser/blocks_filters/Block_Filter_Interface.js +19 -0
- package/src/space_and_block_chooser/blocks_filters/Filter_Runner.js +46 -0
- package/src/space_and_block_chooser/blocks_filters/initial_blocks_filter/Block_With_Overlapped_Slots_Filter.js +14 -0
- package/src/space_and_block_chooser/blocks_filters/initial_blocks_filter/Initial_Blocks_Filter_List.js +19 -0
- package/src/space_and_block_chooser/blocks_filters/pos_selection_filters/Blocks_Bigger_Than_Space_Filter.js +17 -0
- package/src/space_and_block_chooser/blocks_filters/pos_selection_filters/Post_Selection_Filter_List.js +9 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/Insuficient_Items_Filter.js +81 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/Pre_Selection_Filter_List.js +8 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/max_tower_height/Blocks_Lower_Than_Max_Tower_Height.js +23 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/max_tower_height/Max_Tower_Height.js +82 -0
- package/src/space_and_block_chooser/build_allocated_item_snapshots.js +19 -0
- package/src/space_and_block_chooser/compound_first_empty_space_branch.js +61 -0
- package/src/space_and_block_chooser/compound_first_with_leftover_fill.js +142 -0
- package/src/space_and_block_chooser/compound_first_without_leftover_fill.js +56 -0
- package/src/space_and_block_chooser/empty_spaces_where_post_selection_keeps_blocks.js +83 -0
- package/src/space_and_block_chooser/exceptions/Invalid_Space_To_Allocate_Exception.js +14 -0
- package/src/space_and_block_chooser/leftover_space_memory.js +113 -0
- package/src/space_and_block_chooser/leftover_unitary_blocks.js +153 -0
- package/src/space_and_block_chooser/leftover_unitary_empty_spaces.js +135 -0
- package/src/space_and_block_chooser/probe_set_pool.js +35 -0
- package/src/space_and_block_chooser/run_space_and_block_selection_attempt.js +88 -0
- package/src/tools/Array_Validator.js +6 -0
- package/src/tools/Clone.js +27 -0
- package/src/tools/Hash.js +8 -0
- package/src/tools/Rounder.js +5 -0
- package/src/tools/String_To_Boolean.js +12 -0
- package/src/tools/cargo_profile/Cargo_Profile_Field_Value_Resolver.js +44 -0
- package/src/tools/compact_items_with_stock.js +9 -0
- package/src/tools/mm_to_allocation_domain.js +14 -0
- package/src/tracing/Allocation_Tracer.js +52 -0
- package/src/tracing/Trace_Context.js +18 -0
- package/src/tracing/trace_outcome.js +18 -0
- package/src/tracing/traced_step.js +57 -0
- package/src/validation/Item_Continuation_Lock_Flag.js +52 -0
- package/src/validation/Item_Validation.js +29 -0
- package/src/validation/Relational_Colocation_Validator.js +60 -0
- package/src/validation/Relational_Completeness_Validator.js +146 -0
- package/src/validation/Relational_Continuation_Lock_Validation.js +37 -0
- package/src/validation/Relational_Proportional_Normalizer.js +194 -0
- package/src/validation/Validation.js +9 -0
- package/src/validation/Validation_Runner.js +20 -0
- package/src/validation/exceptions/Invalid_Block_Module_Config_Exception.js +14 -0
- package/src/validation/exceptions/Invalid_Input_Exception.js +14 -0
- package/src/validation/exceptions/Invalid_Input_Type_Exception.js +14 -0
- package/src/validation/schemas/allocated_item_schema.js +18 -0
- package/src/validation/schemas/allocation_request_schema.js +178 -0
- package/src/validation/schemas/container_row_schema.js +16 -0
- package/src/validation/schemas/item_schema.js +60 -0
- package/src/validation/schemas/transport_env_schema.js +19 -0
- package/src/validation/validate_block_module_config.js +147 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
|
|
2
|
+
const Config = require('../../../../models/Cargo_Profile')
|
|
3
|
+
const calculate_stackability_index = require('@jettacargo/stackability-index-calculator-core').default
|
|
4
|
+
const round = require('../../../../tools/Rounder')
|
|
5
|
+
|
|
6
|
+
module.exports = function calculate_max_tower_height(container, item_list)
|
|
7
|
+
{
|
|
8
|
+
// variable names were kept the same as the document
|
|
9
|
+
// which can be accessed here: https://docs.google.com/document/d/1-frn1tHfbjpTfN85Uc5laP50qBsazPyT2bZqzL0P7U4/edit?pli=1&tab=t.0
|
|
10
|
+
const A = get_container_height(container, item_list)
|
|
11
|
+
const L = get_measure_factor(container.get_width(), item_list)
|
|
12
|
+
const C = get_measure_factor(container.get_length(), item_list)
|
|
13
|
+
const Af = (L * C * A) / (container.get_width() * container.get_length())
|
|
14
|
+
return round(Af)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function get_measure_factor(factor, item_data_list)
|
|
18
|
+
{
|
|
19
|
+
const l = get_item_width_mean(item_data_list)
|
|
20
|
+
const Xa = factor / (Config.max_tower_height_superior_gap() * l)
|
|
21
|
+
const Xb = factor / (Config.max_tower_height_inferior_gap() * l)
|
|
22
|
+
|
|
23
|
+
const Ka = Xa - Math.trunc(Xa)
|
|
24
|
+
const Kb = Xb - Math.trunc(Xb)
|
|
25
|
+
const ql = Ka < Kb ? Math.trunc(Xa) : Math.trunc(Xb)
|
|
26
|
+
|
|
27
|
+
return l * ql
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function get_container_height(container, item_data_list)
|
|
31
|
+
{
|
|
32
|
+
const Si = get_normalized_si(item_data_list)
|
|
33
|
+
const A = container.get_height() * Si
|
|
34
|
+
return A
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function get_item_width_mean(item_list)
|
|
38
|
+
{
|
|
39
|
+
const item_qty = item_list.reduce((acc, cur) => acc + cur.get_amount(), 0)
|
|
40
|
+
return item_list.reduce((acc, cur) => acc + (cur.get_width() * cur.get_amount()), 0) / item_qty
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function get_normalized_si(item_list)
|
|
44
|
+
{
|
|
45
|
+
const item_data_list = item_list.map(item => create_item_data(item.get_json()))
|
|
46
|
+
const Si = calculate_stackability_index(item_data_list)
|
|
47
|
+
const Si_mean = Si.reduce((acc, cur) => acc + cur, 0) / Si.length
|
|
48
|
+
|
|
49
|
+
if (Si_mean <= 5)
|
|
50
|
+
{
|
|
51
|
+
return 0.8
|
|
52
|
+
}
|
|
53
|
+
if (Si_mean >= 20)
|
|
54
|
+
{
|
|
55
|
+
return 1
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return 0.9
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function create_item_data(item)
|
|
62
|
+
{
|
|
63
|
+
return {
|
|
64
|
+
id: item._id,
|
|
65
|
+
amount: item.qtd,
|
|
66
|
+
width: item.largura,
|
|
67
|
+
height: item.altura,
|
|
68
|
+
length: item.comprimento,
|
|
69
|
+
weight: item.peso,
|
|
70
|
+
supported_weight: item.pesoMaxSuportado,
|
|
71
|
+
maximum_stacking: item.empilhamentoMaximo,
|
|
72
|
+
rotation_list: Object.keys(item.rotacao).filter(rotation => item.rotacao[rotation]),
|
|
73
|
+
stacking_unit: item.stackingUnit.toLowerCase(),
|
|
74
|
+
stacking_rules: {
|
|
75
|
+
family: item.stacking.family,
|
|
76
|
+
supported_families: item.stacking.supported_families,
|
|
77
|
+
only_stack_same_family: item.restricoes.empilharFamilias,
|
|
78
|
+
only_stack_same_area: item.restricoes.empilharAreaIgual,
|
|
79
|
+
only_stack_same_item: item.restricoes.empilharItemIgual
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps allocated container items to empty-space chooser snapshots.
|
|
3
|
+
* @param {object} container - Container with get_allocated_items().
|
|
4
|
+
* @returns {Array<{ x: number, y: number, z: number, width: number, height: number, length: number }>}
|
|
5
|
+
*/
|
|
6
|
+
function build_allocated_item_snapshots(container)
|
|
7
|
+
{
|
|
8
|
+
const allocated_items = container.get_allocated_items?.() ?? []
|
|
9
|
+
return allocated_items.map(item => ({
|
|
10
|
+
x: item.get_x(),
|
|
11
|
+
y: item.get_y(),
|
|
12
|
+
z: item.get_z(),
|
|
13
|
+
width: item.get_width(),
|
|
14
|
+
height: item.get_height(),
|
|
15
|
+
length: item.get_length()
|
|
16
|
+
}))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = build_allocated_item_snapshots
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const Cargo_Profile = require('../models/Cargo_Profile')
|
|
2
|
+
const leftover_space_memory = require('./leftover_space_memory')
|
|
3
|
+
const {
|
|
4
|
+
leftover_or_legacy_resolution,
|
|
5
|
+
skip_probe_resolution
|
|
6
|
+
} = require('./leftover_unitary_empty_spaces')
|
|
7
|
+
const { resolve_after_compound_probe_without_leftover_fill } = require(
|
|
8
|
+
'./compound_first_without_leftover_fill'
|
|
9
|
+
)
|
|
10
|
+
const resolve_after_compound_probe = require('./compound_first_with_leftover_fill')
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolves chooser spaces and blocks when obligate-compound-first applies.
|
|
14
|
+
* @param {Function} run_filters
|
|
15
|
+
* @param {Object} filter_data
|
|
16
|
+
* @param {Array<Object>} empty_space_list
|
|
17
|
+
* @param {Array<Object>} pre_selected_block_list
|
|
18
|
+
* @returns {Promise<object>}
|
|
19
|
+
*/
|
|
20
|
+
async function resolve_empty_spaces_and_blocks_for_obligate_compound_first(
|
|
21
|
+
run_filters,
|
|
22
|
+
filter_data,
|
|
23
|
+
empty_space_list,
|
|
24
|
+
pre_selected_block_list
|
|
25
|
+
)
|
|
26
|
+
{
|
|
27
|
+
if (!Cargo_Profile.obligate_block_allocation_first())
|
|
28
|
+
{
|
|
29
|
+
return leftover_or_legacy_resolution(empty_space_list, pre_selected_block_list, [])
|
|
30
|
+
}
|
|
31
|
+
const use_leftover_fill = Cargo_Profile.leftover_sku_unitary_fill()
|
|
32
|
+
if (filter_data.obligate_compound_session?.skip_compound_probe === true)
|
|
33
|
+
{
|
|
34
|
+
if (use_leftover_fill)
|
|
35
|
+
{
|
|
36
|
+
return leftover_space_memory.skip_probe_or_leftover_resolution(
|
|
37
|
+
filter_data,
|
|
38
|
+
empty_space_list,
|
|
39
|
+
pre_selected_block_list
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
return skip_probe_resolution(empty_space_list, pre_selected_block_list)
|
|
43
|
+
}
|
|
44
|
+
if (use_leftover_fill)
|
|
45
|
+
{
|
|
46
|
+
return resolve_after_compound_probe(
|
|
47
|
+
run_filters,
|
|
48
|
+
filter_data,
|
|
49
|
+
empty_space_list,
|
|
50
|
+
pre_selected_block_list
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
return resolve_after_compound_probe_without_leftover_fill(
|
|
54
|
+
run_filters,
|
|
55
|
+
filter_data,
|
|
56
|
+
empty_space_list,
|
|
57
|
+
pre_selected_block_list
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = resolve_empty_spaces_and_blocks_for_obligate_compound_first
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const leftover_unitary_blocks = require('./leftover_unitary_blocks')
|
|
2
|
+
const empty_spaces_where_post_selection_keeps_blocks = require('./empty_spaces_where_post_selection_keeps_blocks')
|
|
3
|
+
const leftover_space_memory = require('./leftover_space_memory')
|
|
4
|
+
const {
|
|
5
|
+
leftover_unitary_empty_spaces,
|
|
6
|
+
leftover_or_legacy_resolution,
|
|
7
|
+
resolve_compound_first_or_leftover
|
|
8
|
+
} = require('./leftover_unitary_empty_spaces')
|
|
9
|
+
const { compound_blocks_from_list } = require('./compound_first_without_leftover_fill')
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolves chooser spaces after probing compounds and leftover unitaries.
|
|
13
|
+
* @param {Function} run_filters
|
|
14
|
+
* @param {object} filter_data
|
|
15
|
+
* @param {object[]} empty_space_list
|
|
16
|
+
* @param {object[]} pre_selected_block_list
|
|
17
|
+
* @returns {Promise<object>}
|
|
18
|
+
*/
|
|
19
|
+
async function resolve_after_compound_probe(
|
|
20
|
+
run_filters,
|
|
21
|
+
filter_data,
|
|
22
|
+
empty_space_list,
|
|
23
|
+
pre_selected_block_list
|
|
24
|
+
)
|
|
25
|
+
{
|
|
26
|
+
const compound_block_list = compound_blocks_from_list(pre_selected_block_list)
|
|
27
|
+
const leftover_block_list = leftover_unitary_blocks(
|
|
28
|
+
pre_selected_block_list,
|
|
29
|
+
compound_block_list,
|
|
30
|
+
filter_data.obligate_compound_session?.leftover_sku_shape_hashes
|
|
31
|
+
)
|
|
32
|
+
leftover_unitary_blocks.remember_leftover_sku_hashes(
|
|
33
|
+
filter_data.obligate_compound_session,
|
|
34
|
+
leftover_block_list,
|
|
35
|
+
compound_block_list
|
|
36
|
+
)
|
|
37
|
+
if (compound_block_list.length === 0)
|
|
38
|
+
{
|
|
39
|
+
return resolve_leftover_when_no_compounds(
|
|
40
|
+
run_filters,
|
|
41
|
+
filter_data,
|
|
42
|
+
empty_space_list,
|
|
43
|
+
pre_selected_block_list,
|
|
44
|
+
leftover_block_list
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
return resolve_leftover_after_compound_viable(
|
|
48
|
+
run_filters,
|
|
49
|
+
filter_data,
|
|
50
|
+
empty_space_list,
|
|
51
|
+
pre_selected_block_list,
|
|
52
|
+
compound_block_list
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {Function} run_filters
|
|
58
|
+
* @param {object} filter_data
|
|
59
|
+
* @param {object[]} empty_space_list
|
|
60
|
+
* @param {object[]} pre_selected_block_list
|
|
61
|
+
* @param {object[]} leftover_block_list
|
|
62
|
+
* @returns {Promise<object>}
|
|
63
|
+
*/
|
|
64
|
+
async function resolve_leftover_when_no_compounds(
|
|
65
|
+
run_filters,
|
|
66
|
+
filter_data,
|
|
67
|
+
empty_space_list,
|
|
68
|
+
pre_selected_block_list,
|
|
69
|
+
leftover_block_list
|
|
70
|
+
)
|
|
71
|
+
{
|
|
72
|
+
const leftover_candidates = leftover_space_memory.spaces_matching_remembered_leftover(
|
|
73
|
+
empty_space_list,
|
|
74
|
+
filter_data.obligate_compound_session
|
|
75
|
+
)
|
|
76
|
+
const leftover_empty_spaces = await leftover_unitary_empty_spaces(
|
|
77
|
+
run_filters,
|
|
78
|
+
filter_data,
|
|
79
|
+
leftover_candidates.length > 0 ? leftover_candidates : empty_space_list,
|
|
80
|
+
leftover_block_list.length > 0 ? leftover_block_list : pre_selected_block_list,
|
|
81
|
+
[]
|
|
82
|
+
)
|
|
83
|
+
leftover_space_memory.remember_leftover_empty_spaces(
|
|
84
|
+
filter_data.obligate_compound_session,
|
|
85
|
+
leftover_empty_spaces
|
|
86
|
+
)
|
|
87
|
+
return leftover_or_legacy_resolution(
|
|
88
|
+
empty_space_list,
|
|
89
|
+
pre_selected_block_list,
|
|
90
|
+
leftover_empty_spaces,
|
|
91
|
+
leftover_block_list
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {Function} run_filters
|
|
97
|
+
* @param {object} filter_data
|
|
98
|
+
* @param {object[]} empty_space_list
|
|
99
|
+
* @param {object[]} pre_selected_block_list
|
|
100
|
+
* @param {object[]} compound_block_list
|
|
101
|
+
* @returns {Promise<object>}
|
|
102
|
+
*/
|
|
103
|
+
async function resolve_leftover_after_compound_viable(
|
|
104
|
+
run_filters,
|
|
105
|
+
filter_data,
|
|
106
|
+
empty_space_list,
|
|
107
|
+
pre_selected_block_list,
|
|
108
|
+
compound_block_list
|
|
109
|
+
)
|
|
110
|
+
{
|
|
111
|
+
const viable_spaces = await empty_spaces_where_post_selection_keeps_blocks(
|
|
112
|
+
run_filters,
|
|
113
|
+
filter_data,
|
|
114
|
+
empty_space_list,
|
|
115
|
+
compound_block_list
|
|
116
|
+
)
|
|
117
|
+
const leftover_empty_spaces = await leftover_unitary_empty_spaces(
|
|
118
|
+
run_filters,
|
|
119
|
+
filter_data,
|
|
120
|
+
empty_space_list,
|
|
121
|
+
pre_selected_block_list,
|
|
122
|
+
viable_spaces
|
|
123
|
+
)
|
|
124
|
+
leftover_space_memory.remember_leftover_empty_spaces(
|
|
125
|
+
filter_data.obligate_compound_session,
|
|
126
|
+
leftover_empty_spaces
|
|
127
|
+
)
|
|
128
|
+
const leftover_in_region = leftover_space_memory.spaces_matching_remembered_leftover(
|
|
129
|
+
leftover_empty_spaces,
|
|
130
|
+
filter_data.obligate_compound_session
|
|
131
|
+
)
|
|
132
|
+
return resolve_compound_first_or_leftover(
|
|
133
|
+
filter_data,
|
|
134
|
+
empty_space_list,
|
|
135
|
+
pre_selected_block_list,
|
|
136
|
+
compound_block_list,
|
|
137
|
+
viable_spaces,
|
|
138
|
+
leftover_in_region.length > 0 ? leftover_in_region : leftover_empty_spaces
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = resolve_after_compound_probe
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const empty_spaces_where_post_selection_keeps_blocks = require('./empty_spaces_where_post_selection_keeps_blocks')
|
|
2
|
+
const { leftover_or_legacy_resolution } = require('./leftover_unitary_empty_spaces')
|
|
3
|
+
|
|
4
|
+
function compound_blocks_from_list(block_list)
|
|
5
|
+
{
|
|
6
|
+
return block_list.filter(
|
|
7
|
+
block => typeof block.get_slot_list === 'function' && block.get_slot_list().length > 1
|
|
8
|
+
)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Prod compound-first: compounds when viable, else full lists (no leftover-SKU lock).
|
|
13
|
+
* @param {Function} run_filters
|
|
14
|
+
* @param {object} filter_data
|
|
15
|
+
* @param {object[]} empty_space_list
|
|
16
|
+
* @param {object[]} pre_selected_block_list
|
|
17
|
+
* @returns {Promise<object>}
|
|
18
|
+
*/
|
|
19
|
+
async function resolve_after_compound_probe_without_leftover_fill(
|
|
20
|
+
run_filters,
|
|
21
|
+
filter_data,
|
|
22
|
+
empty_space_list,
|
|
23
|
+
pre_selected_block_list
|
|
24
|
+
)
|
|
25
|
+
{
|
|
26
|
+
const compound_block_list = compound_blocks_from_list(pre_selected_block_list)
|
|
27
|
+
if (compound_block_list.length === 0)
|
|
28
|
+
{
|
|
29
|
+
return leftover_or_legacy_resolution(empty_space_list, pre_selected_block_list, [])
|
|
30
|
+
}
|
|
31
|
+
const viable_spaces = await empty_spaces_where_post_selection_keeps_blocks(
|
|
32
|
+
run_filters,
|
|
33
|
+
filter_data,
|
|
34
|
+
empty_space_list,
|
|
35
|
+
compound_block_list
|
|
36
|
+
)
|
|
37
|
+
if (viable_spaces.length > 0)
|
|
38
|
+
{
|
|
39
|
+
return {
|
|
40
|
+
empty_spaces_for_chooser: viable_spaces,
|
|
41
|
+
blocks_for_post_selection: compound_block_list,
|
|
42
|
+
leftover_empty_spaces: [],
|
|
43
|
+
skip_cluster_rank: false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (filter_data.obligate_compound_session)
|
|
47
|
+
{
|
|
48
|
+
filter_data.obligate_compound_session.skip_compound_probe = true
|
|
49
|
+
}
|
|
50
|
+
return leftover_or_legacy_resolution(empty_space_list, pre_selected_block_list, [])
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
compound_blocks_from_list,
|
|
55
|
+
resolve_after_compound_probe_without_leftover_fill
|
|
56
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const pos_selection_filters = require('./blocks_filters/pos_selection_filters/Post_Selection_Filter_List')
|
|
2
|
+
const Invalid_Space_To_Allocate_Exception = require('./exceptions/Invalid_Space_To_Allocate_Exception')
|
|
3
|
+
const { borrow_empty_set, release_probe_set } = require('./probe_set_pool')
|
|
4
|
+
const Cargo_Profile = require('../models/Cargo_Profile')
|
|
5
|
+
const { build_supporters_by_top_y_index } = require('../Allocation_Optimization/tie_ratio/supporters_by_top_y_index')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns empty spaces where at least one block from `block_list_for_probe` survives post-selection filters.
|
|
9
|
+
* Each probe uses fresh invalid and no_fillable sets so the caller's `filter_data` is not mutated.
|
|
10
|
+
*
|
|
11
|
+
* @param {Function} run_filters Same contract as `Filter_Runner`.
|
|
12
|
+
* @param {Object} filter_data Shared filter payload (container, item_list, spaces_to_avoid, etc.).
|
|
13
|
+
* @param {Array<Object>} empty_space_list Candidate empty spaces in iteration order.
|
|
14
|
+
* @param {Array<Object>} block_list_for_probe Blocks to test against each candidate space.
|
|
15
|
+
* @returns {Promise<Array<Object>>} Ordered subset of spaces that keep at least one block.
|
|
16
|
+
*/
|
|
17
|
+
async function empty_spaces_where_post_selection_keeps_blocks(
|
|
18
|
+
run_filters,
|
|
19
|
+
filter_data,
|
|
20
|
+
empty_space_list,
|
|
21
|
+
block_list_for_probe
|
|
22
|
+
)
|
|
23
|
+
{
|
|
24
|
+
const supporters_by_top_y_index = Cargo_Profile.allocate_intercalated()
|
|
25
|
+
? build_supporters_by_top_y_index(filter_data.container.get_allocated_items())
|
|
26
|
+
: undefined
|
|
27
|
+
const viable_spaces = []
|
|
28
|
+
for (const candidate_space of empty_space_list)
|
|
29
|
+
{
|
|
30
|
+
const keeps_blocks = await probe_space_keeps_blocks_after_post_selection(
|
|
31
|
+
run_filters,
|
|
32
|
+
filter_data,
|
|
33
|
+
candidate_space,
|
|
34
|
+
block_list_for_probe,
|
|
35
|
+
supporters_by_top_y_index
|
|
36
|
+
)
|
|
37
|
+
if (keeps_blocks)
|
|
38
|
+
{
|
|
39
|
+
viable_spaces.push(candidate_space)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return viable_spaces
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function probe_space_keeps_blocks_after_post_selection(
|
|
46
|
+
run_filters,
|
|
47
|
+
filter_data,
|
|
48
|
+
candidate_space,
|
|
49
|
+
block_list_for_probe,
|
|
50
|
+
supporters_by_top_y_index
|
|
51
|
+
)
|
|
52
|
+
{
|
|
53
|
+
const spaces_to_avoid = borrow_empty_set()
|
|
54
|
+
const no_fillable_space_set = borrow_empty_set()
|
|
55
|
+
const probe_filter_data = {
|
|
56
|
+
...filter_data,
|
|
57
|
+
block_list: block_list_for_probe,
|
|
58
|
+
empty_space: candidate_space,
|
|
59
|
+
spaces_to_avoid,
|
|
60
|
+
no_fillable_space_set,
|
|
61
|
+
supporters_by_top_y_index
|
|
62
|
+
}
|
|
63
|
+
try
|
|
64
|
+
{
|
|
65
|
+
await run_filters(pos_selection_filters, probe_filter_data)
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
catch (error)
|
|
69
|
+
{
|
|
70
|
+
if (error instanceof Invalid_Space_To_Allocate_Exception)
|
|
71
|
+
{
|
|
72
|
+
return false
|
|
73
|
+
}
|
|
74
|
+
throw error
|
|
75
|
+
}
|
|
76
|
+
finally
|
|
77
|
+
{
|
|
78
|
+
release_probe_set(spaces_to_avoid)
|
|
79
|
+
release_probe_set(no_fillable_space_set)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = empty_spaces_where_post_selection_keeps_blocks
|
|
@@ -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 Invalid_Space_To_Allocate_Exception extends Error
|
|
5
|
+
{
|
|
6
|
+
constructor()
|
|
7
|
+
{
|
|
8
|
+
const message_key = ALLOCATOR_MESSAGE.INVALID_SPACE
|
|
9
|
+
super(message_key)
|
|
10
|
+
this.message_entry = build_message_entry(message_key)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = Invalid_Space_To_Allocate_Exception
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const leftover_unitary_blocks = require('./leftover_unitary_blocks')
|
|
2
|
+
const {
|
|
3
|
+
leftover_or_legacy_resolution,
|
|
4
|
+
skip_probe_resolution
|
|
5
|
+
} = require('./leftover_unitary_empty_spaces')
|
|
6
|
+
|
|
7
|
+
const BBOX_TOLERANCE = 0.001
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Stores leftover-space bboxes on first leftover classification.
|
|
11
|
+
* @param {{ leftover_space_bboxes?: object[] }|undefined} session
|
|
12
|
+
* @param {object[]} leftover_empty_spaces
|
|
13
|
+
*/
|
|
14
|
+
function remember_leftover_empty_spaces(session, leftover_empty_spaces)
|
|
15
|
+
{
|
|
16
|
+
if (!session || leftover_empty_spaces.length === 0)
|
|
17
|
+
{
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
if (session.leftover_space_bboxes?.length > 0)
|
|
21
|
+
{
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
const bboxes = leftover_empty_spaces.map(space_bbox).filter(Boolean)
|
|
25
|
+
if (bboxes.length === 0)
|
|
26
|
+
{
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
session.leftover_space_bboxes = bboxes
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Pending spaces that match leftover pockets remembered during compound-first.
|
|
34
|
+
* @param {object[]} empty_space_list
|
|
35
|
+
* @param {{ leftover_space_bboxes?: object[] }|undefined} session
|
|
36
|
+
* @returns {object[]}
|
|
37
|
+
*/
|
|
38
|
+
function spaces_matching_remembered_leftover(empty_space_list, session)
|
|
39
|
+
{
|
|
40
|
+
const bboxes = session?.leftover_space_bboxes
|
|
41
|
+
if (!bboxes?.length)
|
|
42
|
+
{
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
45
|
+
return empty_space_list.filter(space => bboxes.some(bbox => space_contained_in_region(space, bbox)))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Skip-probe: leftover pocket + leftover SKUs when remembered; else all spaces and blocks.
|
|
50
|
+
* @param {object} filter_data
|
|
51
|
+
* @param {object[]} empty_space_list
|
|
52
|
+
* @param {object[]} pre_selected_block_list
|
|
53
|
+
* @returns {object}
|
|
54
|
+
*/
|
|
55
|
+
function skip_probe_or_leftover_resolution(filter_data, empty_space_list, pre_selected_block_list)
|
|
56
|
+
{
|
|
57
|
+
const session = filter_data.obligate_compound_session
|
|
58
|
+
const leftover_spaces = spaces_matching_remembered_leftover(empty_space_list, session)
|
|
59
|
+
const leftover_block_list = leftover_unitary_blocks(
|
|
60
|
+
pre_selected_block_list,
|
|
61
|
+
pre_selected_block_list.filter(
|
|
62
|
+
block => typeof block.get_slot_list === 'function' && block.get_slot_list().length > 1
|
|
63
|
+
),
|
|
64
|
+
session?.leftover_sku_shape_hashes
|
|
65
|
+
)
|
|
66
|
+
if (leftover_spaces.length > 0 && leftover_block_list.length > 0)
|
|
67
|
+
{
|
|
68
|
+
return leftover_or_legacy_resolution(
|
|
69
|
+
empty_space_list,
|
|
70
|
+
pre_selected_block_list,
|
|
71
|
+
leftover_spaces,
|
|
72
|
+
leftover_block_list
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
return skip_probe_resolution(empty_space_list, pre_selected_block_list)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function space_bbox(space)
|
|
79
|
+
{
|
|
80
|
+
if (typeof space.get_x !== 'function')
|
|
81
|
+
{
|
|
82
|
+
return null
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
x: space.get_x(),
|
|
86
|
+
y: space.get_y(),
|
|
87
|
+
z: space.get_z(),
|
|
88
|
+
w: space.get_width(),
|
|
89
|
+
h: space.get_height(),
|
|
90
|
+
l: space.get_length()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function space_contained_in_region(space, region)
|
|
95
|
+
{
|
|
96
|
+
const current = space_bbox(space)
|
|
97
|
+
if (!current)
|
|
98
|
+
{
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
return current.x >= region.x - BBOX_TOLERANCE
|
|
102
|
+
&& current.y >= region.y - BBOX_TOLERANCE
|
|
103
|
+
&& current.z >= region.z - BBOX_TOLERANCE
|
|
104
|
+
&& current.x + current.w <= region.x + region.w + BBOX_TOLERANCE
|
|
105
|
+
&& current.y + current.h <= region.y + region.h + BBOX_TOLERANCE
|
|
106
|
+
&& current.z + current.l <= region.z + region.l + BBOX_TOLERANCE
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = {
|
|
110
|
+
remember_leftover_empty_spaces,
|
|
111
|
+
spaces_matching_remembered_leftover,
|
|
112
|
+
skip_probe_or_leftover_resolution
|
|
113
|
+
}
|