@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,162 @@
|
|
|
1
|
+
const { Space, EmptySpaceFinder } = require('@jetta/empty-spaces-manager')
|
|
2
|
+
const create_input = require('../../Allocation_Optimization/block_builder/Stacking_Validation')
|
|
3
|
+
const items_for_empty_space_finder = require('./items_for_empty_space_finder')
|
|
4
|
+
const {
|
|
5
|
+
define_stacking_cell_size,
|
|
6
|
+
build_stacking_feasibility_checker
|
|
7
|
+
} = require('./build_stacking_feasibility_checker')
|
|
8
|
+
const {
|
|
9
|
+
ensure_stacking_checkpoint,
|
|
10
|
+
restore_stacking_checker_after_discard
|
|
11
|
+
} = require('./container_stacking_checkpoint')
|
|
12
|
+
const { traced_step_sync } = require('../../tracing/traced_step')
|
|
13
|
+
const { TRACE_CONTEXT } = require('../../tracing/Trace_Context')
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {object} Container_Constructor_Data
|
|
17
|
+
* @property {string} id - Identifier associated with this physical container (often transport `_id`).
|
|
18
|
+
* @property {number} width - Interior width.
|
|
19
|
+
* @property {number} height - Interior height.
|
|
20
|
+
* @property {number} length - Interior length.
|
|
21
|
+
* @property {number} supported_weight - Maximum cargo weight the container may carry.
|
|
22
|
+
* @property {Array<object>} allocated_item_list - Already placed items; may be empty.
|
|
23
|
+
* @property {Array<object>} corner_casting_list - Corner castings passed to {@link EmptySpaceFinder}.
|
|
24
|
+
* @property {object|undefined} empty_space_finder_options - Optional `{ merge_tolerance }` (width=X, length=Z, vertical in domain units).
|
|
25
|
+
* @property {object[]|undefined} preloaded_stacking_inputs - Wire-derived stacking DTOs for preloaded cargo.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Shipping container as a {@link Space} with empty-space tracking and weight capacity.
|
|
30
|
+
*/
|
|
31
|
+
class Container extends Space
|
|
32
|
+
{
|
|
33
|
+
#id
|
|
34
|
+
#allocated_item_list = []
|
|
35
|
+
#supported_weight_limit
|
|
36
|
+
#stacking_feasibility_checker
|
|
37
|
+
#stacking_cell_size
|
|
38
|
+
#stacking_checkpoint = null
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {Container_Constructor_Data} data - Geometry, capacity, corner castings, and pre-loaded items.
|
|
42
|
+
* Pre-loaded items with the same `groupId` are collapsed to one bounding box for empty-space initialization.
|
|
43
|
+
*/
|
|
44
|
+
constructor(data)
|
|
45
|
+
{
|
|
46
|
+
super({ x: 0, y: 0, z: 0, width: data.width, height: data.height, length: data.length })
|
|
47
|
+
this.#id = data.id
|
|
48
|
+
this.#supported_weight_limit = data.supported_weight
|
|
49
|
+
this.finder = new EmptySpaceFinder(
|
|
50
|
+
this,
|
|
51
|
+
data.corner_casting_list,
|
|
52
|
+
data.empty_space_finder_options
|
|
53
|
+
)
|
|
54
|
+
this.find_empty_spaces(items_for_empty_space_finder(data.allocated_item_list))
|
|
55
|
+
this.merge_item_list(data.allocated_item_list)
|
|
56
|
+
this.#stacking_cell_size = define_stacking_cell_size(this, data.item_list)
|
|
57
|
+
this.#stacking_feasibility_checker = build_stacking_feasibility_checker({
|
|
58
|
+
cell_size: this.#stacking_cell_size,
|
|
59
|
+
preloaded_stacking_inputs: data.preloaded_stacking_inputs,
|
|
60
|
+
allocated_item_list: data.allocated_item_list
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
supported_weight()
|
|
65
|
+
{
|
|
66
|
+
if (this.#allocated_item_list.length === 0)
|
|
67
|
+
{
|
|
68
|
+
return this.#supported_weight_limit
|
|
69
|
+
}
|
|
70
|
+
const loaded_weight = this.#allocated_item_list.reduce((sum, cur) => sum + cur.get_weight(), 0)
|
|
71
|
+
return this.#supported_weight_limit - loaded_weight
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Validates stacking. On success, `@jetta/stacking-constraints` commits the candidate into the index.
|
|
76
|
+
* Call {@link discard_provisional_stackings} if the wall/attempt that used this check is aborted.
|
|
77
|
+
* @param {object} item - Allocated item (or compatible) to validate.
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
is_a_valid_stacking(item)
|
|
81
|
+
{
|
|
82
|
+
this.#stacking_checkpoint = ensure_stacking_checkpoint(
|
|
83
|
+
this.#stacking_checkpoint,
|
|
84
|
+
this.#stacking_feasibility_checker
|
|
85
|
+
)
|
|
86
|
+
const item_data = create_input(item)
|
|
87
|
+
return this.#stacking_feasibility_checker.validate_stackings(item_data)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Drops provisional stacking commits left by failed slot/wall attempts.
|
|
92
|
+
* Restores the pre-attempt checkpoint when stacking was touched; otherwise a no-op.
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
95
|
+
discard_provisional_stackings()
|
|
96
|
+
{
|
|
97
|
+
const restored = restore_stacking_checker_after_discard(
|
|
98
|
+
this.#stacking_checkpoint,
|
|
99
|
+
this.#stacking_feasibility_checker
|
|
100
|
+
)
|
|
101
|
+
this.#stacking_feasibility_checker = restored.checker
|
|
102
|
+
this.#stacking_checkpoint = restored.checkpoint
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Registers an allocated item in the stacking index (used by loose-on-block finalize).
|
|
108
|
+
* @param {object} item
|
|
109
|
+
* @returns {boolean}
|
|
110
|
+
*/
|
|
111
|
+
commit_allocated_item_for_stacking(item)
|
|
112
|
+
{
|
|
113
|
+
this.#stacking_checkpoint = ensure_stacking_checkpoint(
|
|
114
|
+
this.#stacking_checkpoint,
|
|
115
|
+
this.#stacking_feasibility_checker
|
|
116
|
+
)
|
|
117
|
+
return this.#stacking_feasibility_checker.validate_stackings(create_input(item))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
merge_item_list(item_list)
|
|
121
|
+
{
|
|
122
|
+
this.#allocated_item_list.push(...item_list)
|
|
123
|
+
this.#stacking_checkpoint = null
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
find_empty_spaces(item_list)
|
|
127
|
+
{
|
|
128
|
+
traced_step_sync(TRACE_CONTEXT.MAP_EMPTY_SPACES, () =>
|
|
129
|
+
{
|
|
130
|
+
this.finder.allocate_item_list(item_list)
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
add_item(item)
|
|
135
|
+
{
|
|
136
|
+
this.#allocated_item_list.push(item)
|
|
137
|
+
this.finder.allocate_item(item)
|
|
138
|
+
this.#stacking_checkpoint = null
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
empty_spaces()
|
|
142
|
+
{
|
|
143
|
+
return this.finder.empty_spaces()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
has_space(items)
|
|
147
|
+
{
|
|
148
|
+
return items.some(item => this.fits_rotated_item(item))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
get_id()
|
|
152
|
+
{
|
|
153
|
+
return this.#id
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get_allocated_items()
|
|
157
|
+
{
|
|
158
|
+
return this.#allocated_item_list
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = Container
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const create_container_map = require('./factory/Container_Factory')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* In-memory representation of one transport environment: a map of sequence → container model.
|
|
5
|
+
*/
|
|
6
|
+
class Transport
|
|
7
|
+
{
|
|
8
|
+
#containers = new Map()
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} transport_data - First element shape from `input_data.envs` (includes `containers` array).
|
|
11
|
+
* @param {object|undefined} empty_space_finder_options - Optional merge tolerance for each {@link Container} finder.
|
|
12
|
+
*/
|
|
13
|
+
constructor(data)
|
|
14
|
+
{
|
|
15
|
+
this.#containers = create_container_map(data)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @returns {Map<number, object>} Container instances keyed by `sequencia`.
|
|
20
|
+
*/
|
|
21
|
+
get_containers()
|
|
22
|
+
{
|
|
23
|
+
return this.#containers
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @returns {number} Number of containers in this transport.
|
|
28
|
+
*/
|
|
29
|
+
container_amount()
|
|
30
|
+
{
|
|
31
|
+
return this.#containers.size
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {number} sequence - Container `sequencia` from input data.
|
|
36
|
+
* @returns {object} The matching container instance.
|
|
37
|
+
* @throws {Error} When no container exists for the sequence.
|
|
38
|
+
*/
|
|
39
|
+
get_container_by_sequence(sequence)
|
|
40
|
+
{
|
|
41
|
+
if (this.#containers.has(sequence))
|
|
42
|
+
{
|
|
43
|
+
return this.#containers.get(sequence)
|
|
44
|
+
}
|
|
45
|
+
throw new Error('there is no container with sequence ' + sequence)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Sorted list of container sequences (ascending).
|
|
50
|
+
* @returns {number[]}
|
|
51
|
+
*/
|
|
52
|
+
get_container_sequence_list()
|
|
53
|
+
{
|
|
54
|
+
const keys = Array.from(this.#containers.keys())
|
|
55
|
+
const sorted = keys.sort((a, b) => a - b)
|
|
56
|
+
return sorted
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = Transport
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const { StackingFeasibilityChecker } = require('@jetta/stacking-constraints')
|
|
2
|
+
const create_input = require('../../Allocation_Optimization/block_builder/Stacking_Validation')
|
|
3
|
+
const resolve_container_stacking_inputs = require('./resolve_container_stacking_inputs')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves uniform grid cell size from cargo item footprints, else container plan dimensions.
|
|
7
|
+
* @param {object} container_space - Space with get_width() and get_length().
|
|
8
|
+
* @param {object[]|undefined} item_list - Items exposing get_width() and get_length().
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
function define_stacking_cell_size(container_space, item_list)
|
|
12
|
+
{
|
|
13
|
+
const list = item_list ?? []
|
|
14
|
+
if (list.length === 0)
|
|
15
|
+
{
|
|
16
|
+
return Math.max(container_space.get_width(), container_space.get_length())
|
|
17
|
+
}
|
|
18
|
+
const widths = list.map(item => item.get_width())
|
|
19
|
+
const lengths = list.map(item => item.get_length())
|
|
20
|
+
return Math.max(...widths, ...lengths)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Builds the stacking index from wire DTOs or allocated items.
|
|
25
|
+
* @param {object} data - Constructor bag plus resolved cell size.
|
|
26
|
+
* @param {number} data.cell_size - Fallback cell size when no allocated stacking inputs exist.
|
|
27
|
+
* @param {object[]|undefined} data.preloaded_stacking_inputs - Wire-derived stacking DTOs.
|
|
28
|
+
* @param {object[]} data.allocated_item_list - Committed allocated items.
|
|
29
|
+
* @returns {StackingFeasibilityChecker}
|
|
30
|
+
*/
|
|
31
|
+
function build_stacking_feasibility_checker(data)
|
|
32
|
+
{
|
|
33
|
+
const stacking_inputs = resolve_container_stacking_inputs(
|
|
34
|
+
data.preloaded_stacking_inputs,
|
|
35
|
+
data.allocated_item_list
|
|
36
|
+
)
|
|
37
|
+
if (stacking_inputs.length === 0)
|
|
38
|
+
{
|
|
39
|
+
return new StackingFeasibilityChecker(data.cell_size)
|
|
40
|
+
}
|
|
41
|
+
return StackingFeasibilityChecker.from_allocated(stacking_inputs)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Rebuilds the stacking index from committed allocated items only (drops provisional validates).
|
|
46
|
+
* @param {object[]} allocated_item_list - Items already committed on the container.
|
|
47
|
+
* @param {number} cell_size - Cell size used when the list is empty.
|
|
48
|
+
* @returns {StackingFeasibilityChecker}
|
|
49
|
+
*/
|
|
50
|
+
function stacking_checker_from_allocated_items(allocated_item_list, cell_size)
|
|
51
|
+
{
|
|
52
|
+
if (allocated_item_list.length === 0)
|
|
53
|
+
{
|
|
54
|
+
return new StackingFeasibilityChecker(cell_size)
|
|
55
|
+
}
|
|
56
|
+
const stacking_inputs = allocated_item_list.map(allocated => create_input(allocated))
|
|
57
|
+
return StackingFeasibilityChecker.from_allocated(stacking_inputs)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
define_stacking_cell_size,
|
|
62
|
+
build_stacking_feasibility_checker,
|
|
63
|
+
stacking_checker_from_allocated_items
|
|
64
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy stacking-index checkpoint helpers for cheap provisional discard.
|
|
3
|
+
* Baseline is a structural clone taken before the first validate of an attempt.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {object|null} stacking_checkpoint - Prior baseline clone, if any.
|
|
8
|
+
* @param {object} stacking_feasibility_checker - Live checker to snapshot.
|
|
9
|
+
* @returns {object} Existing or newly cloned baseline
|
|
10
|
+
*/
|
|
11
|
+
function ensure_stacking_checkpoint(stacking_checkpoint, stacking_feasibility_checker)
|
|
12
|
+
{
|
|
13
|
+
if (stacking_checkpoint != null)
|
|
14
|
+
{
|
|
15
|
+
return stacking_checkpoint
|
|
16
|
+
}
|
|
17
|
+
return stacking_feasibility_checker.clone()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Restores the live checker from a checkpoint when provisionals may exist.
|
|
22
|
+
* If there is no checkpoint, stacking was not mutated — return the live checker unchanged.
|
|
23
|
+
* @param {object|null} stacking_checkpoint - Baseline for this attempt, if any.
|
|
24
|
+
* @param {object} stacking_feasibility_checker - Current live checker.
|
|
25
|
+
* @returns {{ checker: object, checkpoint: null }}
|
|
26
|
+
*/
|
|
27
|
+
function restore_stacking_checker_after_discard(
|
|
28
|
+
stacking_checkpoint,
|
|
29
|
+
stacking_feasibility_checker
|
|
30
|
+
)
|
|
31
|
+
{
|
|
32
|
+
if (stacking_checkpoint != null)
|
|
33
|
+
{
|
|
34
|
+
return { checker: stacking_checkpoint, checkpoint: null }
|
|
35
|
+
}
|
|
36
|
+
return { checker: stacking_feasibility_checker, checkpoint: null }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
ensure_stacking_checkpoint,
|
|
41
|
+
restore_stacking_checker_after_discard
|
|
42
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const create_allocated_item_list = require('./Previously_Allocated_Item_Factory')
|
|
2
|
+
const create_corner_castings = require('./Corner_Casting_Factory')
|
|
3
|
+
const Container = require('../Container')
|
|
4
|
+
const { build_stacking_inputs_from_wire_list } = require('../stacking_input_from_wire')
|
|
5
|
+
|
|
6
|
+
function create_container_data(data)
|
|
7
|
+
{
|
|
8
|
+
const {transport_data, container_data, empty_space_finder_options, item_list} = data
|
|
9
|
+
const allocated_item_list = create_allocated_item_list(container_data.items)
|
|
10
|
+
const preloaded_stacking_inputs = build_stacking_inputs_from_wire_list(container_data.items ?? [])
|
|
11
|
+
const corner_casting_list = create_corner_castings(transport_data, container_data)
|
|
12
|
+
return new Container({
|
|
13
|
+
id: transport_data._id,
|
|
14
|
+
width: container_data.largura,
|
|
15
|
+
height: container_data.altura,
|
|
16
|
+
length: container_data.comprimento,
|
|
17
|
+
supported_weight: container_data.pesoDeCarga,
|
|
18
|
+
allocated_item_list: allocated_item_list,
|
|
19
|
+
preloaded_stacking_inputs,
|
|
20
|
+
corner_casting_list,
|
|
21
|
+
empty_space_finder_options,
|
|
22
|
+
item_list
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Builds a `Map` of container `sequencia` to constructed container instances for one transport env.
|
|
28
|
+
* Call after request validation so `container_data_list` is a non-empty array.
|
|
29
|
+
* @param {object} transport_data - Raw transport/env object (`_id`, `tipo`, `props`, etc.).
|
|
30
|
+
* @param {object[]} container_data_list - Elements of `transport_data.containers`.
|
|
31
|
+
* @param {object|undefined} empty_space_finder_options - Optional `{ merge_tolerance }` for {@link EmptySpaceFinder}.
|
|
32
|
+
* @returns {Map<number, object>}
|
|
33
|
+
*/
|
|
34
|
+
module.exports = function create_container_map(data)
|
|
35
|
+
{
|
|
36
|
+
const container_map = new Map()
|
|
37
|
+
|
|
38
|
+
const { transport_data, empty_space_finder_options, item_list } = data
|
|
39
|
+
for (const container_data of transport_data.containers)
|
|
40
|
+
{
|
|
41
|
+
const container = create_container_data({transport_data, container_data, empty_space_finder_options, item_list})
|
|
42
|
+
container_map.set(container_data.sequencia, container)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return container_map
|
|
46
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const {CornerCasting, Direction} = require('@jetta/empty-spaces-manager')
|
|
2
|
+
|
|
3
|
+
const round = require('../../../tools/Rounder')
|
|
4
|
+
|
|
5
|
+
function create_corner_casting_data_list(container, value, direction)
|
|
6
|
+
{
|
|
7
|
+
const corner_casting_list = []
|
|
8
|
+
|
|
9
|
+
if (value <= 0)
|
|
10
|
+
{
|
|
11
|
+
return corner_casting_list
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
for (let index = 0; index < 2; index++)
|
|
15
|
+
{
|
|
16
|
+
const corner_casting_data = create_corner_casting_data(index, container, value, direction)
|
|
17
|
+
const corner_casting = new CornerCasting(corner_casting_data, direction)
|
|
18
|
+
corner_casting_list.push(corner_casting)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return corner_casting_list
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function create_corner_casting_data(index, container, value, direction)
|
|
25
|
+
{
|
|
26
|
+
const x = index === 0 ? 0 : round(container.largura - value)
|
|
27
|
+
const y = round(container.altura - value)
|
|
28
|
+
const z = direction.toLowerCase() === Direction.FRONT ? 0 : round(container.comprimento - value)
|
|
29
|
+
const corner_casting_data = {x: x, y: y, z: z, w: value, h: value, l: value}
|
|
30
|
+
|
|
31
|
+
return corner_casting_data
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Builds corner-casting geometry for the empty-space manager when transport is a container with props.
|
|
36
|
+
* @param {object} transport_data - Env root; must define string `tipo` and, when tipo is `container`, may define `props`.
|
|
37
|
+
* @param {object} container_data - Raw container row (`largura`, `altura`, `comprimento`).
|
|
38
|
+
* @returns {Array<object>} CornerCasting instances; empty when tipo is not `container` or `props` is missing.
|
|
39
|
+
* @throws {TypeError} When `transport_data.tipo` is not a string (e.g. missing).
|
|
40
|
+
*/
|
|
41
|
+
module.exports = function create_all_corner_castings(transport_data, container_data)
|
|
42
|
+
{
|
|
43
|
+
if (transport_data.tipo.toLowerCase() !== 'container' || transport_data.props === undefined)
|
|
44
|
+
{
|
|
45
|
+
return []
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const corner_castings_data = transport_data.props
|
|
49
|
+
|
|
50
|
+
const front_casting = create_corner_casting_data_list(
|
|
51
|
+
container_data,
|
|
52
|
+
corner_castings_data.espacoSuperiorFrente,
|
|
53
|
+
Direction.FRONT
|
|
54
|
+
)
|
|
55
|
+
const back_casting = create_corner_casting_data_list(
|
|
56
|
+
container_data,
|
|
57
|
+
corner_castings_data.espacoSuperiorPorta,
|
|
58
|
+
Direction.BACK
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return [...front_casting, ...back_casting]
|
|
62
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const Allocated_Item = require('../../Allocated_Item')
|
|
2
|
+
const Preloaded_Allocated_Item = require('../../Preloaded_Allocated_Item')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts raw `items` from a container payload into allocated item instances for the finder.
|
|
6
|
+
* @param {object[]|undefined} allocated_item_list - `container_data.items` from input JSON.
|
|
7
|
+
* @returns {Array<object>} Empty array when input is missing or not an array; otherwise allocated items.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = function create_previously_allocated_item_list(allocated_item_list)
|
|
10
|
+
{
|
|
11
|
+
if (allocated_item_list === undefined || !Array.isArray(allocated_item_list))
|
|
12
|
+
{
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return allocated_item_list.map(create_previously_allocated_item)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function create_previously_allocated_item(item_data)
|
|
20
|
+
{
|
|
21
|
+
const allocation_item = new Preloaded_Allocated_Item(item_data)
|
|
22
|
+
return new Allocated_Item(
|
|
23
|
+
allocation_item,
|
|
24
|
+
allocation_item.get_x(),
|
|
25
|
+
allocation_item.get_y(),
|
|
26
|
+
allocation_item.get_z()
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const Transport = require('../Transport')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Selects the first transport definition from `envs` and returns a ready transport instance.
|
|
5
|
+
* Call after `parse_allocation_request` (or equivalent) so `transport_data_list` is non-empty.
|
|
6
|
+
* @param {object[]} transport_data_list - Typically `input_data.envs`.
|
|
7
|
+
* @param {object|undefined} empty_space_finder_options - Optional `{ merge_tolerance }` for {@link EmptySpaceFinder}.
|
|
8
|
+
* @returns {object} Transport model built from `transport_data_list[0]`.
|
|
9
|
+
*/
|
|
10
|
+
module.exports = function create_transport(data)
|
|
11
|
+
{
|
|
12
|
+
return new Transport(data)
|
|
13
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const { Space } = require('@jetta/empty-spaces-manager')
|
|
2
|
+
|
|
3
|
+
function has_group_id(group_id)
|
|
4
|
+
{
|
|
5
|
+
return group_id !== undefined && group_id !== null
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function group_key(item, index)
|
|
9
|
+
{
|
|
10
|
+
const group_id = item.get_group_id()
|
|
11
|
+
if (!has_group_id(group_id))
|
|
12
|
+
{
|
|
13
|
+
return `__no_group_${index}`
|
|
14
|
+
}
|
|
15
|
+
return group_id
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function group_items_by_group_id(allocated_item_list)
|
|
19
|
+
{
|
|
20
|
+
const groups = new Map()
|
|
21
|
+
allocated_item_list.forEach((item, index) =>
|
|
22
|
+
{
|
|
23
|
+
const key = group_key(item, index)
|
|
24
|
+
if (!groups.has(key))
|
|
25
|
+
{
|
|
26
|
+
groups.set(key, [])
|
|
27
|
+
}
|
|
28
|
+
groups.get(key).push(item)
|
|
29
|
+
})
|
|
30
|
+
return groups
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function bounding_box_space_from_items(item_list)
|
|
34
|
+
{
|
|
35
|
+
let min_x = Infinity
|
|
36
|
+
let min_y = Infinity
|
|
37
|
+
let min_z = Infinity
|
|
38
|
+
let max_x = -Infinity
|
|
39
|
+
let max_y = -Infinity
|
|
40
|
+
let max_z = -Infinity
|
|
41
|
+
for (const item of item_list)
|
|
42
|
+
{
|
|
43
|
+
min_x = Math.min(min_x, item.get_x())
|
|
44
|
+
min_y = Math.min(min_y, item.get_y())
|
|
45
|
+
min_z = Math.min(min_z, item.get_z())
|
|
46
|
+
const end_point = item.get_end_point()
|
|
47
|
+
max_x = Math.max(max_x, end_point.x)
|
|
48
|
+
max_y = Math.max(max_y, end_point.y)
|
|
49
|
+
max_z = Math.max(max_z, end_point.z)
|
|
50
|
+
}
|
|
51
|
+
return new Space({
|
|
52
|
+
x: min_x,
|
|
53
|
+
y: min_y,
|
|
54
|
+
z: min_z,
|
|
55
|
+
width: max_x - min_x,
|
|
56
|
+
height: max_y - min_y,
|
|
57
|
+
length: max_z - min_z
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function item_or_bounding_box_for_group(item_list)
|
|
62
|
+
{
|
|
63
|
+
if (item_list.length === 1)
|
|
64
|
+
{
|
|
65
|
+
return item_list[0]
|
|
66
|
+
}
|
|
67
|
+
return bounding_box_space_from_items(item_list)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Builds the item list passed to {@link EmptySpaceFinder}: one entry per block group
|
|
72
|
+
* (bounding box when multiple slots share a groupId), or each item when groupId is absent.
|
|
73
|
+
* @param {Array<object>} allocated_item_list - Pre-placed allocated items.
|
|
74
|
+
* @returns {Array<object>} Items for empty-space subtraction.
|
|
75
|
+
*/
|
|
76
|
+
function items_for_empty_space_finder(allocated_item_list)
|
|
77
|
+
{
|
|
78
|
+
if (allocated_item_list.length === 0)
|
|
79
|
+
{
|
|
80
|
+
return []
|
|
81
|
+
}
|
|
82
|
+
const groups = group_items_by_group_id(allocated_item_list)
|
|
83
|
+
const finder_items = []
|
|
84
|
+
for (const item_list of groups.values())
|
|
85
|
+
{
|
|
86
|
+
finder_items.push(item_or_bounding_box_for_group(item_list))
|
|
87
|
+
}
|
|
88
|
+
return finder_items
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = items_for_empty_space_finder
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const create_input = require('../../Allocation_Optimization/block_builder/Stacking_Validation')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prefers wire-derived stacking DTOs; falls back to allocated items for direct {@link Container} construction.
|
|
5
|
+
* @param {object[]|undefined} preloaded_stacking_inputs - Wire-derived DTOs from the factory path.
|
|
6
|
+
* @param {object[]|undefined} allocated_item_list - Allocated items when wire DTOs are absent.
|
|
7
|
+
* @returns {object[]}
|
|
8
|
+
*/
|
|
9
|
+
function resolve_container_stacking_inputs(preloaded_stacking_inputs, allocated_item_list)
|
|
10
|
+
{
|
|
11
|
+
const wire_inputs = preloaded_stacking_inputs ?? []
|
|
12
|
+
if (wire_inputs.length > 0)
|
|
13
|
+
{
|
|
14
|
+
return wire_inputs
|
|
15
|
+
}
|
|
16
|
+
if (allocated_item_list === undefined || allocated_item_list.length === 0)
|
|
17
|
+
{
|
|
18
|
+
return []
|
|
19
|
+
}
|
|
20
|
+
return allocated_item_list.map(allocated => create_input(allocated))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = resolve_container_stacking_inputs
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const {
|
|
2
|
+
build_placed_item_record,
|
|
3
|
+
build_stacking_info,
|
|
4
|
+
read_placed_position
|
|
5
|
+
} = require('../placed_item_record')
|
|
6
|
+
const { build_stacking_rules_from_info } = require(
|
|
7
|
+
'../../Allocation_Optimization/block_builder/stacking_rules_input'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
function read_wire_dimensions(wire_item)
|
|
11
|
+
{
|
|
12
|
+
return {
|
|
13
|
+
width: wire_item.w ?? wire_item.largura ?? wire_item.width,
|
|
14
|
+
height: wire_item.h ?? wire_item.altura ?? wire_item.height,
|
|
15
|
+
length: wire_item.d ?? wire_item.comprimento ?? wire_item.length
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Builds a {@link StackingFeasibilityChecker} input DTO from a raw placed item wire payload.
|
|
21
|
+
* @param {object} wire_item - Element of `container.items`.
|
|
22
|
+
* @returns {object}
|
|
23
|
+
*/
|
|
24
|
+
function build_stacking_input_from_wire(wire_item)
|
|
25
|
+
{
|
|
26
|
+
const record = build_placed_item_record(wire_item)
|
|
27
|
+
const stacking_info = build_stacking_info(wire_item)
|
|
28
|
+
const position = read_placed_position(wire_item)
|
|
29
|
+
const dimensions = read_wire_dimensions(wire_item)
|
|
30
|
+
return {
|
|
31
|
+
itemId: record._id,
|
|
32
|
+
x: position.x,
|
|
33
|
+
y: position.y,
|
|
34
|
+
z: position.z,
|
|
35
|
+
width: dimensions.width,
|
|
36
|
+
height: dimensions.height,
|
|
37
|
+
length: dimensions.length,
|
|
38
|
+
stackingRules: build_stacking_rules_from_info(stacking_info, record)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {object[]} wire_list - Raw `container.items` entries.
|
|
44
|
+
* @returns {object[]}
|
|
45
|
+
*/
|
|
46
|
+
function build_stacking_inputs_from_wire_list(wire_list)
|
|
47
|
+
{
|
|
48
|
+
if (!Array.isArray(wire_list) || wire_list.length === 0)
|
|
49
|
+
{
|
|
50
|
+
return []
|
|
51
|
+
}
|
|
52
|
+
return wire_list.map(build_stacking_input_from_wire)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
build_stacking_input_from_wire,
|
|
57
|
+
build_stacking_inputs_from_wire_list
|
|
58
|
+
}
|