@jetta/blocks-allocator 0.0.0-stage → 0.1.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,49 @@
|
|
|
1
|
+
const Cargo_Profile = require('../../../models/Cargo_Profile')
|
|
2
|
+
const Cant_Stack_It_Self = require('./rules/Cant_Stack_It_Self')
|
|
3
|
+
const Almost_Unique_Item = require('./rules/Almost_Unique_Item')
|
|
4
|
+
/**
|
|
5
|
+
* @class Key_Item_Mapper
|
|
6
|
+
* @description Manages and applies rules to identify "key items" within a set of items.
|
|
7
|
+
* Key items are those that have specific allocation constraints or preferences.
|
|
8
|
+
* @see {@link file://c:/Users/amatsukan/jetta/blocks-wall-allocation/doc/how_to_add_a_key_item_rule.md}
|
|
9
|
+
*/
|
|
10
|
+
class Key_Item_Mapper
|
|
11
|
+
{
|
|
12
|
+
#rules
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @description Initializes the Key_Item_Mapper with a predefined set of rules.
|
|
17
|
+
*/
|
|
18
|
+
constructor()
|
|
19
|
+
{
|
|
20
|
+
this.#rules = [
|
|
21
|
+
new Cant_Stack_It_Self(),
|
|
22
|
+
new Almost_Unique_Item()
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @method filter_key_items
|
|
28
|
+
* @description Filters a given array of items, returning only those that are identified as "key items"
|
|
29
|
+
* based on the applied rules. An item is considered a key item if at least one rule identifies it as such.
|
|
30
|
+
*
|
|
31
|
+
* @param {object} container - The container object against which the rules are evaluated.
|
|
32
|
+
* @param {Array<object>} items - An array of item objects to be filtered.
|
|
33
|
+
* @returns {Array<object>} An array containing only the key items.
|
|
34
|
+
*/
|
|
35
|
+
filter_key_items(container, items)
|
|
36
|
+
{
|
|
37
|
+
if (!Cargo_Profile.enable_key_item_mapping())
|
|
38
|
+
{
|
|
39
|
+
return []
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const apply_rules = (item) =>
|
|
43
|
+
{
|
|
44
|
+
return this.#rules.some(rule => rule.is_key_item(container, item, items))
|
|
45
|
+
}
|
|
46
|
+
return items.filter(apply_rules)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
module.exports = Key_Item_Mapper
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const Rule_Interface = require('./Rule_Interface')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class Almost_Unique_Item
|
|
5
|
+
* @augments Rule_Interface
|
|
6
|
+
* @description Implements a rule to identify an item as a "key item" if it is unique in the list of available items.
|
|
7
|
+
*/
|
|
8
|
+
class Almost_Unique_Item extends Rule_Interface
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a given item is a key item within the context of a container.
|
|
12
|
+
*
|
|
13
|
+
* Almost_Unique_Item is item amount < 3
|
|
14
|
+
*
|
|
15
|
+
* @param {Container} container - The container object (e.g., from `src\models\Container.js`).
|
|
16
|
+
* @param {Allocation_Item} item - The item object, (e.g., from `src/models/Allocation_Item`)
|
|
17
|
+
* @param {Array<Allocation_Item>} item_list - A list of all available items to be allocated.
|
|
18
|
+
* @returns {boolean} - Returns `true` if the item is considered a key item, `false` otherwise.
|
|
19
|
+
* @throws {Error} - Throws an error if the method is not overridden by the extended class.
|
|
20
|
+
*/
|
|
21
|
+
is_key_item(container, item, item_list)
|
|
22
|
+
{
|
|
23
|
+
// An item is considered a "key item" by this rule if it is the only one of its kind in the list.
|
|
24
|
+
return item_list.filter(i => i.get_hash() === item.get_hash()).length < 3
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @module Almost_Unique_Item
|
|
30
|
+
*/
|
|
31
|
+
module.exports = Almost_Unique_Item
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const Rule_Interface = require('./Rule_Interface')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class Cant_Stack_It_Self
|
|
5
|
+
* @augments Rule_Interface
|
|
6
|
+
* @description Implements a rule to identify "key items" that cannot be stacked upon or have specific stacking restrictions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class Cant_Stack_It_Self extends Rule_Interface
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a given item is a key item within the context of a container.
|
|
13
|
+
* For this rule, an item is considered a key item if its `empilhamentoMaximo` property is 0,
|
|
14
|
+
* meaning it cannot be stacked upon.
|
|
15
|
+
*
|
|
16
|
+
* @param {Transport} transport - The transport object (e.g., from `src/models/transport/Transport.js`).
|
|
17
|
+
* @param {Allocation_Item} item - The item object, (e.g., from `src/models/Allocation_Item`)
|
|
18
|
+
* @returns {boolean} - Returns `true` if the item's `empilhamentoMaximo` is 0, `false` otherwise.
|
|
19
|
+
*/
|
|
20
|
+
is_key_item(transport, item)
|
|
21
|
+
{
|
|
22
|
+
const containers = [ ... transport.get_containers().values() ]
|
|
23
|
+
const container_heights = containers.map(container => container.get_height())
|
|
24
|
+
const bigger_container_height = Math.max(...container_heights)
|
|
25
|
+
const item_height = get_item_max_height(item)
|
|
26
|
+
const item_max_stack = item.empilhamentoMaximo ? item.empilhamentoMaximo : item.get_stacking_info().max_stacking
|
|
27
|
+
const item_weight = item.peso ? item.peso : item.get_stacking_info().weight
|
|
28
|
+
const item_max_load_weight = item.pesoMaxSuportado ? item.pesoMaxSuportado : item.get_stacking_info().supported_weight
|
|
29
|
+
|
|
30
|
+
const conditions =
|
|
31
|
+
[
|
|
32
|
+
item_max_load_weight < item_weight,
|
|
33
|
+
item_max_stack === 0,
|
|
34
|
+
item_height * 2 > bigger_container_height
|
|
35
|
+
]
|
|
36
|
+
return conditions.some(condition => condition)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const get_height = (item) =>
|
|
41
|
+
{
|
|
42
|
+
if (item.altura !== undefined)
|
|
43
|
+
{
|
|
44
|
+
return item.altura
|
|
45
|
+
}
|
|
46
|
+
if (typeof item.get_height === 'function')
|
|
47
|
+
{
|
|
48
|
+
return item.get_height()
|
|
49
|
+
}
|
|
50
|
+
throw Error('Not possible to find item height')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function get_item_max_height(item)
|
|
54
|
+
{
|
|
55
|
+
const rotation_options = item.get_all_rotated_options()
|
|
56
|
+
if (rotation_options === undefined || rotation_options.length === 0)
|
|
57
|
+
{
|
|
58
|
+
throw new Error('item has no rotations')
|
|
59
|
+
}
|
|
60
|
+
const item_possible_heights = rotation_options.map(get_height)
|
|
61
|
+
const item_height = Math.max(...item_possible_heights)
|
|
62
|
+
return item_height
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @module Cant_Stack_It_Self
|
|
67
|
+
*/
|
|
68
|
+
module.exports = Cant_Stack_It_Self
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @interface Rule_Interface
|
|
3
|
+
* @description Defines the contract for rules that identify "key items" within an allocation context.
|
|
4
|
+
* All concrete rule implementations must extend this interface and implement the `is_key_item` method.
|
|
5
|
+
* @see {@link file://c:/Users/amatsukan/jetta/blocks-wall-allocation/doc/how_to_add_a_key_item_rule.md}
|
|
6
|
+
*/
|
|
7
|
+
class Rule_Interface
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a given item is a key item within the context of a container.
|
|
12
|
+
* This is a pure virtual method that must be implemented by any class extending Rule_Interface.
|
|
13
|
+
*
|
|
14
|
+
* @param {Container} container - The container object (e.g., from `src\models\Container.js`).
|
|
15
|
+
* @param {Allocation_Item} item - The item object, (e.g., from `src/models/Allocation_Item`)
|
|
16
|
+
* @param {Array<Allocation_Item>} item_list - A list of all available items to be allocated.
|
|
17
|
+
* @returns {boolean} - Returns `true` if the item is considered a key item, `false` otherwise.
|
|
18
|
+
* @throws {Error} - Throws an error if the method is not overridden by the extended class.
|
|
19
|
+
*/
|
|
20
|
+
is_key_item(container, item, item_list)
|
|
21
|
+
{
|
|
22
|
+
throw new Error('Not overrided pure virtual method, please implement on your extended class')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = Rule_Interface
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const ORIENTATION_SEQUENCE = ['3_2', '2_3']
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tracks required tie-ratio orientation for intercalated wall allocation per container.
|
|
5
|
+
*/
|
|
6
|
+
class Tie_Ratio_Intercalation_State
|
|
7
|
+
{
|
|
8
|
+
#allocate_intercalated
|
|
9
|
+
#next_orientation_index = 0
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {boolean} allocate_intercalated - Whether intercalation alternation is enabled.
|
|
13
|
+
*/
|
|
14
|
+
constructor(allocate_intercalated)
|
|
15
|
+
{
|
|
16
|
+
this.#allocate_intercalated = allocate_intercalated === true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
reset()
|
|
20
|
+
{
|
|
21
|
+
this.#next_orientation_index = 0
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @returns {'3_2'|'2_3'|null} Required orientation, or null when intercalation is disabled.
|
|
26
|
+
*/
|
|
27
|
+
get_required_orientation()
|
|
28
|
+
{
|
|
29
|
+
if (!this.#allocate_intercalated)
|
|
30
|
+
{
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
return ORIENTATION_SEQUENCE[this.#next_orientation_index]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Toggles orientation after a wall that placed at least one tie-ratio block.
|
|
38
|
+
*/
|
|
39
|
+
advance_after_tie_ratio_wall()
|
|
40
|
+
{
|
|
41
|
+
if (!this.#allocate_intercalated)
|
|
42
|
+
{
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
this.#next_orientation_index = (this.#next_orientation_index + 1) % ORIENTATION_SEQUENCE.length
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = Tie_Ratio_Intercalation_State
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const Block_Filter_Interface = require('../../space_and_block_chooser/blocks_filters/Block_Filter_Interface')
|
|
2
|
+
const Cargo_Profile = require('../../models/Cargo_Profile')
|
|
3
|
+
const filter_blocks_by_orientation = require('./filter_blocks_by_orientation')
|
|
4
|
+
const { empty_space_stacks_on_tie_ratio_supporter } = require('./tie_ratio_orientation_below_empty_space')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Post-selection filter: tie-ratio blocks must match the next intercalated orientation along Z.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = class Tie_Ratio_Orientation_Filter extends Block_Filter_Interface
|
|
10
|
+
{
|
|
11
|
+
static run(filter_data)
|
|
12
|
+
{
|
|
13
|
+
if (!Cargo_Profile.allocate_intercalated())
|
|
14
|
+
{
|
|
15
|
+
return filter_data.block_list
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (empty_space_stacks_on_tie_ratio_supporter(filter_data))
|
|
19
|
+
{
|
|
20
|
+
return filter_data.block_list
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const required_orientation = filter_data.tie_ratio_intercalation_state
|
|
24
|
+
?.get_required_orientation() ?? null
|
|
25
|
+
|
|
26
|
+
if (required_orientation === null)
|
|
27
|
+
{
|
|
28
|
+
return filter_data.block_list
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return filter_blocks_by_orientation(filter_data.block_list, required_orientation)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const Block_Filter_Interface = require('../../space_and_block_chooser/blocks_filters/Block_Filter_Interface')
|
|
2
|
+
const filter_blocks_by_orientation = require('./filter_blocks_by_orientation')
|
|
3
|
+
const tie_ratio_orientation_below_empty_space = require('./tie_ratio_orientation_below_empty_space')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Post-selection filter: stacked tie-ratio blocks must match orientation below the space.
|
|
7
|
+
*/
|
|
8
|
+
module.exports = class Tie_Ratio_Vertical_Stack_Filter extends Block_Filter_Interface
|
|
9
|
+
{
|
|
10
|
+
static run(filter_data)
|
|
11
|
+
{
|
|
12
|
+
const stack_orientation = tie_ratio_orientation_below_empty_space(filter_data)
|
|
13
|
+
if (stack_orientation === undefined)
|
|
14
|
+
{
|
|
15
|
+
return filter_data.block_list
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return filter_blocks_by_orientation(filter_data.block_list, stack_orientation)
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/Allocation_Optimization/tie_ratio/collect_tie_ratio_orientations_below_footprint.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const math = require('@jetta/number-compare')
|
|
2
|
+
const { supporters_at_top_y } = require('./supporters_by_top_y_index')
|
|
3
|
+
const { footprint_overlap_on_space } = require('./loose_on_block/tie_ratio_footprint_overlap')
|
|
4
|
+
const {
|
|
5
|
+
build_tie_ratio_orientation_by_group_id,
|
|
6
|
+
tie_ratio_orientation_from_item
|
|
7
|
+
} = require('./tie_ratio_orientation_from_group')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} container
|
|
11
|
+
* @param {object} empty_space
|
|
12
|
+
* @param {import('./supporters_by_top_y_index').Supporters_By_Top_Y_Index|undefined} supporters_by_top_y_index
|
|
13
|
+
* @returns {Array<'3_2'|'2_3'>}
|
|
14
|
+
*/
|
|
15
|
+
function collect_tie_ratio_orientations_below_footprint(
|
|
16
|
+
container,
|
|
17
|
+
empty_space,
|
|
18
|
+
supporters_by_top_y_index
|
|
19
|
+
)
|
|
20
|
+
{
|
|
21
|
+
if (!empty_space || empty_space.get_y() <= 0)
|
|
22
|
+
{
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const space_bottom = empty_space.get_y()
|
|
27
|
+
const candidate_items = resolve_candidate_items(
|
|
28
|
+
container,
|
|
29
|
+
supporters_by_top_y_index,
|
|
30
|
+
space_bottom
|
|
31
|
+
)
|
|
32
|
+
const orientation_by_group_id = build_tie_ratio_orientation_by_group_id(
|
|
33
|
+
container.get_allocated_items?.() ?? []
|
|
34
|
+
)
|
|
35
|
+
const orientations = new Set()
|
|
36
|
+
for (const item of candidate_items)
|
|
37
|
+
{
|
|
38
|
+
if (footprint_overlap_on_space(item, empty_space) <= 0)
|
|
39
|
+
{
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
const orientation = tie_ratio_orientation_from_item(item, orientation_by_group_id)
|
|
43
|
+
if (orientation === '3_2' || orientation === '2_3')
|
|
44
|
+
{
|
|
45
|
+
orientations.add(orientation)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return [...orientations]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function resolve_candidate_items(container, supporters_by_top_y_index, space_bottom)
|
|
52
|
+
{
|
|
53
|
+
if (supporters_by_top_y_index !== undefined)
|
|
54
|
+
{
|
|
55
|
+
return supporters_at_top_y(supporters_by_top_y_index, space_bottom)
|
|
56
|
+
}
|
|
57
|
+
return container.get_allocated_items().filter(item =>
|
|
58
|
+
math.eq(item.get_y() + item.get_height(), space_bottom)
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = {
|
|
63
|
+
collect_tie_ratio_orientations_below_footprint
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps non-tie-ratio blocks and tie-ratio blocks matching the required orientation.
|
|
3
|
+
* @param {object[]} block_list
|
|
4
|
+
* @param {'3_2'|'2_3'} required_orientation
|
|
5
|
+
* @returns {object[]}
|
|
6
|
+
*/
|
|
7
|
+
module.exports = function filter_blocks_by_orientation(block_list, required_orientation)
|
|
8
|
+
{
|
|
9
|
+
return block_list.filter(block =>
|
|
10
|
+
{
|
|
11
|
+
if (!block.is_tie_ratio_block())
|
|
12
|
+
{
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
return block.get_tie_ratio_orientation() === required_orientation
|
|
16
|
+
})
|
|
17
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const math = require('@jetta/number-compare')
|
|
2
|
+
const { supporters_at_top_y } = require('./supporters_by_top_y_index')
|
|
3
|
+
const { footprint_overlap_on_space } = require('./loose_on_block/tie_ratio_footprint_overlap')
|
|
4
|
+
const {
|
|
5
|
+
build_tie_ratio_orientation_by_group_id,
|
|
6
|
+
tie_ratio_orientation_from_item
|
|
7
|
+
} = require('./tie_ratio_orientation_from_group')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Finds tie-ratio orientation of a compound block directly under an empty space footprint.
|
|
11
|
+
* @param {object} container - Container with allocated items.
|
|
12
|
+
* @param {object|undefined} empty_space - Candidate empty space (may be undefined during pre-selection).
|
|
13
|
+
* @param {import('./supporters_by_top_y_index').Supporters_By_Top_Y_Index|undefined} supporters_by_top_y_index
|
|
14
|
+
* @returns {'3_2'|'2_3'|undefined}
|
|
15
|
+
*/
|
|
16
|
+
module.exports = function find_orientation_below_space(
|
|
17
|
+
container,
|
|
18
|
+
empty_space,
|
|
19
|
+
supporters_by_top_y_index
|
|
20
|
+
)
|
|
21
|
+
{
|
|
22
|
+
if (!empty_space || empty_space.get_y() <= 0)
|
|
23
|
+
{
|
|
24
|
+
return undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const allocated_items = container.get_allocated_items?.() ?? []
|
|
28
|
+
const orientation_by_group_id = build_tie_ratio_orientation_by_group_id(allocated_items)
|
|
29
|
+
const space_bottom = empty_space.get_y()
|
|
30
|
+
const candidate_items = resolve_candidate_items(
|
|
31
|
+
container,
|
|
32
|
+
supporters_by_top_y_index,
|
|
33
|
+
space_bottom
|
|
34
|
+
)
|
|
35
|
+
return orientation_from_candidates(
|
|
36
|
+
candidate_items,
|
|
37
|
+
empty_space,
|
|
38
|
+
orientation_by_group_id
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function resolve_candidate_items(container, supporters_by_top_y_index, space_bottom)
|
|
43
|
+
{
|
|
44
|
+
if (supporters_by_top_y_index !== undefined)
|
|
45
|
+
{
|
|
46
|
+
return supporters_at_top_y(supporters_by_top_y_index, space_bottom)
|
|
47
|
+
}
|
|
48
|
+
return container.get_allocated_items().filter(item =>
|
|
49
|
+
math.eq(item.get_y() + item.get_height(), space_bottom)
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function orientation_from_candidates(candidate_items, empty_space, orientation_by_group_id)
|
|
54
|
+
{
|
|
55
|
+
let best_orientation = undefined
|
|
56
|
+
let best_footprint_overlap = -1
|
|
57
|
+
for (const item of candidate_items)
|
|
58
|
+
{
|
|
59
|
+
const footprint_overlap = footprint_overlap_on_space(item, empty_space)
|
|
60
|
+
if (footprint_overlap <= 0)
|
|
61
|
+
{
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
const orientation = tie_ratio_orientation_from_item(item, orientation_by_group_id)
|
|
65
|
+
if (orientation === undefined)
|
|
66
|
+
{
|
|
67
|
+
continue
|
|
68
|
+
}
|
|
69
|
+
if (footprint_overlap <= best_footprint_overlap)
|
|
70
|
+
{
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
best_footprint_overlap = footprint_overlap
|
|
74
|
+
best_orientation = orientation
|
|
75
|
+
}
|
|
76
|
+
return best_orientation
|
|
77
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when two axis-aligned allocated items occupy the same volume.
|
|
3
|
+
* @param {object} left
|
|
4
|
+
* @param {object} right
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
function allocated_items_penetrate(left, right)
|
|
8
|
+
{
|
|
9
|
+
const overlap_x = Math.min(left.get_x() + left.get_width(), right.get_x() + right.get_width())
|
|
10
|
+
- Math.max(left.get_x(), right.get_x())
|
|
11
|
+
const overlap_y = Math.min(left.get_y() + left.get_height(), right.get_y() + right.get_height())
|
|
12
|
+
- Math.max(left.get_y(), right.get_y())
|
|
13
|
+
const overlap_z = Math.min(left.get_z() + left.get_length(), right.get_z() + right.get_length())
|
|
14
|
+
- Math.max(left.get_z(), right.get_z())
|
|
15
|
+
return overlap_x > 1e-6 && overlap_y > 1e-6 && overlap_z > 1e-6
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* True when the candidate penetrates any other occupant.
|
|
20
|
+
* @param {object} candidate
|
|
21
|
+
* @param {object[]} occupants
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
function allocated_item_penetrates_any(candidate, occupants)
|
|
25
|
+
{
|
|
26
|
+
return occupants.some(occupant =>
|
|
27
|
+
occupant !== candidate && allocated_items_penetrate(candidate, occupant)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = allocated_item_penetrates_any
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const Cargo_Profile = require('../../../models/Cargo_Profile')
|
|
2
|
+
const find_tie_ratio_supporter_cluster = require('./find_tie_ratio_supporter_cluster')
|
|
3
|
+
const resolve_loose_placement_position = require('./resolve_loose_placement_position')
|
|
4
|
+
const container_with_pending_wall_items = require('./container_with_pending_wall_items')
|
|
5
|
+
const {
|
|
6
|
+
resolve_without_tie_ratio_cluster,
|
|
7
|
+
finalize_placement_coords
|
|
8
|
+
} = require('./resolve_without_tie_ratio_cluster')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Realigns a placed loose item to a tie-ratio slot when valid.
|
|
12
|
+
* @param {object} allocated_item
|
|
13
|
+
* @param {object} container
|
|
14
|
+
* @param {object} empty_space
|
|
15
|
+
* @param {object} slot_state
|
|
16
|
+
* @param {object|undefined} supporters_by_top_y_index
|
|
17
|
+
* @param {object[]|undefined} pending_wall_allocated_items
|
|
18
|
+
* @returns {object|undefined}
|
|
19
|
+
*/
|
|
20
|
+
function apply_loose_placement_to_allocated_item(
|
|
21
|
+
allocated_item,
|
|
22
|
+
container,
|
|
23
|
+
empty_space,
|
|
24
|
+
slot_state,
|
|
25
|
+
supporters_by_top_y_index,
|
|
26
|
+
pending_wall_allocated_items
|
|
27
|
+
)
|
|
28
|
+
{
|
|
29
|
+
const allocation_item = allocated_item.get_stacking_source_item()
|
|
30
|
+
const container_view = container_with_pending_wall_items(
|
|
31
|
+
container,
|
|
32
|
+
pending_wall_allocated_items
|
|
33
|
+
)
|
|
34
|
+
const placement_options = {
|
|
35
|
+
item_width: allocated_item.get_width(),
|
|
36
|
+
item_length: allocated_item.get_length(),
|
|
37
|
+
item_height: allocated_item.get_height(),
|
|
38
|
+
require_same_area: Cargo_Profile.stack_loose_on_tie_ratio_blocks(),
|
|
39
|
+
loose_origin_x: allocated_item.get_x(),
|
|
40
|
+
loose_origin_z: allocated_item.get_z()
|
|
41
|
+
}
|
|
42
|
+
const cluster = find_tie_ratio_supporter_cluster(
|
|
43
|
+
container_view,
|
|
44
|
+
empty_space,
|
|
45
|
+
supporters_by_top_y_index,
|
|
46
|
+
allocated_item.get_y(),
|
|
47
|
+
placement_options
|
|
48
|
+
)
|
|
49
|
+
if (cluster === undefined)
|
|
50
|
+
{
|
|
51
|
+
return resolve_without_tie_ratio_cluster(
|
|
52
|
+
allocated_item,
|
|
53
|
+
container,
|
|
54
|
+
container_view,
|
|
55
|
+
empty_space,
|
|
56
|
+
slot_state,
|
|
57
|
+
placement_options,
|
|
58
|
+
allocation_item
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
const placement = resolve_loose_placement_position(
|
|
62
|
+
container_view,
|
|
63
|
+
empty_space,
|
|
64
|
+
slot_state,
|
|
65
|
+
supporters_by_top_y_index,
|
|
66
|
+
placement_options,
|
|
67
|
+
allocated_item.get_y(),
|
|
68
|
+
cluster
|
|
69
|
+
)
|
|
70
|
+
if (placement !== undefined)
|
|
71
|
+
{
|
|
72
|
+
const tied_item = finalize_placement_coords(
|
|
73
|
+
container,
|
|
74
|
+
container_view,
|
|
75
|
+
allocation_item,
|
|
76
|
+
placement
|
|
77
|
+
)
|
|
78
|
+
if (tied_item !== undefined)
|
|
79
|
+
{
|
|
80
|
+
return tied_item
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return resolve_without_tie_ratio_cluster(
|
|
84
|
+
allocated_item,
|
|
85
|
+
container,
|
|
86
|
+
container_view,
|
|
87
|
+
empty_space,
|
|
88
|
+
slot_state,
|
|
89
|
+
placement_options,
|
|
90
|
+
allocation_item
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = apply_loose_placement_to_allocated_item
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns overlap length on a single axis between two ranges.
|
|
3
|
+
* @param {number} start_a
|
|
4
|
+
* @param {number} end_a
|
|
5
|
+
* @param {number} start_b
|
|
6
|
+
* @param {number} end_b
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
function axis_overlap_length(start_a, end_a, start_b, end_b)
|
|
10
|
+
{
|
|
11
|
+
const overlap_start = Math.max(start_a, start_b)
|
|
12
|
+
const overlap_end = Math.min(end_a, end_b)
|
|
13
|
+
return Math.max(0, overlap_end - overlap_start)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = axis_overlap_length
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the local origin (min x, min z) of a supporter cluster.
|
|
3
|
+
* @param {object[]} cluster_items
|
|
4
|
+
* @returns {{ min_x: number, min_z: number }}
|
|
5
|
+
*/
|
|
6
|
+
function block_local_origin(cluster_items)
|
|
7
|
+
{
|
|
8
|
+
let min_x = Infinity
|
|
9
|
+
let min_z = Infinity
|
|
10
|
+
for (const item of cluster_items)
|
|
11
|
+
{
|
|
12
|
+
min_x = Math.min(min_x, item.get_x())
|
|
13
|
+
min_z = Math.min(min_z, item.get_z())
|
|
14
|
+
}
|
|
15
|
+
return { min_x, min_z }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = block_local_origin
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const math = require('@jetta/number-compare')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {object|undefined} container
|
|
5
|
+
* @param {number} origin_x
|
|
6
|
+
* @param {number} origin_y
|
|
7
|
+
* @param {number} origin_z
|
|
8
|
+
* @param {number} item_width
|
|
9
|
+
* @param {number} item_height
|
|
10
|
+
* @param {number} item_length
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
function box_fits_inside_container(
|
|
14
|
+
container,
|
|
15
|
+
origin_x,
|
|
16
|
+
origin_y,
|
|
17
|
+
origin_z,
|
|
18
|
+
item_width,
|
|
19
|
+
item_height,
|
|
20
|
+
item_length
|
|
21
|
+
)
|
|
22
|
+
{
|
|
23
|
+
if (container === undefined || typeof container.get_width !== 'function')
|
|
24
|
+
{
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
if (math.lt(origin_x, 0) || math.lt(origin_y, 0) || math.lt(origin_z, 0))
|
|
28
|
+
{
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
const end_x = origin_x + item_width
|
|
32
|
+
const end_y = origin_y + item_height
|
|
33
|
+
const end_z = origin_z + item_length
|
|
34
|
+
return math.le(end_x, container.get_width())
|
|
35
|
+
&& math.le(end_y, container.get_height())
|
|
36
|
+
&& math.le(end_z, container.get_length())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = box_fits_inside_container
|
package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_allocated_item_at_placement.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const Allocated_Item = require('../../../models/Allocated_Item')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} allocation_item
|
|
5
|
+
* @param {{ x: number, y: number, z: number }} placement
|
|
6
|
+
* @returns {object}
|
|
7
|
+
*/
|
|
8
|
+
function build_allocated_item_at_placement(allocation_item, placement)
|
|
9
|
+
{
|
|
10
|
+
return new Allocated_Item(
|
|
11
|
+
allocation_item,
|
|
12
|
+
placement.x,
|
|
13
|
+
placement.y,
|
|
14
|
+
placement.z
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = build_allocated_item_at_placement
|