@jetta/blocks-allocator 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -2
- package/package.json +67 -5
- package/src/Allocation_Attempt.js +135 -0
- package/src/Allocation_Error_Handler.js +69 -0
- package/src/Allocation_Flow.js +162 -0
- package/src/Allocation_Optimization/Allocation_LP.js +150 -0
- package/src/Allocation_Optimization/Block_Allocator.js +129 -0
- package/src/Allocation_Optimization/Block_Layer_Order.js +50 -0
- package/src/Allocation_Optimization/Block_Potential_Weight.js +54 -0
- package/src/Allocation_Optimization/Chosen_Blocks_Stock_Cap.js +82 -0
- package/src/Allocation_Optimization/block_builder/Allocation_Item_Creator.js +37 -0
- package/src/Allocation_Optimization/block_builder/Block_Item_List_Validator.js +18 -0
- package/src/Allocation_Optimization/block_builder/Block_Wall_Builder.js +303 -0
- package/src/Allocation_Optimization/block_builder/Blocks_Builder.js +40 -0
- package/src/Allocation_Optimization/block_builder/Next_Block_Position.js +33 -0
- package/src/Allocation_Optimization/block_builder/Slot_Item_Assigner.js +45 -0
- package/src/Allocation_Optimization/block_builder/Stacking_Validation.js +30 -0
- package/src/Allocation_Optimization/block_builder/assert_tie_ratio_block_matches_orientation_below.js +44 -0
- package/src/Allocation_Optimization/block_builder/block_shape_stock.js +129 -0
- package/src/Allocation_Optimization/block_builder/exceptions/Empty_Block_Item_List_Exception.js +21 -0
- package/src/Allocation_Optimization/block_builder/exceptions/Invalid_Stacking_Exception.js +14 -0
- package/src/Allocation_Optimization/block_builder/exceptions/No_Suitable_Item_Exception.js +16 -0
- package/src/Allocation_Optimization/block_builder/exceptions/Restricted_Block_Exception.js +21 -0
- package/src/Allocation_Optimization/block_builder/should_omit_block_group_id.js +29 -0
- package/src/Allocation_Optimization/block_builder/snap_elevated_block_wall_items.js +34 -0
- package/src/Allocation_Optimization/block_builder/stacking_rules_input.js +52 -0
- package/src/Allocation_Optimization/cap_chosen_blocks_by_shape_stock.js +110 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Preparer.js +21 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Selector.js +55 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Threshold_Resolver.js +28 -0
- package/src/Allocation_Optimization/density_groups/Adaptive_Density_Group_Thresholds.js +23 -0
- package/src/Allocation_Optimization/density_groups/Container_Utilization.js +67 -0
- package/src/Allocation_Optimization/density_groups/Density_Group_Partitioner.js +74 -0
- package/src/Allocation_Optimization/density_groups/Density_Group_Scheduler.js +168 -0
- package/src/Allocation_Optimization/density_groups/Density_Group_Stock.js +49 -0
- package/src/Allocation_Optimization/density_groups/Density_Groups_Strategy.js +26 -0
- package/src/Allocation_Optimization/density_groups/Item_Density_Calculator.js +20 -0
- package/src/Allocation_Optimization/density_groups/Lock_Weight_Ahead_Release.js +75 -0
- package/src/Allocation_Optimization/exceptions/Invalid_Item_Amount_Exception.js +17 -0
- package/src/Allocation_Optimization/exceptions/No_Valid_Allocation_Exception.js +14 -0
- package/src/Allocation_Optimization/exceptions/Optimization_Infeasible_Exception.js +14 -0
- package/src/Allocation_Optimization/functions/Measure_Reader.js +20 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Cobination_Mode.js +25 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Cobination_Strategies.js +8 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Measure_Combination_Mode_Checkers.js +70 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Translation.js +22 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/Variable_Weight_Getter.js +85 -0
- package/src/Allocation_Optimization/functions/Weight_Getter/constants.js +16 -0
- package/src/Allocation_Optimization/functions/measure_to_optimize.js +6 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Capacity_Bias_Item_Order.js +76 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Choose_Item_Heuristic_Context.js +63 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Item_Chooser.js +159 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Item_For_Slot_Chooser.js +49 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Slot_Compatible_Items_Finder.js +88 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Slots_Items_Assigner.js +182 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Stack_Slot_Calculator.js +87 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/Weight_Slot_Distribution.js +72 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/Empty_Slot_Exception.js +17 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/Item_Taller_Than_Limit_Exception.js +21 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/No_Available_Items_Exception.js +14 -0
- package/src/Allocation_Optimization/item_consumption_heuristic/exceptions/No_Slots_For_Items_Exception.js +14 -0
- package/src/Allocation_Optimization/lp_model/Block_Weight_Calculator.js +31 -0
- package/src/Allocation_Optimization/lp_model/LP_Data_Processor.js +42 -0
- package/src/Allocation_Optimization/lp_model/LP_Item_Slot_Assignment.js +93 -0
- package/src/Allocation_Optimization/lp_model/LP_Result_Mapper.js +47 -0
- package/src/Allocation_Optimization/lp_model/model_builder/Dimension_Range_Helper.js +49 -0
- package/src/Allocation_Optimization/lp_model/model_builder/Item_Assignment_Variables.js +133 -0
- package/src/Allocation_Optimization/lp_model/model_builder/LP_Model_Builder.js +132 -0
- package/src/Allocation_Optimization/lp_model/model_builder/exceptions/Missing_Item_Stock_Exception.js +18 -0
- package/src/Allocation_Optimization/lp_model/model_builder/goal_function/Goal_Function_Creator.js +83 -0
- package/src/Allocation_Optimization/lp_model/model_builder/item_dimension_hashes.js +31 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Block_Item_Amount_Restriction.js +53 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Coherence_Restriction.js +65 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Container_Supported_Weight_Restriction.js +42 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Relational_Exact_Pass_Amount_Restriction.js +62 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Relational_Group_Restriction.js +97 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Single_Item_Type_Restriction.js +79 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Space_Restriction.js +47 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Unavailable_Block_Restriction.js +27 -0
- package/src/Allocation_Optimization/lp_model/model_builder/restrictions/Uniform_Block_Measure_Restriction.js +92 -0
- package/src/Allocation_Optimization/next_group_id_after_preloaded.js +30 -0
- package/src/Allocation_Optimization/preferential_blocks/Preferential_Block_Identifier.js +74 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/Key_Item_Mapper.js +49 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Almost_Unique_Item.js +31 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Cant_Stack_It_Self.js +68 -0
- package/src/Allocation_Optimization/preferential_blocks/key_item/rules/Rule_Interface.js +26 -0
- package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Intercalation_State.js +49 -0
- package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Orientation_Filter.js +33 -0
- package/src/Allocation_Optimization/tie_ratio/Tie_Ratio_Vertical_Stack_Filter.js +20 -0
- package/src/Allocation_Optimization/tie_ratio/collect_tie_ratio_orientations_below_footprint.js +64 -0
- package/src/Allocation_Optimization/tie_ratio/filter_blocks_by_orientation.js +17 -0
- package/src/Allocation_Optimization/tie_ratio/find_orientation_below_space.js +77 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/allocated_item_penetrates_any.js +31 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/apply_loose_placement_to_allocated_item.js +94 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/axis_overlap_length.js +16 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/block_local_origin.js +18 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/box_fits_inside_container.js +39 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_allocated_item_at_placement.js +18 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_placement_on_generic_supporter.js +64 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/build_slot_grid_from_cluster.js +66 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/compare_group_ids.js +20 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/container_with_pending_wall_items.js +26 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/empty_space_is_on_floor.js +16 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/finalize_loose_item_placement.js +58 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_best_generic_supporter_placement.js +58 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_next_free_slot_index.js +119 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_supporter_directly_below.js +51 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/find_tie_ratio_supporter_cluster.js +57 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/footprint_xz_overlap_area.js +26 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/item_fits_supporter_slot.js +22 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_footprint_region_from_options.js +24 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_item_fits_inside_container.js +21 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_item_has_geometric_support.js +21 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/loose_on_block_slot_state.js +88 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/placement_coords_fit_inside_container.js +34 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/read_empilhar_area_igual_from_allocation_item.js +12 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/realigned_loose_geometry_gates.js +25 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_loose_on_generic_supporter.js +65 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_loose_placement_position.js +68 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_placement_y_at_slot.js +45 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/resolve_without_tie_ratio_cluster.js +79 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/select_tie_ratio_slot_placement.js +84 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/slot_footprint_collision.js +105 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_cluster_selection.js +119 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_footprint_overlap.js +56 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_placement_plane.js +109 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/tie_ratio_supporter_predicate.js +23 -0
- package/src/Allocation_Optimization/tie_ratio/loose_on_block/try_tie_ratio_slot_placement.js +62 -0
- package/src/Allocation_Optimization/tie_ratio/snap_stacked_items_to_floor_footprints.js +138 -0
- package/src/Allocation_Optimization/tie_ratio/supporters_by_top_y_index.js +78 -0
- package/src/Allocation_Optimization/tie_ratio/tie_ratio_orientation_below_empty_space.js +89 -0
- package/src/Allocation_Optimization/tie_ratio/tie_ratio_orientation_from_group.js +48 -0
- package/src/Block_Management.js +34 -0
- package/src/Blocks_Preparation/Cube_Map_Function.js +27 -0
- package/src/Blocks_Wall_Allocation.js +3 -0
- package/src/IO/Answer_Status.js +4 -0
- package/src/IO/Output_Builder.js +35 -0
- package/src/IO/count_allocated_items.js +31 -0
- package/src/IO/create_error_response.js +62 -0
- package/src/IO/format_allocation_error_message.js +25 -0
- package/src/Item_Continuation_Lock.js +129 -0
- package/src/Item_Picking_Continuity.js +41 -0
- package/src/allocation_flow/chooser_session_state.js +21 -0
- package/src/allocation_flow/compound_probe_fallback.js +17 -0
- package/src/allocation_flow/container_remaining_capacity.js +23 -0
- package/src/allocation_flow/density_group_item_filter.js +31 -0
- package/src/allocation_flow/effective_item_fingerprint.js +14 -0
- package/src/allocation_flow/item_continuation_lock_gate.js +38 -0
- package/src/allocation_flow/no_space_left_recovery.js +48 -0
- package/src/allocation_flow/run_allocation_iteration.js +155 -0
- package/src/allocation_flow/space_skip_state.js +91 -0
- package/src/allocation_flow/try_no_space_left_recovery.js +50 -0
- package/src/exceptions/Invalid_Parameter_Exception.js +17 -0
- package/src/exceptions/Relational_Allocation_Incomplete_Exception.js +24 -0
- package/src/exceptions/Relational_Colocation_Violation_Exception.js +23 -0
- package/src/exceptions/Relational_Config_Mismatch_Exception.js +17 -0
- package/src/exceptions/There_Is_No_Block_Options_To_Allocate_Exception.js +14 -0
- package/src/index.js +6 -0
- package/src/input_preparation/Block_Formatter.js +179 -0
- package/src/input_preparation/Input_Creator.js +76 -0
- package/src/input_preparation/Input_State_Preparation.js +47 -0
- package/src/input_preparation/State_Builder.js +27 -0
- package/src/input_preparation/block_formatter/align_flush_axis_config.js +36 -0
- package/src/input_preparation/block_formatter/align_flush_axis_single_round.js +112 -0
- package/src/input_preparation/block_formatter/align_flush_stacked_slots.js +67 -0
- package/src/input_preparation/block_formatter/overlapped_slots.js +24 -0
- package/src/input_preparation/block_formatter/parallelepiped_shell.js +38 -0
- package/src/input_preparation/block_formatter/rectangle_coverage.js +112 -0
- package/src/input_preparation/block_formatter/shell_face_coverage.js +64 -0
- package/src/input_preparation/block_formatter/shell_snap_convergence.js +104 -0
- package/src/input_preparation/block_preparation/Block_Data_To_Object_Transformer.js +57 -0
- package/src/input_preparation/block_preparation/Block_Module_Name.js +17 -0
- package/src/input_preparation/block_preparation/Blocks_Creator.js +101 -0
- package/src/input_preparation/block_preparation/Blocksmith.js +19 -0
- package/src/input_preparation/block_preparation/block_modules/create_block_candidates.js +41 -0
- package/src/input_preparation/block_preparation/block_modules/manual_blocks.js +10 -0
- package/src/input_preparation/block_preparation/block_modules/module_registry.js +20 -0
- package/src/input_preparation/block_preparation/block_modules/run_creator.js +34 -0
- package/src/input_preparation/block_preparation/block_modules/single_item_blocks.js +12 -0
- package/src/input_preparation/block_preparation/block_modules/spiral_blocks.js +12 -0
- package/src/input_preparation/block_preparation/block_modules/tie_ratio_blocks.js +12 -0
- package/src/input_preparation/block_preparation/block_modules/tower_blocks.js +12 -0
- package/src/input_preparation/block_preparation/exceptions/Failed_To_Create_Block_Exception.js +14 -0
- package/src/input_preparation/block_preparation/exceptions/Failed_To_Retrieve_Block_Exception.js +17 -0
- package/src/input_preparation/block_preparation/exceptions/Missing_Object_Store_Exception.js +10 -0
- package/src/input_preparation/block_preparation/exceptions/No_Blocks_Were_Created_Exception.js +14 -0
- package/src/input_preparation/block_preparation/input/Input_Creator.js +96 -0
- package/src/input_preparation/block_preparation/manual_blocks/Manual_Blocks.js +95 -0
- package/src/input_preparation/build_empty_space_finder_options.js +43 -0
- package/src/input_preparation/item_preparation/Items_Reader.js +27 -0
- package/src/input_preparation/min_extents_from_items.js +29 -0
- package/src/input_preparation/stackability_index/Blocks_Stackability_Index_Calculator.js +58 -0
- package/src/input_preparation/stackability_index/Slots_Stackability_index_Calculator.js +28 -0
- package/src/input_preparation/stackability_index/Stackability_Input_Creator.js +27 -0
- package/src/input_preparation/stackability_index/stackability_index_pop_stack.js +81 -0
- package/src/input_preparation/stacking_constraints/Weight_Stacking_Validation.js +15 -0
- package/src/lp_optimizer_result_status.js +20 -0
- package/src/messages/Allocator_Message.js +42 -0
- package/src/messages/resolve_error_message_entry.js +57 -0
- package/src/models/Allocated_Item.js +136 -0
- package/src/models/Allocation_Item.js +219 -0
- package/src/models/Block.js +198 -0
- package/src/models/Cargo_Profile.js +418 -0
- package/src/models/Preloaded_Allocated_Item.js +132 -0
- package/src/models/Slot.js +67 -0
- package/src/models/Stacking_Rules.js +58 -0
- package/src/models/auxiliaryFunctions/Available_Block_Module_List_Creator.js +9 -0
- package/src/models/auxiliaryFunctions/Measure_Translator.js +24 -0
- package/src/models/auxiliaryFunctions/item_json_reader.js +44 -0
- package/src/models/item_json_reader.js +71 -0
- package/src/models/placed_item_record.js +70 -0
- package/src/models/preloaded_rotation_helpers.js +38 -0
- package/src/models/slots_have_same_measure.js +45 -0
- package/src/models/transport/Container.js +162 -0
- package/src/models/transport/Transport.js +62 -0
- package/src/models/transport/build_stacking_feasibility_checker.js +64 -0
- package/src/models/transport/container_stacking_checkpoint.js +42 -0
- package/src/models/transport/factory/Container_Factory.js +46 -0
- package/src/models/transport/factory/Corner_Casting_Factory.js +62 -0
- package/src/models/transport/factory/Previously_Allocated_Item_Factory.js +28 -0
- package/src/models/transport/factory/Transport_Factory.js +13 -0
- package/src/models/transport/items_for_empty_space_finder.js +91 -0
- package/src/models/transport/resolve_container_stacking_inputs.js +23 -0
- package/src/models/transport/stacking_input_from_wire.js +58 -0
- package/src/optimizer_connection_errors.js +50 -0
- package/src/relational/Relational_Error_Codes.js +7 -0
- package/src/relational/finalize_relational_allocation.js +20 -0
- package/src/relational/has_relational_items.js +11 -0
- package/src/relational/is_relational_error_code.js +15 -0
- package/src/relational/resolve_relational_container_sequences.js +29 -0
- package/src/run_core_allocation.js +118 -0
- package/src/space_and_block_chooser/Space_And_Blocks_Chooser.js +115 -0
- package/src/space_and_block_chooser/blocks_filters/Block_Filter_Interface.js +19 -0
- package/src/space_and_block_chooser/blocks_filters/Filter_Runner.js +46 -0
- package/src/space_and_block_chooser/blocks_filters/initial_blocks_filter/Block_With_Overlapped_Slots_Filter.js +14 -0
- package/src/space_and_block_chooser/blocks_filters/initial_blocks_filter/Initial_Blocks_Filter_List.js +19 -0
- package/src/space_and_block_chooser/blocks_filters/pos_selection_filters/Blocks_Bigger_Than_Space_Filter.js +17 -0
- package/src/space_and_block_chooser/blocks_filters/pos_selection_filters/Post_Selection_Filter_List.js +9 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/Insuficient_Items_Filter.js +81 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/Pre_Selection_Filter_List.js +8 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/max_tower_height/Blocks_Lower_Than_Max_Tower_Height.js +23 -0
- package/src/space_and_block_chooser/blocks_filters/pre_selection_filter/max_tower_height/Max_Tower_Height.js +82 -0
- package/src/space_and_block_chooser/build_allocated_item_snapshots.js +19 -0
- package/src/space_and_block_chooser/compound_first_empty_space_branch.js +61 -0
- package/src/space_and_block_chooser/compound_first_with_leftover_fill.js +142 -0
- package/src/space_and_block_chooser/compound_first_without_leftover_fill.js +56 -0
- package/src/space_and_block_chooser/empty_spaces_where_post_selection_keeps_blocks.js +83 -0
- package/src/space_and_block_chooser/exceptions/Invalid_Space_To_Allocate_Exception.js +14 -0
- package/src/space_and_block_chooser/leftover_space_memory.js +113 -0
- package/src/space_and_block_chooser/leftover_unitary_blocks.js +153 -0
- package/src/space_and_block_chooser/leftover_unitary_empty_spaces.js +135 -0
- package/src/space_and_block_chooser/probe_set_pool.js +35 -0
- package/src/space_and_block_chooser/run_space_and_block_selection_attempt.js +88 -0
- package/src/tools/Array_Validator.js +6 -0
- package/src/tools/Clone.js +27 -0
- package/src/tools/Hash.js +8 -0
- package/src/tools/Rounder.js +5 -0
- package/src/tools/String_To_Boolean.js +12 -0
- package/src/tools/cargo_profile/Cargo_Profile_Field_Value_Resolver.js +44 -0
- package/src/tools/compact_items_with_stock.js +9 -0
- package/src/tools/mm_to_allocation_domain.js +14 -0
- package/src/tracing/Allocation_Tracer.js +52 -0
- package/src/tracing/Trace_Context.js +18 -0
- package/src/tracing/trace_outcome.js +18 -0
- package/src/tracing/traced_step.js +57 -0
- package/src/validation/Item_Continuation_Lock_Flag.js +52 -0
- package/src/validation/Item_Validation.js +29 -0
- package/src/validation/Relational_Colocation_Validator.js +60 -0
- package/src/validation/Relational_Completeness_Validator.js +146 -0
- package/src/validation/Relational_Continuation_Lock_Validation.js +37 -0
- package/src/validation/Relational_Proportional_Normalizer.js +194 -0
- package/src/validation/Validation.js +9 -0
- package/src/validation/Validation_Runner.js +20 -0
- package/src/validation/exceptions/Invalid_Block_Module_Config_Exception.js +14 -0
- package/src/validation/exceptions/Invalid_Input_Exception.js +14 -0
- package/src/validation/exceptions/Invalid_Input_Type_Exception.js +14 -0
- package/src/validation/schemas/allocated_item_schema.js +18 -0
- package/src/validation/schemas/allocation_request_schema.js +178 -0
- package/src/validation/schemas/container_row_schema.js +16 -0
- package/src/validation/schemas/item_schema.js +60 -0
- package/src/validation/schemas/transport_env_schema.js +19 -0
- package/src/validation/validate_block_module_config.js +147 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block module vocabulary — keep in sync with block_modules/module_registry.js.
|
|
3
|
+
*/
|
|
4
|
+
const BLOCK_MODULE_NAME = Object.freeze({
|
|
5
|
+
MANUAL_BLOCKS: 'manual_blocks',
|
|
6
|
+
SPIRAL_BLOCKS: 'spiral_blocks',
|
|
7
|
+
TOWER_BLOCKS: 'tower_blocks',
|
|
8
|
+
SINGLE_ITEM_BLOCKS: 'single_item_blocks',
|
|
9
|
+
TIE_RATIO_BLOCKS: 'tie_ratio_blocks',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const VALID_BLOCK_MODULE_NAMES = Object.freeze(Object.values(BLOCK_MODULE_NAME))
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
BLOCK_MODULE_NAME,
|
|
16
|
+
VALID_BLOCK_MODULE_NAMES,
|
|
17
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const { Item, Rotations, Space } = require('@jetta/empty-spaces-manager')
|
|
2
|
+
const item_json_reader = require('../../models/item_json_reader')
|
|
3
|
+
const transform_blocks_data_into_object = require('./Block_Data_To_Object_Transformer')
|
|
4
|
+
const make_blocks = require('./Blocksmith')
|
|
5
|
+
const create_input = require('./input/Input_Creator')
|
|
6
|
+
const build_initial_blocks_filter_list = require('../../space_and_block_chooser/blocks_filters/initial_blocks_filter/Initial_Blocks_Filter_List')
|
|
7
|
+
const run_filters = require('../../space_and_block_chooser/blocks_filters/Filter_Runner')
|
|
8
|
+
const {Logger} = require('@jetta/logger')
|
|
9
|
+
const logger = new Logger('Blocks Creator')
|
|
10
|
+
const { traced_step } = require('../../tracing/traced_step')
|
|
11
|
+
const { TRACE_CONTEXT } = require('../../tracing/Trace_Context')
|
|
12
|
+
|
|
13
|
+
async function create_all_blocks(block_path_list, transport, item_list, object_store)
|
|
14
|
+
{
|
|
15
|
+
const input_data = create_input(block_path_list, transport, item_list)
|
|
16
|
+
input_data.item_list = input_data.item_list.filter(item => any_rotation_fit(item, transport))
|
|
17
|
+
if (input_data.item_list.length === 0)
|
|
18
|
+
{
|
|
19
|
+
return []
|
|
20
|
+
}
|
|
21
|
+
const block_list = await make_blocks(input_data, object_store)
|
|
22
|
+
return block_list
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function build_container_space_cache(container_list)
|
|
26
|
+
{
|
|
27
|
+
const space_by_container = new Map()
|
|
28
|
+
for (const container of container_list)
|
|
29
|
+
{
|
|
30
|
+
const cache_key = `${container.largura}|${container.altura}|${container.comprimento}`
|
|
31
|
+
if (!space_by_container.has(cache_key))
|
|
32
|
+
{
|
|
33
|
+
space_by_container.set(cache_key, new Space({
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
z: 0,
|
|
37
|
+
width: container.largura,
|
|
38
|
+
height: container.altura,
|
|
39
|
+
length: container.comprimento
|
|
40
|
+
}))
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return space_by_container
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function any_rotation_fit(item, transport)
|
|
47
|
+
{
|
|
48
|
+
const item_object = new Item(item_json_reader(item, Rotations.POS1))
|
|
49
|
+
const rotation_list = item_object.get_rotations()
|
|
50
|
+
const space_cache = build_container_space_cache(transport.containers)
|
|
51
|
+
return rotation_list.some(
|
|
52
|
+
rotation => does_any_rotation_fit_any_of_the_containers(
|
|
53
|
+
item_object,
|
|
54
|
+
rotation,
|
|
55
|
+
transport.containers,
|
|
56
|
+
space_cache
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function does_any_rotation_fit_any_of_the_containers(item, rotation, container_list, space_cache)
|
|
62
|
+
{
|
|
63
|
+
return container_list.some(container =>
|
|
64
|
+
{
|
|
65
|
+
const cache_key = `${container.largura}|${container.altura}|${container.comprimento}`
|
|
66
|
+
const container_as_es = space_cache.get(cache_key)
|
|
67
|
+
return container_as_es.fit_item(item, rotation)
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = async function create_blocks(block_path_list, transport, item_list, object_store)
|
|
72
|
+
{
|
|
73
|
+
return traced_step(TRACE_CONTEXT.BLOCKS_GENERATION, async () =>
|
|
74
|
+
{
|
|
75
|
+
logger.debug('creating blocks possibilities')
|
|
76
|
+
const block_data_list = await create_all_blocks(
|
|
77
|
+
block_path_list,
|
|
78
|
+
transport,
|
|
79
|
+
item_list,
|
|
80
|
+
object_store
|
|
81
|
+
)
|
|
82
|
+
if (block_data_list.length === 0)
|
|
83
|
+
{
|
|
84
|
+
return []
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const available_blocks = await filter_transformed_blocks(block_data_list, item_list)
|
|
88
|
+
logger.debug('blocks created successfully')
|
|
89
|
+
return available_blocks
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function filter_transformed_blocks(block_data_list, item_list)
|
|
94
|
+
{
|
|
95
|
+
const block_list = transform_blocks_data_into_object(block_data_list)
|
|
96
|
+
const filter_data = {
|
|
97
|
+
block_list,
|
|
98
|
+
item_list
|
|
99
|
+
}
|
|
100
|
+
return run_filters(build_initial_blocks_filter_list(), filter_data)
|
|
101
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const create_block_candidates = require('./block_modules/create_block_candidates')
|
|
2
|
+
const create_manual_blocks = require('./manual_blocks/Manual_Blocks')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds generated candidates and manual blocks for one preparation input.
|
|
6
|
+
* @param {object} input_data
|
|
7
|
+
* @param {{ get_object: Function }} [object_store]
|
|
8
|
+
* @returns {Promise<object[]>}
|
|
9
|
+
*/
|
|
10
|
+
async function build_block_list(input_data, object_store)
|
|
11
|
+
{
|
|
12
|
+
const manual_block_promise = create_manual_blocks(input_data.block_path_list, object_store)
|
|
13
|
+
const block_list = create_block_candidates(input_data)
|
|
14
|
+
const manual_block_list = await manual_block_promise
|
|
15
|
+
block_list.push(...manual_block_list)
|
|
16
|
+
return block_list
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = build_block_list
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { MODULE_REGISTRY, MODULE_NAME_LIST } = require('./module_registry')
|
|
2
|
+
const Invalid_Block_Module_Config_Exception = require(
|
|
3
|
+
'../../../validation/exceptions/Invalid_Block_Module_Config_Exception'
|
|
4
|
+
)
|
|
5
|
+
const { Logger } = require('@jetta/logger')
|
|
6
|
+
|
|
7
|
+
const logger = new Logger('create_block_candidates')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Dispatches each name in config.block_module_list to a creator and concatenates results.
|
|
11
|
+
* @param {object} input_data blocksmith-shaped input (container, config, item_list)
|
|
12
|
+
* @param {{ registry?: Record<string, Function> }} [options]
|
|
13
|
+
* @returns {object[]}
|
|
14
|
+
*/
|
|
15
|
+
function create_block_candidates(input_data, options = {})
|
|
16
|
+
{
|
|
17
|
+
const registry = options.registry || MODULE_REGISTRY
|
|
18
|
+
const module_name_list = input_data?.config?.block_module_list || []
|
|
19
|
+
const block_list = []
|
|
20
|
+
|
|
21
|
+
for (const module_name of module_name_list)
|
|
22
|
+
{
|
|
23
|
+
const create_module_blocks = registry[module_name]
|
|
24
|
+
if (!create_module_blocks)
|
|
25
|
+
{
|
|
26
|
+
logger.error(
|
|
27
|
+
`Unknown module: "${module_name}". Valid modules: ${MODULE_NAME_LIST.join(', ')}`
|
|
28
|
+
)
|
|
29
|
+
throw new Invalid_Block_Module_Config_Exception()
|
|
30
|
+
}
|
|
31
|
+
const created_blocks = create_module_blocks(input_data)
|
|
32
|
+
if (Array.isArray(created_blocks) && created_blocks.length > 0)
|
|
33
|
+
{
|
|
34
|
+
block_list.push(...created_blocks)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return block_list
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = create_block_candidates
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const create_tower_blocks = require('./tower_blocks')
|
|
2
|
+
const create_spiral_blocks = require('./spiral_blocks')
|
|
3
|
+
const create_single_item_blocks = require('./single_item_blocks')
|
|
4
|
+
const create_tie_ratio_blocks = require('./tie_ratio_blocks')
|
|
5
|
+
const create_manual_blocks = require('./manual_blocks')
|
|
6
|
+
|
|
7
|
+
const MODULE_REGISTRY = Object.freeze({
|
|
8
|
+
manual_blocks: create_manual_blocks,
|
|
9
|
+
spiral_blocks: create_spiral_blocks,
|
|
10
|
+
tower_blocks: create_tower_blocks,
|
|
11
|
+
single_item_blocks: create_single_item_blocks,
|
|
12
|
+
tie_ratio_blocks: create_tie_ratio_blocks,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const MODULE_NAME_LIST = Object.freeze(Object.keys(MODULE_REGISTRY))
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
MODULE_REGISTRY,
|
|
19
|
+
MODULE_NAME_LIST,
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves CJS/ESM default export and invokes a block creator with input data.
|
|
3
|
+
* @param {unknown} imported_module
|
|
4
|
+
* @param {object} input_data
|
|
5
|
+
* @returns {object[]}
|
|
6
|
+
*/
|
|
7
|
+
function run_creator(imported_module, input_data)
|
|
8
|
+
{
|
|
9
|
+
const create_blocks = resolve_create_blocks(imported_module)
|
|
10
|
+
const block_list = create_blocks(input_data)
|
|
11
|
+
return Array.isArray(block_list) ? block_list : []
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {unknown} imported_module
|
|
16
|
+
* @returns {(input_data: object) => object[]}
|
|
17
|
+
*/
|
|
18
|
+
function resolve_create_blocks(imported_module)
|
|
19
|
+
{
|
|
20
|
+
if (typeof imported_module === 'function')
|
|
21
|
+
{
|
|
22
|
+
return imported_module
|
|
23
|
+
}
|
|
24
|
+
if (imported_module && typeof imported_module.default === 'function')
|
|
25
|
+
{
|
|
26
|
+
return imported_module.default
|
|
27
|
+
}
|
|
28
|
+
throw new Error('Block creator module does not export a callable default')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
run_creator,
|
|
33
|
+
resolve_create_blocks,
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { run_creator } = require('./run_creator')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} input_data
|
|
5
|
+
* @returns {object[]}
|
|
6
|
+
*/
|
|
7
|
+
function create_single_item_blocks(input_data)
|
|
8
|
+
{
|
|
9
|
+
return run_creator(require('@jettacargo/single-item-block-creator-core'), input_data)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = create_single_item_blocks
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { run_creator } = require('./run_creator')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} input_data
|
|
5
|
+
* @returns {object[]}
|
|
6
|
+
*/
|
|
7
|
+
function create_spiral_blocks(input_data)
|
|
8
|
+
{
|
|
9
|
+
return run_creator(require('@jettacargo/spiral-block-creator-core'), input_data)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = create_spiral_blocks
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { run_creator } = require('./run_creator')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} input_data
|
|
5
|
+
* @returns {object[]}
|
|
6
|
+
*/
|
|
7
|
+
function create_tie_ratio_blocks(input_data)
|
|
8
|
+
{
|
|
9
|
+
return run_creator(require('@jetta/tie-ratio-block-creator-core'), input_data)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = create_tie_ratio_blocks
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { run_creator } = require('./run_creator')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} input_data
|
|
5
|
+
* @returns {object[]}
|
|
6
|
+
*/
|
|
7
|
+
function create_tower_blocks(input_data)
|
|
8
|
+
{
|
|
9
|
+
return run_creator(require('@jettacargo/tower-block-creator-core'), input_data)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = create_tower_blocks
|
package/src/input_preparation/block_preparation/exceptions/Failed_To_Create_Block_Exception.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { build_message_entry } = require('../../../messages/resolve_error_message_entry')
|
|
2
|
+
const { ALLOCATOR_MESSAGE } = require('../../../messages/Allocator_Message')
|
|
3
|
+
|
|
4
|
+
class Failed_To_Create_Block_Exception extends Error
|
|
5
|
+
{
|
|
6
|
+
constructor()
|
|
7
|
+
{
|
|
8
|
+
const message_key = ALLOCATOR_MESSAGE.FAILED_TO_CREATE_BLOCKS
|
|
9
|
+
super(message_key)
|
|
10
|
+
this.message_entry = build_message_entry(message_key)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = Failed_To_Create_Block_Exception
|
package/src/input_preparation/block_preparation/exceptions/Failed_To_Retrieve_Block_Exception.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { build_message_entry } = require('../../../messages/resolve_error_message_entry')
|
|
2
|
+
const { ALLOCATOR_MESSAGE } = require('../../../messages/Allocator_Message')
|
|
3
|
+
|
|
4
|
+
class Failed_To_Retrieve_Block_Exception extends Error
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} path
|
|
8
|
+
*/
|
|
9
|
+
constructor(path)
|
|
10
|
+
{
|
|
11
|
+
const message_key = ALLOCATOR_MESSAGE.FAILED_TO_RETRIEVE_BLOCK
|
|
12
|
+
super(message_key)
|
|
13
|
+
this.message_entry = build_message_entry(message_key, [String(path)])
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = Failed_To_Retrieve_Block_Exception
|
package/src/input_preparation/block_preparation/exceptions/No_Blocks_Were_Created_Exception.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { build_message_entry } = require('../../../messages/resolve_error_message_entry')
|
|
2
|
+
const { ALLOCATOR_MESSAGE } = require('../../../messages/Allocator_Message')
|
|
3
|
+
|
|
4
|
+
class No_Blocks_Were_Created_Exception extends Error
|
|
5
|
+
{
|
|
6
|
+
constructor()
|
|
7
|
+
{
|
|
8
|
+
const message_key = ALLOCATOR_MESSAGE.NO_BLOCKS_WERE_CREATED
|
|
9
|
+
super(message_key)
|
|
10
|
+
this.message_entry = build_message_entry(message_key)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = No_Blocks_Were_Created_Exception
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const Config = require('../../../models/Cargo_Profile')
|
|
2
|
+
|
|
3
|
+
module.exports = function create_blocksmith_input(block_path_list, transport, item_list)
|
|
4
|
+
{
|
|
5
|
+
const item_data_list = create_input_item_list(item_list)
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
container: create_container_data(transport),
|
|
9
|
+
config: create_config(),
|
|
10
|
+
item_list: item_data_list,
|
|
11
|
+
block_path_list: block_path_list
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function create_config()
|
|
16
|
+
{
|
|
17
|
+
const config = {
|
|
18
|
+
block_module_list: Config.block_module_list(),
|
|
19
|
+
max_tower_height_superior_gap: Config.max_tower_height_superior_gap(),
|
|
20
|
+
max_tower_height_inferior_gap: Config.max_tower_height_inferior_gap(),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (Config.tie_ratio_allocate_remainder_as_partial_blocks())
|
|
24
|
+
{
|
|
25
|
+
config.allocate_remainder_as_partial_blocks = true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return config
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function create_container_data(transport)
|
|
32
|
+
{
|
|
33
|
+
const tallest_container = transport.containers.reduce((acc, cur) => cur.altura > acc.altura ? acc = cur : cur = cur, '')
|
|
34
|
+
return {
|
|
35
|
+
width: tallest_container.largura,
|
|
36
|
+
height: tallest_container.altura,
|
|
37
|
+
length: tallest_container.comprimento,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function create_input_item_list(item_list)
|
|
42
|
+
{
|
|
43
|
+
return item_list.map(item => create_input_item_data(item))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function create_input_item_data(item)
|
|
47
|
+
{
|
|
48
|
+
const item_json = item.get_json()
|
|
49
|
+
return {
|
|
50
|
+
'id': item_json._id,
|
|
51
|
+
'length': item_json.length || item_json.comprimento,
|
|
52
|
+
'width': item_json.width || item_json.largura,
|
|
53
|
+
'height': item_json.height || item_json.altura,
|
|
54
|
+
'weight': item_json.weight || item_json.peso,
|
|
55
|
+
'supported_weight': item_json.supported_weight || item_json.pesoMaxSuportado,
|
|
56
|
+
'maximum_stacking': item_json.maximum_stacking || item_json.empilhamentoMaximo,
|
|
57
|
+
'stacking_rule': get_stacking_unit(item_json.stackingUnit),
|
|
58
|
+
'amount': item_json.amount || item_json.qtd,
|
|
59
|
+
'type': item_json.type || item_json.tipo,
|
|
60
|
+
'priority': item_json.priority || item_json.prioridade,
|
|
61
|
+
'rotation_list': rotation_list(
|
|
62
|
+
item_json.rotacao !== undefined ? item_json.rotacao : item_json.rotation_list
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function get_stacking_unit(value)
|
|
68
|
+
{
|
|
69
|
+
if (value.toLowerCase() === 'supportedweight')
|
|
70
|
+
{
|
|
71
|
+
return 'SUPPORTED_WEIGHT'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (value.toLowerCase() === 'maximumStacking')
|
|
75
|
+
{
|
|
76
|
+
return 'MAXIMUM_STACKING'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return 'BOTH'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function rotation_list(rotation_map)
|
|
83
|
+
{
|
|
84
|
+
const rotation_list = []
|
|
85
|
+
|
|
86
|
+
for (const key in rotation_map)
|
|
87
|
+
{
|
|
88
|
+
if (rotation_map[key])
|
|
89
|
+
{
|
|
90
|
+
const rotation = key.replace('pos', 'position')
|
|
91
|
+
rotation_list.push(rotation)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return rotation_list
|
|
96
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const Failed_To_Retrieve_Block_Exception = require('../exceptions/Failed_To_Retrieve_Block_Exception')
|
|
2
|
+
const Missing_Object_Store_Exception = require('../exceptions/Missing_Object_Store_Exception')
|
|
3
|
+
const is_valid_array = require('../../../tools/Array_Validator')
|
|
4
|
+
const Config = require('../../../models/Cargo_Profile')
|
|
5
|
+
const { Logger } = require('@jetta/logger')
|
|
6
|
+
const logger = new Logger('Manual Blocks')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Loads manually created blocks through the injected object store.
|
|
10
|
+
* @param {string[]} block_path_list
|
|
11
|
+
* @param {{ get_object: (bucket_name: string, object_key: string) => Promise<string>|string }} [object_store]
|
|
12
|
+
* @returns {Promise<object[]>}
|
|
13
|
+
*/
|
|
14
|
+
async function create_manual_blocks(block_path_list, object_store)
|
|
15
|
+
{
|
|
16
|
+
if (!manual_blocks_requested(block_path_list))
|
|
17
|
+
{
|
|
18
|
+
logger.warn('it was not informed any path of the manually created blocks.')
|
|
19
|
+
return []
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
assert_object_store(object_store)
|
|
23
|
+
return read_manual_blocks(block_path_list, object_store)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string[]} block_path_list
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
function manual_blocks_requested(block_path_list)
|
|
31
|
+
{
|
|
32
|
+
return is_valid_array(block_path_list) && Config.block_module_list().includes('manual_blocks')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {{ get_object?: Function }} object_store
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
function assert_object_store(object_store)
|
|
40
|
+
{
|
|
41
|
+
if (object_store == null || typeof object_store.get_object !== 'function')
|
|
42
|
+
{
|
|
43
|
+
throw new Missing_Object_Store_Exception()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {string[]} block_path_list
|
|
49
|
+
* @param {{ get_object: Function }} object_store
|
|
50
|
+
* @returns {Promise<object[]>}
|
|
51
|
+
*/
|
|
52
|
+
async function read_manual_blocks(block_path_list, object_store)
|
|
53
|
+
{
|
|
54
|
+
for (const path of block_path_list)
|
|
55
|
+
{
|
|
56
|
+
try
|
|
57
|
+
{
|
|
58
|
+
const bucket_name = process.env.MANUAL_BLOCKS_BUCKET_NAME
|
|
59
|
+
const block_str_list = await object_store.get_object(bucket_name, path)
|
|
60
|
+
return read_output(block_str_list)
|
|
61
|
+
}
|
|
62
|
+
catch (error)
|
|
63
|
+
{
|
|
64
|
+
logger.error(error.message)
|
|
65
|
+
logger.error(error.stack)
|
|
66
|
+
throw new Failed_To_Retrieve_Block_Exception(path)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return []
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} block_str_list
|
|
75
|
+
* @returns {object[]}
|
|
76
|
+
*/
|
|
77
|
+
function read_output(block_str_list)
|
|
78
|
+
{
|
|
79
|
+
const block_data_list = JSON.parse(block_str_list)
|
|
80
|
+
return block_data_list.map(normalize_manual_block)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {object} block_data
|
|
85
|
+
* @returns {object}
|
|
86
|
+
*/
|
|
87
|
+
function normalize_manual_block(block_data)
|
|
88
|
+
{
|
|
89
|
+
return {
|
|
90
|
+
...block_data,
|
|
91
|
+
slot_list: block_data.positioned_items
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = create_manual_blocks
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const mm_to_allocation_domain = require('../tools/mm_to_allocation_domain')
|
|
2
|
+
const min_extents_from_items = require('./min_extents_from_items')
|
|
3
|
+
const { merge_tolerance_from_operational_gaps } = require('@jetta/empty-spaces-manager')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Optional third-argument shape for {@link EmptySpaceFinder} from request `config` and item rotation minima.
|
|
7
|
+
* Tolerance math lives in `@jetta/empty-spaces-manager` (`merge_tolerance_from_operational_gaps`).
|
|
8
|
+
* @param {object} config - Parsed `config` with `algoritmo` (may include `empty_space_merge_*` there).
|
|
9
|
+
* @param {Array} items_to_allocate - Items with `get_all_rotated_options`.
|
|
10
|
+
* @returns {{ merge_tolerance: { epsilon_x: number, epsilon_z: number, max_vertical_offset: number } }|undefined}
|
|
11
|
+
*/
|
|
12
|
+
function build_empty_space_finder_options(config, items_to_allocate)
|
|
13
|
+
{
|
|
14
|
+
const algo = config.algoritmo ?? {}
|
|
15
|
+
const pct_w = algo.empty_space_merge_gap_percent_width ?? 0
|
|
16
|
+
const pct_l = algo.empty_space_merge_gap_percent_length ?? 0
|
|
17
|
+
const mm_gap = algo.empty_space_merge_max_vertical_offset_mm ?? 0
|
|
18
|
+
if (pct_w <= 0 && pct_l <= 0 && mm_gap <= 0)
|
|
19
|
+
{
|
|
20
|
+
return undefined
|
|
21
|
+
}
|
|
22
|
+
const mins = min_extents_from_items(items_to_allocate)
|
|
23
|
+
let max_vertical_offset = 0
|
|
24
|
+
if (mm_gap > 0)
|
|
25
|
+
{
|
|
26
|
+
max_vertical_offset = mm_to_allocation_domain(mm_gap)
|
|
27
|
+
}
|
|
28
|
+
const merge_tolerance = merge_tolerance_from_operational_gaps(
|
|
29
|
+
{
|
|
30
|
+
gap_percent_width: pct_w,
|
|
31
|
+
gap_percent_length: pct_l,
|
|
32
|
+
max_vertical_offset: max_vertical_offset
|
|
33
|
+
},
|
|
34
|
+
{min_width: mins.min_width, min_length: mins.min_length}
|
|
35
|
+
)
|
|
36
|
+
if (merge_tolerance === null)
|
|
37
|
+
{
|
|
38
|
+
return undefined
|
|
39
|
+
}
|
|
40
|
+
return { merge_tolerance }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = build_empty_space_finder_options
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const Allocation_Item = require('../../models/Allocation_Item')
|
|
2
|
+
const create_input = require('../stackability_index/Stackability_Input_Creator')
|
|
3
|
+
const calculate_stackability_index = require('@jettacargo/stackability-index-calculator-core').default
|
|
4
|
+
|
|
5
|
+
module.exports = function(item_data_list)
|
|
6
|
+
{
|
|
7
|
+
const item_input_list = create_input(item_data_list)
|
|
8
|
+
const stackability_index_list = calculate_stackability_index(item_input_list)
|
|
9
|
+
set_stackability_index_to_items(item_data_list, stackability_index_list)
|
|
10
|
+
const item_object_list = create_item_object_list(item_data_list)
|
|
11
|
+
return item_object_list
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function set_stackability_index_to_items(item_data_list, stackability_index_list)
|
|
15
|
+
{
|
|
16
|
+
for (let index = 0; index < item_data_list.length; index++)
|
|
17
|
+
{
|
|
18
|
+
const stackability_index = stackability_index_list[index]
|
|
19
|
+
const item = item_data_list[index]
|
|
20
|
+
item.stackability_index = stackability_index
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function create_item_object_list(item_data_list)
|
|
25
|
+
{
|
|
26
|
+
return item_data_list.map(item_data => new Allocation_Item(item_data))
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global minima of width (X), length (Z), and height (Y) over every allowed rotation of each item.
|
|
3
|
+
* @param {Array<{ get_all_rotated_options: () => Array<{ get_width: () => number, get_length: () => number, get_height: () => number }> }>} items_to_allocate - Prepared allocation items.
|
|
4
|
+
* @returns {{ min_width: number, min_length: number, min_height: number }}
|
|
5
|
+
*/
|
|
6
|
+
function min_extents_from_items(items_to_allocate)
|
|
7
|
+
{
|
|
8
|
+
let min_width = Infinity
|
|
9
|
+
let min_length = Infinity
|
|
10
|
+
let min_height = Infinity
|
|
11
|
+
for (let i = 0; i < items_to_allocate.length; i++)
|
|
12
|
+
{
|
|
13
|
+
const rotations = items_to_allocate[i].get_all_rotated_options()
|
|
14
|
+
for (let r = 0; r < rotations.length; r++)
|
|
15
|
+
{
|
|
16
|
+
const ri = rotations[r]
|
|
17
|
+
min_width = Math.min(min_width, ri.get_width())
|
|
18
|
+
min_length = Math.min(min_length, ri.get_length())
|
|
19
|
+
min_height = Math.min(min_height, ri.get_height())
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!Number.isFinite(min_width))
|
|
23
|
+
{
|
|
24
|
+
return {min_width: 0, min_length: 0, min_height: 0}
|
|
25
|
+
}
|
|
26
|
+
return {min_width, min_length, min_height}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = min_extents_from_items
|