@jetta/blocks-allocator 0.2.1-1 → 0.2.1-3

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.
Files changed (19) hide show
  1. package/package.json +1 -1
  2. package/src/Allocation_Optimization/item_consumption_heuristic/Item_Chooser.js +6 -138
  3. package/src/Allocation_Optimization/item_consumption_heuristic/axle_load/axle_load_exceeds_limit.js +27 -16
  4. package/src/Allocation_Optimization/item_consumption_heuristic/axle_load/candidate_item_axle_score.js +42 -0
  5. package/src/Allocation_Optimization/item_consumption_heuristic/axle_load/evaluate_layout_axle_load.js +28 -8
  6. package/src/Allocation_Optimization/item_consumption_heuristic/axle_load/layout_fits_axle_load.js +3 -2
  7. package/src/Allocation_Optimization/item_consumption_heuristic/select_axle_balanced_slot_item.js +143 -0
  8. package/src/Allocation_Optimization/item_consumption_heuristic/select_slot_item.js +149 -0
  9. package/src/Allocation_Optimization/item_consumption_heuristic/slot_candidate_acceptance.js +110 -0
  10. package/src/Allocation_Optimization/item_consumption_heuristic/slot_candidate_order.js +49 -0
  11. package/src/allocation_flow/leftover_catalog_retry.js +67 -0
  12. package/src/allocation_flow/run_allocation_iteration.js +4 -25
  13. package/src/models/transport/Container.js +11 -0
  14. package/src/space_and_block_chooser/compound_first_with_leftover_fill.js +2 -2
  15. package/src/space_and_block_chooser/leftover_sku_hashes.js +159 -0
  16. package/src/space_and_block_chooser/leftover_space_memory.js +21 -5
  17. package/src/space_and_block_chooser/leftover_unitary_admission.js +89 -0
  18. package/src/space_and_block_chooser/leftover_unitary_blocks.js +73 -98
  19. package/src/space_and_block_chooser/leftover_unitary_empty_spaces.js +2 -2
@@ -1,114 +1,90 @@
1
- const { cube_map_function } = require('../Blocks_Preparation/Cube_Map_Function')
2
- const round = require('../tools/Rounder')
1
+ const {
2
+ remember_leftover_sku_hashes,
3
+ leftover_sku_shape_hashes,
4
+ to_hash_set,
5
+ compound_slot_shape_hashes,
6
+ is_unitary_matching_hashes,
7
+ cube_map_function,
8
+ swapped_length_width_hash
9
+ } = require('./leftover_sku_hashes')
10
+ const {
11
+ unite_with_hidden_unitaries,
12
+ unitaries_outside_remembered_hashes,
13
+ blocks_are_remembered_unitaries_only
14
+ } = require('./leftover_unitary_admission')
3
15
 
4
16
  /**
5
17
  * 1-slot blocks of leftover SKUs: not used by remaining compounds, or remembered after compounds are gone.
18
+ * When `admit_other_unitaries` is true, other 1-slot blocks are included without changing stored hashes.
6
19
  * @param {object[]} pre_selected_block_list
7
20
  * @param {object[]} compound_block_list
8
21
  * @param {Set<string>|string[]} [remembered_sku_hashes]
22
+ * @param {boolean} [admit_other_unitaries]
9
23
  * @returns {object[]}
10
24
  */
11
- function leftover_unitary_blocks(pre_selected_block_list, compound_block_list, remembered_sku_hashes)
25
+ function leftover_unitary_blocks(
26
+ pre_selected_block_list,
27
+ compound_block_list,
28
+ remembered_sku_hashes,
29
+ admit_other_unitaries
30
+ )
12
31
  {
13
- const remembered = to_hash_set(remembered_sku_hashes)
14
- if (remembered.size > 0)
32
+ const remembered_matches = remembered_or_current_unitaries(
33
+ pre_selected_block_list,
34
+ compound_block_list,
35
+ remembered_sku_hashes
36
+ )
37
+ if (admit_other_unitaries !== true)
15
38
  {
16
- return pre_selected_block_list.filter(block => is_unitary_matching_hashes(block, remembered))
39
+ return remembered_matches
17
40
  }
18
- return pre_selected_block_list.filter(
19
- block => is_leftover_unitary_block(block, compound_slot_shape_hashes(compound_block_list))
41
+ return unite_with_hidden_unitaries(
42
+ pre_selected_block_list,
43
+ remembered_matches,
44
+ remembered_sku_hashes
20
45
  )
21
46
  }
22
47
 
23
48
  /**
24
- * Stores leftover SKU shape hashes while compounds still remain.
25
- * @param {{ leftover_sku_shape_hashes?: string[] }|undefined} session
26
- * @param {object[]} leftover_block_list
49
+ * Applies the session allow-list, including hidden unitaries after the one-shot release.
50
+ * @param {object[]} pre_selected_block_list
27
51
  * @param {object[]} compound_block_list
52
+ * @param {{ leftover_sku_shape_hashes?: string[], admit_non_remembered_unitaries?: boolean }|undefined} session
53
+ * @returns {object[]}
28
54
  */
29
- function remember_leftover_sku_hashes(session, leftover_block_list, compound_block_list)
55
+ function leftover_unitary_blocks_from_session(pre_selected_block_list, compound_block_list, session)
30
56
  {
31
- if (!session || compound_block_list.length === 0 || leftover_block_list.length === 0)
32
- {
33
- return
34
- }
35
- if (session.leftover_sku_shape_hashes?.length > 0)
36
- {
37
- return
38
- }
39
- session.leftover_sku_shape_hashes = [...leftover_sku_shape_hashes(leftover_block_list)]
57
+ return leftover_unitary_blocks(
58
+ pre_selected_block_list,
59
+ compound_block_list,
60
+ session?.leftover_sku_shape_hashes,
61
+ session?.admit_non_remembered_unitaries === true
62
+ )
40
63
  }
41
64
 
42
65
  /**
43
- * Width/height/length hashes for leftover 1-slot blocks, including swapped floor axes.
44
- * @param {object[]} leftover_block_list
45
- * @returns {Set<string>}
66
+ * @param {object[]} pre_selected_block_list
67
+ * @param {object[]} compound_block_list
68
+ * @param {Set<string>|string[]|undefined} remembered_sku_hashes
69
+ * @returns {object[]}
46
70
  */
47
- function leftover_sku_shape_hashes(leftover_block_list)
48
- {
49
- const hashes = new Set()
50
- for (const block of leftover_block_list)
51
- {
52
- add_slot_orientation_hashes(hashes, block)
53
- }
54
- return hashes
55
- }
56
-
57
- function add_slot_orientation_hashes(hashes, block)
58
- {
59
- if (typeof block.get_slot_list !== 'function')
60
- {
61
- return
62
- }
63
- const slot_list = block.get_slot_list()
64
- if (slot_list.length !== 1 || typeof slot_list[0].get_width !== 'function')
65
- {
66
- return
67
- }
68
- hashes.add(cube_map_function(slot_list[0]))
69
- hashes.add(swapped_length_width_hash(slot_list[0]))
70
- }
71
-
72
- function swapped_length_width_hash(slot)
73
- {
74
- return round(slot.get_length()) + ';' + round(slot.get_height()) + ';' + round(slot.get_width())
75
- }
76
-
77
- function to_hash_set(remembered_sku_hashes)
71
+ function remembered_or_current_unitaries(pre_selected_block_list, compound_block_list, remembered_sku_hashes)
78
72
  {
79
- if (!remembered_sku_hashes)
80
- {
81
- return new Set()
82
- }
83
- if (remembered_sku_hashes instanceof Set)
84
- {
85
- return remembered_sku_hashes
86
- }
87
- return new Set(remembered_sku_hashes)
88
- }
89
-
90
- function compound_slot_shape_hashes(compound_block_list)
91
- {
92
- const hashes = new Set()
93
- for (const block of compound_block_list)
73
+ const remembered = to_hash_set(remembered_sku_hashes)
74
+ if (remembered.size > 0)
94
75
  {
95
- if (typeof block.get_slot_list !== 'function')
96
- {
97
- continue
98
- }
99
- for (const slot of block.get_slot_list())
100
- {
101
- if (typeof slot.get_width !== 'function')
102
- {
103
- continue
104
- }
105
- hashes.add(cube_map_function(slot))
106
- hashes.add(swapped_length_width_hash(slot))
107
- }
76
+ return pre_selected_block_list.filter(block => is_unitary_matching_hashes(block, remembered))
108
77
  }
109
- return hashes
78
+ return pre_selected_block_list.filter(
79
+ block => is_leftover_unitary_block(block, compound_slot_shape_hashes(compound_block_list))
80
+ )
110
81
  }
111
82
 
83
+ /**
84
+ * @param {object} block
85
+ * @param {Set<string>} compound_slot_hashes
86
+ * @returns {boolean}
87
+ */
112
88
  function is_leftover_unitary_block(block, compound_slot_hashes)
113
89
  {
114
90
  if (typeof block.get_slot_list !== 'function')
@@ -128,26 +104,25 @@ function is_leftover_unitary_block(block, compound_slot_hashes)
128
104
  {
129
105
  return true
130
106
  }
131
- return !compound_slot_hashes.has(cube_map_function(slot_list[0]))
132
- && !compound_slot_hashes.has(swapped_length_width_hash(slot_list[0]))
107
+ return slot_shape_is_absent(slot_list[0], compound_slot_hashes)
133
108
  }
134
109
 
135
- function is_unitary_matching_hashes(block, remembered)
110
+ /**
111
+ * @param {object} slot
112
+ * @param {Set<string>} compound_slot_hashes
113
+ * @returns {boolean}
114
+ */
115
+ function slot_shape_is_absent(slot, compound_slot_hashes)
136
116
  {
137
- if (typeof block.get_slot_list !== 'function')
138
- {
139
- return false
140
- }
141
- const slot_list = block.get_slot_list()
142
- if (slot_list.length !== 1 || typeof slot_list[0].get_width !== 'function')
143
- {
144
- return false
145
- }
146
- return remembered.has(cube_map_function(slot_list[0]))
147
- || remembered.has(swapped_length_width_hash(slot_list[0]))
117
+ const matches_cube = compound_slot_hashes.has(cube_map_function(slot))
118
+ const matches_swap = compound_slot_hashes.has(swapped_length_width_hash(slot))
119
+ return !matches_cube && !matches_swap
148
120
  }
149
121
 
150
122
  leftover_unitary_blocks.remember_leftover_sku_hashes = remember_leftover_sku_hashes
151
123
  leftover_unitary_blocks.leftover_sku_shape_hashes = leftover_sku_shape_hashes
124
+ leftover_unitary_blocks.from_session = leftover_unitary_blocks_from_session
125
+ leftover_unitary_blocks.unitaries_outside_remembered_hashes = unitaries_outside_remembered_hashes
126
+ leftover_unitary_blocks.blocks_are_remembered_unitaries_only = blocks_are_remembered_unitaries_only
152
127
 
153
128
  module.exports = leftover_unitary_blocks
@@ -119,10 +119,10 @@ function resolve_compound_first_or_leftover(
119
119
  empty_space_list,
120
120
  pre_selected_block_list,
121
121
  leftover_empty_spaces,
122
- leftover_unitary_blocks(
122
+ leftover_unitary_blocks.from_session(
123
123
  pre_selected_block_list,
124
124
  compound_block_list,
125
- filter_data.obligate_compound_session?.leftover_sku_shape_hashes
125
+ filter_data.obligate_compound_session
126
126
  )
127
127
  )
128
128
  }