@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,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {object[]} allocated_items
|
|
3
|
+
* @returns {Map<string|number, '3_2'|'2_3'>}
|
|
4
|
+
*/
|
|
5
|
+
function build_tie_ratio_orientation_by_group_id(allocated_items)
|
|
6
|
+
{
|
|
7
|
+
const orientation_by_group_id = new Map()
|
|
8
|
+
for (const item of allocated_items)
|
|
9
|
+
{
|
|
10
|
+
const orientation = item.get_tie_ratio_orientation?.()
|
|
11
|
+
if (orientation !== '3_2' && orientation !== '2_3')
|
|
12
|
+
{
|
|
13
|
+
continue
|
|
14
|
+
}
|
|
15
|
+
const group_id = item.get_group_id?.()
|
|
16
|
+
if (group_id === undefined || group_id === null)
|
|
17
|
+
{
|
|
18
|
+
continue
|
|
19
|
+
}
|
|
20
|
+
orientation_by_group_id.set(group_id, orientation)
|
|
21
|
+
}
|
|
22
|
+
return orientation_by_group_id
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {object} item
|
|
27
|
+
* @param {Map<string|number, '3_2'|'2_3'>} orientation_by_group_id
|
|
28
|
+
* @returns {'3_2'|'2_3'|undefined}
|
|
29
|
+
*/
|
|
30
|
+
function tie_ratio_orientation_from_item(item, orientation_by_group_id)
|
|
31
|
+
{
|
|
32
|
+
const direct_orientation = item.get_tie_ratio_orientation?.()
|
|
33
|
+
if (direct_orientation === '3_2' || direct_orientation === '2_3')
|
|
34
|
+
{
|
|
35
|
+
return direct_orientation
|
|
36
|
+
}
|
|
37
|
+
const group_id = item.get_group_id?.()
|
|
38
|
+
if (group_id === undefined || group_id === null)
|
|
39
|
+
{
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
return orientation_by_group_id.get(group_id)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
build_tie_ratio_orientation_by_group_id,
|
|
47
|
+
tie_ratio_orientation_from_item
|
|
48
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function clean_blocks_restricted_to_0(avaiable_usable_blocks, block_amount_restrictions)
|
|
2
|
+
{
|
|
3
|
+
for (const restricted_id in block_amount_restrictions)
|
|
4
|
+
{
|
|
5
|
+
if (block_amount_restrictions[restricted_id] > 0)
|
|
6
|
+
{
|
|
7
|
+
continue
|
|
8
|
+
}
|
|
9
|
+
const removable_indexes = avaiable_usable_blocks
|
|
10
|
+
.map((item, index) => (item._id === restricted_id ? index : -1))
|
|
11
|
+
.filter(index => index !== -1)
|
|
12
|
+
|
|
13
|
+
for (let index = removable_indexes.length - 1; index >= 0; index--)
|
|
14
|
+
{
|
|
15
|
+
avaiable_usable_blocks.splice(removable_indexes[index], 1)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function restrict_block(exception, block_amount_restrictions)
|
|
21
|
+
{
|
|
22
|
+
const restriction = exception.block_to_restrict
|
|
23
|
+
if (!block_amount_restrictions[restriction.id])
|
|
24
|
+
{
|
|
25
|
+
block_amount_restrictions[restriction.id] = Number.POSITIVE_INFINITY
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (block_amount_restrictions[restriction.id] > restriction.restrict_to)
|
|
29
|
+
{
|
|
30
|
+
block_amount_restrictions[restriction.id] = restriction.restrict_to
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = {clean_blocks_restricted_to_0, restrict_block}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const round = require('../tools/Rounder')
|
|
2
|
+
|
|
3
|
+
function cube_map_function(cube)
|
|
4
|
+
{
|
|
5
|
+
return round(cube.get_width()) + ';' + round(cube.get_height()) + ';' + round(cube.get_length())
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function item_map_function(item)
|
|
9
|
+
{
|
|
10
|
+
return round(item.width) + ';' + round(item.height) + ';' + round(item.length)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function allocation_item_map_function(allocation_item)
|
|
14
|
+
{
|
|
15
|
+
const item =
|
|
16
|
+
{
|
|
17
|
+
width: allocation_item.get_width(),
|
|
18
|
+
height: allocation_item.get_height(),
|
|
19
|
+
length: allocation_item.get_length()
|
|
20
|
+
}
|
|
21
|
+
return item_map_function(item)
|
|
22
|
+
}
|
|
23
|
+
module.exports = {
|
|
24
|
+
cube_map_function,
|
|
25
|
+
item_map_function,
|
|
26
|
+
allocation_item_map_function
|
|
27
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const {SUCCESS} = require('./Answer_Status')
|
|
2
|
+
const to_string = (data) => typeof data === 'string' ? data : JSON.stringify(data)
|
|
3
|
+
|
|
4
|
+
module.exports = function build_output_answer(request_status, data)
|
|
5
|
+
{
|
|
6
|
+
return request_status === SUCCESS ? _build_success_message(data) : to_string(data)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function _build_success_message(transport)
|
|
10
|
+
{
|
|
11
|
+
const output_data = []
|
|
12
|
+
const container_map = transport.get_containers()
|
|
13
|
+
|
|
14
|
+
for (const sequence of container_map.keys())
|
|
15
|
+
{
|
|
16
|
+
const container = container_map.get(sequence)
|
|
17
|
+
const container_data = {}
|
|
18
|
+
const environment = {}
|
|
19
|
+
environment.id = container.get_id()
|
|
20
|
+
environment._id = container.get_id()
|
|
21
|
+
environment.sequencia = sequence
|
|
22
|
+
container_data.environment = environment
|
|
23
|
+
|
|
24
|
+
const items = _get_items(container.get_allocated_items())
|
|
25
|
+
container_data.items = items
|
|
26
|
+
|
|
27
|
+
output_data.push(container_data)
|
|
28
|
+
}
|
|
29
|
+
return to_string(output_data)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _get_items(item_list)
|
|
33
|
+
{
|
|
34
|
+
return item_list.map(item => item.to_json())
|
|
35
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {object} transport - Transport after allocate().
|
|
3
|
+
* @returns {number} Total allocated items across all containers.
|
|
4
|
+
*/
|
|
5
|
+
function count_allocated_items_in_transport(transport)
|
|
6
|
+
{
|
|
7
|
+
let total = 0
|
|
8
|
+
for (const sequence of transport.get_container_sequence_list())
|
|
9
|
+
{
|
|
10
|
+
const container = transport.get_container_by_sequence(sequence)
|
|
11
|
+
total += container.get_allocated_items().length
|
|
12
|
+
}
|
|
13
|
+
return total
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {object} safe_input - Parsed allocation request with envs/containers.
|
|
18
|
+
* @returns {number} Pre-loaded items present in the input payload.
|
|
19
|
+
*/
|
|
20
|
+
function count_preloaded_items_in_input(safe_input)
|
|
21
|
+
{
|
|
22
|
+
return safe_input.envs
|
|
23
|
+
.flatMap(transport => transport.containers)
|
|
24
|
+
.flatMap(container => container.items ?? [])
|
|
25
|
+
.length
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
count_allocated_items_in_transport,
|
|
30
|
+
count_preloaded_items_in_input
|
|
31
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const resolve_error_message_entry = require('../messages/resolve_error_message_entry')
|
|
2
|
+
const is_relational_error_code = require('../relational/is_relational_error_code')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds the standard allocator error response envelope with catalog keys.
|
|
6
|
+
* @param {unknown} error_value
|
|
7
|
+
* @param {string} [response_status='error']
|
|
8
|
+
* @returns {object}
|
|
9
|
+
*/
|
|
10
|
+
function create_error_response(error_value, response_status = 'error')
|
|
11
|
+
{
|
|
12
|
+
const errors = resolve_error_message_entry(error_value)
|
|
13
|
+
const primary_key = errors[0][0]
|
|
14
|
+
const envelope = {
|
|
15
|
+
data: primary_key,
|
|
16
|
+
apiError: primary_key,
|
|
17
|
+
status: response_status,
|
|
18
|
+
messages: {
|
|
19
|
+
errors,
|
|
20
|
+
warnings: [],
|
|
21
|
+
infos: []
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
append_relational_fields(envelope, error_value)
|
|
25
|
+
return envelope
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {object} envelope
|
|
30
|
+
* @param {unknown} error_value
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
33
|
+
function append_relational_fields(envelope, error_value)
|
|
34
|
+
{
|
|
35
|
+
if (error_value === null || typeof error_value !== 'object')
|
|
36
|
+
{
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
if (!is_relational_error_code(error_value.code))
|
|
40
|
+
{
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
envelope.code = error_value.code
|
|
44
|
+
if (error_value.relational_group_id !== undefined)
|
|
45
|
+
{
|
|
46
|
+
envelope.relational_group_id = error_value.relational_group_id
|
|
47
|
+
}
|
|
48
|
+
if (error_value.container_sequences !== undefined)
|
|
49
|
+
{
|
|
50
|
+
envelope.container_sequences = error_value.container_sequences
|
|
51
|
+
}
|
|
52
|
+
if (error_value.allocated_counts !== undefined)
|
|
53
|
+
{
|
|
54
|
+
envelope.allocated_counts = error_value.allocated_counts
|
|
55
|
+
}
|
|
56
|
+
if (error_value.expected_counts !== undefined)
|
|
57
|
+
{
|
|
58
|
+
envelope.expected_counts = error_value.expected_counts
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = create_error_response
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const is_relational_error_code = require('../relational/is_relational_error_code')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copies relational metadata used by create_error_response.
|
|
5
|
+
* Prefer create_error_response for new wire paths.
|
|
6
|
+
* @param {Error} error
|
|
7
|
+
* @returns {object|undefined}
|
|
8
|
+
*/
|
|
9
|
+
function read_relational_error_fields(error)
|
|
10
|
+
{
|
|
11
|
+
if (!is_relational_error_code(error.code))
|
|
12
|
+
{
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
code: error.code,
|
|
18
|
+
relational_group_id: error.relational_group_id,
|
|
19
|
+
container_sequences: error.container_sequences,
|
|
20
|
+
allocated_counts: error.allocated_counts,
|
|
21
|
+
expected_counts: error.expected_counts
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = read_relational_error_fields
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks an item that must be reused across iterations once a single-slot
|
|
3
|
+
* block has allocated it. The lock holds until the item runs out of stock or
|
|
4
|
+
* an iteration with the lock active produces no consumption of that item.
|
|
5
|
+
*
|
|
6
|
+
* Callers are expected to resolve the locked item once per iteration via
|
|
7
|
+
* {@link Item_Continuation_Lock#resolve_locked_item} and then pass that
|
|
8
|
+
* reference to the other query methods, keeping per-iteration cost O(n) for
|
|
9
|
+
* a single lookup instead of repeating it.
|
|
10
|
+
*/
|
|
11
|
+
class Item_Continuation_Lock
|
|
12
|
+
{
|
|
13
|
+
#locked_item_id = null
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the locked item against the current master list. Returns
|
|
17
|
+
* `null` when no lock is set or when the locked id is no longer present.
|
|
18
|
+
* Memoize the result per iteration and pass it to the other methods.
|
|
19
|
+
* @param {object[]} item_list - Master item list with current amounts.
|
|
20
|
+
* @returns {object|null}
|
|
21
|
+
*/
|
|
22
|
+
resolve_locked_item(item_list)
|
|
23
|
+
{
|
|
24
|
+
if (this.#locked_item_id === null)
|
|
25
|
+
{
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
const locked = item_list.find(item => item.get_id() === this.#locked_item_id)
|
|
29
|
+
return locked ?? null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the item list to expose to the LP / chooser in the next
|
|
34
|
+
* iteration. When no item is locked, returns the original list. When the
|
|
35
|
+
* locked item is exhausted or missing, releases the lock and returns the
|
|
36
|
+
* original. Otherwise returns a list containing only the locked item.
|
|
37
|
+
* @param {object[]} item_list - Master item list with current amounts.
|
|
38
|
+
* @param {object|null} locked_item - Item previously resolved via {@link resolve_locked_item}.
|
|
39
|
+
* @returns {object[]}
|
|
40
|
+
*/
|
|
41
|
+
get_effective_item_list(item_list, locked_item)
|
|
42
|
+
{
|
|
43
|
+
if (this.#locked_item_id === null)
|
|
44
|
+
{
|
|
45
|
+
return item_list
|
|
46
|
+
}
|
|
47
|
+
if (!locked_item || locked_item.get_amount() <= 0)
|
|
48
|
+
{
|
|
49
|
+
this.#locked_item_id = null
|
|
50
|
+
return item_list
|
|
51
|
+
}
|
|
52
|
+
return [locked_item]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Sets the lock to the first id reported by a single-slot allocation
|
|
57
|
+
* (no-op if a lock is already active or the set is empty).
|
|
58
|
+
* @param {Set<string>} single_slot_allocated_item_ids - Ids allocated via single-slot blocks.
|
|
59
|
+
* @returns {void}
|
|
60
|
+
*/
|
|
61
|
+
update_from_iteration(single_slot_allocated_item_ids)
|
|
62
|
+
{
|
|
63
|
+
if (this.#locked_item_id !== null)
|
|
64
|
+
{
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
if (!single_slot_allocated_item_ids || single_slot_allocated_item_ids.size === 0)
|
|
68
|
+
{
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
const [first_id] = single_slot_allocated_item_ids
|
|
72
|
+
this.#locked_item_id = first_id
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Snapshots the locked item's current amount, to be compared after the
|
|
77
|
+
* iteration runs. Returns null when no item is currently locked.
|
|
78
|
+
* @param {object|null} locked_item - Item previously resolved via {@link resolve_locked_item}.
|
|
79
|
+
* @returns {number|null}
|
|
80
|
+
*/
|
|
81
|
+
snapshot_locked_amount(locked_item)
|
|
82
|
+
{
|
|
83
|
+
if (this.#locked_item_id === null)
|
|
84
|
+
{
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
return locked_item ? locked_item.get_amount() : 0
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Releases the lock when the locked item's amount has not changed since
|
|
92
|
+
* the snapshot, signaling that the last iteration made no progress on it.
|
|
93
|
+
* @param {number|null} amount_before - Snapshot returned by snapshot_locked_amount.
|
|
94
|
+
* @param {object|null} locked_item - Item previously resolved via {@link resolve_locked_item}.
|
|
95
|
+
* @returns {void}
|
|
96
|
+
*/
|
|
97
|
+
release_if_no_progress(amount_before, locked_item)
|
|
98
|
+
{
|
|
99
|
+
if (this.#locked_item_id === null || amount_before === null)
|
|
100
|
+
{
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
const current_amount = locked_item ? locked_item.get_amount() : 0
|
|
104
|
+
if (current_amount === amount_before)
|
|
105
|
+
{
|
|
106
|
+
this.#locked_item_id = null
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Clears the lock so density balancing can expose other SKUs.
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*/
|
|
114
|
+
release_for_density_balance()
|
|
115
|
+
{
|
|
116
|
+
this.#locked_item_id = null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Exposed for testing/diagnostics.
|
|
121
|
+
* @returns {string|null}
|
|
122
|
+
*/
|
|
123
|
+
get_locked_item_id()
|
|
124
|
+
{
|
|
125
|
+
return this.#locked_item_id
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = Item_Continuation_Lock
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const Cargo_Profile = require('./models/Cargo_Profile')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Soft SKU continuity across walls: seeds the slot heuristic with the last
|
|
5
|
+
* allocated item from the previous successful wall without filtering the LP.
|
|
6
|
+
*/
|
|
7
|
+
class Item_Picking_Continuity
|
|
8
|
+
{
|
|
9
|
+
#seed_item_id = null
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @returns {string|null}
|
|
13
|
+
*/
|
|
14
|
+
get_seed_item_id()
|
|
15
|
+
{
|
|
16
|
+
return this.#seed_item_id
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {string|null|undefined} last_item_id
|
|
21
|
+
* @returns {void}
|
|
22
|
+
*/
|
|
23
|
+
update_from_wall(last_item_id)
|
|
24
|
+
{
|
|
25
|
+
if (last_item_id == null || last_item_id === '' || !Cargo_Profile.prefer_block_with_same_item())
|
|
26
|
+
{
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
this.#seed_item_id = last_item_id
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
reset()
|
|
36
|
+
{
|
|
37
|
+
this.#seed_item_id = null
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = Item_Picking_Continuity
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Tie_Ratio_Intercalation_State = require('../Allocation_Optimization/tie_ratio/Tie_Ratio_Intercalation_State')
|
|
2
|
+
const Cargo_Profile = require('../models/Cargo_Profile')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates persistent chooser session state reused across allocation iterations.
|
|
6
|
+
* @returns {{
|
|
7
|
+
* obligate_compound_session: { skip_compound_probe: boolean },
|
|
8
|
+
* tie_ratio_intercalation_state: Tie_Ratio_Intercalation_State
|
|
9
|
+
* }}
|
|
10
|
+
*/
|
|
11
|
+
function create_chooser_session_state()
|
|
12
|
+
{
|
|
13
|
+
return {
|
|
14
|
+
obligate_compound_session: { skip_compound_probe: false },
|
|
15
|
+
tie_ratio_intercalation_state: new Tie_Ratio_Intercalation_State(
|
|
16
|
+
Cargo_Profile.allocate_intercalated()
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { create_chooser_session_state }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const Cargo_Profile = require('../models/Cargo_Profile')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns true when compound-first probing should be skipped on the next chooser pass.
|
|
5
|
+
* @param {object[]} block_list - Blocks selected for the failed allocation attempt.
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
8
|
+
function should_skip_compound_probe_after_failure(block_list)
|
|
9
|
+
{
|
|
10
|
+
if (!Cargo_Profile.obligate_block_allocation_first())
|
|
11
|
+
{
|
|
12
|
+
return false
|
|
13
|
+
}
|
|
14
|
+
return block_list.some(block => block.get_slot_list().length > 1)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { should_skip_compound_probe_after_failure }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const compact_items_with_stock = require('../tools/compact_items_with_stock')
|
|
2
|
+
const math = require('@jetta/number-compare')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {object[]} item_list
|
|
6
|
+
* @param {object} container
|
|
7
|
+
* @returns {{ item_list: object[], has_capacity: boolean }}
|
|
8
|
+
*/
|
|
9
|
+
function remaining_items_fit_container(item_list, container)
|
|
10
|
+
{
|
|
11
|
+
const compacted_list = compact_items_with_stock(item_list)
|
|
12
|
+
const has_items = compacted_list.length > 0
|
|
13
|
+
const has_space = container.has_space(compacted_list)
|
|
14
|
+
const has_weight = compacted_list.some(
|
|
15
|
+
item => math.le(item.get_weight(), container.supported_weight())
|
|
16
|
+
)
|
|
17
|
+
return {
|
|
18
|
+
item_list: compacted_list,
|
|
19
|
+
has_capacity: has_items && has_space && has_weight
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = { remaining_items_fit_container }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies the active density group filter to the effective item list.
|
|
3
|
+
* @param {object|null} density_scheduler
|
|
4
|
+
* @param {object[]} master_item_list
|
|
5
|
+
* @param {object[]} effective_item_list
|
|
6
|
+
* @param {object|null} locked_item
|
|
7
|
+
* @returns {object[]}
|
|
8
|
+
*/
|
|
9
|
+
function apply_density_group_item_filter(density_scheduler, master_item_list, effective_item_list, locked_item)
|
|
10
|
+
{
|
|
11
|
+
if (!density_scheduler || locked_item)
|
|
12
|
+
{
|
|
13
|
+
return effective_item_list
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const filtered = density_scheduler.filter_item_list(effective_item_list)
|
|
17
|
+
if (filtered.length > 0)
|
|
18
|
+
{
|
|
19
|
+
return filtered
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const has_stock = density_scheduler.skip_empty_groups(master_item_list)
|
|
23
|
+
if (!has_stock)
|
|
24
|
+
{
|
|
25
|
+
return []
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return density_scheduler.filter_item_list(effective_item_list)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { apply_density_group_item_filter }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a stable fingerprint from the effective item list used by the chooser and LP.
|
|
3
|
+
* @param {object[]} effective_item_list - Items exposed to the current allocation iteration.
|
|
4
|
+
* @returns {string} Sorted `id:amount` pairs joined by `|`, e.g. `3:12|7:4`.
|
|
5
|
+
*/
|
|
6
|
+
function build_effective_item_fingerprint(effective_item_list)
|
|
7
|
+
{
|
|
8
|
+
const pairs = effective_item_list
|
|
9
|
+
.map(item => `${item.get_id()}:${item.get_amount()}`)
|
|
10
|
+
.sort()
|
|
11
|
+
return pairs.join('|')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = { build_effective_item_fingerprint }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const Cargo_Profile = require('../models/Cargo_Profile')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Clears the hard SKU lock when the continuation-lock feature flag is off.
|
|
5
|
+
* @param {object} context
|
|
6
|
+
* @param {object|null} locked_item
|
|
7
|
+
* @returns {object|null}
|
|
8
|
+
*/
|
|
9
|
+
function apply_item_continuation_lock_gate(context, locked_item)
|
|
10
|
+
{
|
|
11
|
+
if (Cargo_Profile.enable_item_continuation_lock())
|
|
12
|
+
{
|
|
13
|
+
return locked_item
|
|
14
|
+
}
|
|
15
|
+
context.item_lock.release_for_density_balance()
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Updates or clears the continuation lock after a wall, honoring the feature flag.
|
|
21
|
+
* @param {object} context
|
|
22
|
+
* @param {Set<string>} single_slot_allocated_item_ids
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
function update_item_continuation_lock(context, single_slot_allocated_item_ids)
|
|
26
|
+
{
|
|
27
|
+
if (!Cargo_Profile.enable_item_continuation_lock())
|
|
28
|
+
{
|
|
29
|
+
context.item_lock.release_for_density_balance()
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
context.item_lock.update_from_iteration(single_slot_allocated_item_ids)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
apply_item_continuation_lock_gate,
|
|
37
|
+
update_item_continuation_lock
|
|
38
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {number|null|undefined} group_count - Density group count when scheduler is active.
|
|
3
|
+
* @param {boolean} compound_fallback_engaged - True after compound-first probe is skipped.
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
function compute_max_no_space_left_recoveries(group_count, compound_fallback_engaged)
|
|
7
|
+
{
|
|
8
|
+
const base = group_count ?? 1
|
|
9
|
+
if (compound_fallback_engaged)
|
|
10
|
+
{
|
|
11
|
+
return base * 2
|
|
12
|
+
}
|
|
13
|
+
return base
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {{ obligate_compound_session: { skip_compound_probe: boolean } }} chooser_session
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
function is_compound_fallback_engaged(chooser_session)
|
|
21
|
+
{
|
|
22
|
+
return chooser_session.obligate_compound_session.skip_compound_probe === true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resets skip state and enables legacy block resolution for subsequent chooser calls.
|
|
27
|
+
* @param {object} params
|
|
28
|
+
* @param {import('./space_skip_state')} params.space_skip_state
|
|
29
|
+
* @param {object} params.chooser_session
|
|
30
|
+
* @param {object|null} params.density_scheduler
|
|
31
|
+
* @param {object|null} params.locked_item
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
34
|
+
function apply_no_space_left_recovery(params)
|
|
35
|
+
{
|
|
36
|
+
params.space_skip_state.clear_stalls()
|
|
37
|
+
params.chooser_session.obligate_compound_session.skip_compound_probe = true
|
|
38
|
+
if (params.density_scheduler && !params.locked_item)
|
|
39
|
+
{
|
|
40
|
+
params.density_scheduler.advance_after_successful_wall()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
compute_max_no_space_left_recoveries,
|
|
46
|
+
is_compound_fallback_engaged,
|
|
47
|
+
apply_no_space_left_recovery
|
|
48
|
+
}
|