@jetta/cargo-stabilizer 0.1.0-14 → 0.1.0-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.
- package/CHANGELOG.md +1 -26
- package/README.md +12 -53
- package/build/core/adapters/axle_adapter.d.ts +4 -4
- package/build/core/adapters/axle_adapter.d.ts.map +1 -1
- package/build/core/adapters/axle_adapter.js +11 -13
- package/build/core/adapters/coordinate_mapper.d.ts +5 -5
- package/build/core/adapters/coordinate_mapper.d.ts.map +1 -1
- package/build/core/adapters/coordinate_mapper.js +13 -13
- package/build/core/adapters/stability_adapter.d.ts +1 -1
- package/build/core/adapters/stability_adapter.d.ts.map +1 -1
- package/build/core/adapters/stability_adapter.js +1 -1
- package/build/core/candidates/build_candidate_context.d.ts +1 -1
- package/build/core/candidates/build_candidate_context.d.ts.map +1 -1
- package/build/core/candidates/build_candidate_context.js +1 -3
- package/build/core/candidates/candidate_context.d.ts +1 -4
- package/build/core/candidates/candidate_context.d.ts.map +1 -1
- package/build/core/candidates/candidate_generator.d.ts +1 -1
- package/build/core/candidates/candidate_generator.d.ts.map +1 -1
- package/build/core/candidates/candidate_generator.js +16 -33
- package/build/core/candidates/candidate_validation.d.ts +12 -0
- package/build/core/candidates/candidate_validation.d.ts.map +1 -1
- package/build/core/candidates/candidate_validation.js +26 -36
- package/build/core/candidates/rank_candidates.d.ts.map +1 -1
- package/build/core/candidates/rank_candidates.js +0 -3
- package/build/core/evaluation/evaluation_context.d.ts +1 -3
- package/build/core/evaluation/evaluation_context.d.ts.map +1 -1
- package/build/core/evaluation/state_evaluator.d.ts +1 -12
- package/build/core/evaluation/state_evaluator.d.ts.map +1 -1
- package/build/core/evaluation/state_evaluator.js +7 -31
- package/build/core/factory/read_stabilizer_config.d.ts +2 -4
- package/build/core/factory/read_stabilizer_config.d.ts.map +1 -1
- package/build/core/factory/read_stabilizer_config.js +25 -6
- package/build/core/filters/loose_item_filter.d.ts +2 -2
- package/build/core/filters/loose_item_filter.d.ts.map +1 -1
- package/build/core/filters/loose_item_filter.js +3 -3
- package/build/core/geometry/box_geometry.d.ts +1 -17
- package/build/core/geometry/box_geometry.d.ts.map +1 -1
- package/build/core/geometry/box_geometry.js +2 -67
- package/build/core/move/apply_move.d.ts +1 -3
- package/build/core/move/apply_move.d.ts.map +1 -1
- package/build/core/move/apply_move.js +1 -1
- package/build/core/orchestration/StabilizerFlow.d.ts +1 -2
- package/build/core/orchestration/StabilizerFlow.d.ts.map +1 -1
- package/build/core/orchestration/StabilizerFlow.js +2 -2
- package/build/core/orchestration/build_reorder_context.d.ts +1 -1
- package/build/core/orchestration/build_reorder_context.d.ts.map +1 -1
- package/build/core/orchestration/build_reorder_context.js +12 -10
- package/build/core/strategies/reorder/BeamSearchReorder.d.ts +1 -1
- package/build/core/strategies/reorder/BeamSearchReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/BeamSearchReorder.js +6 -7
- package/build/core/strategies/reorder/GeneticReorder.d.ts +1 -1
- package/build/core/strategies/reorder/GeneticReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/GravityCompaction.d.ts +1 -1
- package/build/core/strategies/reorder/GravityCompaction.d.ts.map +1 -1
- package/build/core/strategies/reorder/GravityCompaction.js +2 -2
- package/build/core/strategies/reorder/GreedyReorder.d.ts +1 -1
- package/build/core/strategies/reorder/GreedyReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/ReorderStrategy.d.ts +1 -3
- package/build/core/strategies/reorder/ReorderStrategy.d.ts.map +1 -1
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts +1 -1
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/anneal_helpers.d.ts +1 -1
- package/build/core/strategies/reorder/anneal_helpers.d.ts.map +1 -1
- package/build/core/strategies/reorder/anneal_helpers.js +1 -1
- package/build/core/strategies/reorder/apply_if_gates_pass.d.ts +1 -1
- package/build/core/strategies/reorder/apply_if_gates_pass.d.ts.map +1 -1
- package/build/core/strategies/reorder/beam_context.d.ts +1 -1
- package/build/core/strategies/reorder/beam_context.d.ts.map +1 -1
- package/build/core/strategies/reorder/genetic/Chromosome.d.ts +1 -1
- package/build/core/strategies/reorder/genetic/Chromosome.d.ts.map +1 -1
- package/build/core/strategies/reorder/genetic/Chromosome.js +2 -2
- package/build/core/strategies/reorder/greedy_improvement.d.ts +1 -1
- package/build/core/strategies/reorder/greedy_improvement.d.ts.map +1 -1
- package/build/core/strategies/reorder/greedy_improvement.js +2 -2
- package/build/core/validation/parse_stabilizer_input.d.ts +8 -0
- package/build/core/validation/parse_stabilizer_input.d.ts.map +1 -0
- package/build/core/validation/parse_stabilizer_input.js +20 -0
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts +1 -5
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts.map +1 -1
- package/build/core/validation/schemas/stabilizer_config_schema.js +1 -5
- package/build/core/validation/schemas/stabilizer_input_schema.d.ts +110 -0
- package/build/core/validation/schemas/stabilizer_input_schema.d.ts.map +1 -0
- package/build/core/validation/schemas/stabilizer_input_schema.js +34 -0
- package/build/core/validation/schemas/stabilizer_output_schema.d.ts +13 -0
- package/build/core/validation/schemas/stabilizer_output_schema.d.ts.map +1 -0
- package/build/core/validation/schemas/stabilizer_output_schema.js +6 -0
- package/build/core/waypoint/build_waypoint_zones.d.ts +1 -1
- package/build/core/waypoint/build_waypoint_zones.d.ts.map +1 -1
- package/build/core/waypoint/build_waypoint_zones.js +2 -2
- package/build/core/waypoint/preserves_waypoint_order.d.ts +1 -1
- package/build/core/waypoint/preserves_waypoint_order.d.ts.map +1 -1
- package/build/core/waypoint/validate_waypoint_ids.d.ts +1 -1
- package/build/core/waypoint/validate_waypoint_ids.d.ts.map +1 -1
- package/build/index.d.ts +6 -15
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -30
- package/package.json +1 -1
- package/build/core/adapters/build_axle_request.d.ts +0 -15
- package/build/core/adapters/build_axle_request.d.ts.map +0 -1
- package/build/core/adapters/build_axle_request.js +0 -39
- package/build/core/adapters/empty_space_adapter.d.ts +0 -10
- package/build/core/adapters/empty_space_adapter.d.ts.map +0 -1
- package/build/core/adapters/empty_space_adapter.js +0 -24
- package/build/core/adapters/map_item_to_positioned_cube.d.ts +0 -9
- package/build/core/adapters/map_item_to_positioned_cube.d.ts.map +0 -1
- package/build/core/adapters/map_item_to_positioned_cube.js +0 -16
- package/build/core/adapters/run_axle_calculator.d.ts +0 -16
- package/build/core/adapters/run_axle_calculator.d.ts.map +0 -1
- package/build/core/adapters/run_axle_calculator.js +0 -32
- package/build/core/candidates/collect_container_slots.d.ts +0 -16
- package/build/core/candidates/collect_container_slots.d.ts.map +0 -1
- package/build/core/candidates/collect_container_slots.js +0 -20
- package/build/core/candidates/enumerate_empty_space_slots.d.ts +0 -15
- package/build/core/candidates/enumerate_empty_space_slots.d.ts.map +0 -1
- package/build/core/candidates/enumerate_empty_space_slots.js +0 -44
- package/build/core/candidates/enumerate_supporter_top_slots.d.ts +0 -11
- package/build/core/candidates/enumerate_supporter_top_slots.d.ts.map +0 -1
- package/build/core/candidates/enumerate_supporter_top_slots.js +0 -36
- package/build/core/candidates/is_elevated_on_supporter_origin.d.ts +0 -14
- package/build/core/candidates/is_elevated_on_supporter_origin.d.ts.map +0 -1
- package/build/core/candidates/is_elevated_on_supporter_origin.js +0 -28
- package/build/core/constants/TieRatioOrientation.d.ts +0 -6
- package/build/core/constants/TieRatioOrientation.d.ts.map +0 -1
- package/build/core/constants/TieRatioOrientation.js +0 -5
- package/build/core/evaluation/compute_reorder_objective.d.ts +0 -13
- package/build/core/evaluation/compute_reorder_objective.d.ts.map +0 -1
- package/build/core/evaluation/compute_reorder_objective.js +0 -13
- package/build/core/exceptions/AxleCalculationError.d.ts +0 -4
- package/build/core/exceptions/AxleCalculationError.d.ts.map +0 -1
- package/build/core/exceptions/AxleCalculationError.js +0 -6
- package/build/core/exceptions/InvalidStabilizerOutputError.d.ts +0 -4
- package/build/core/exceptions/InvalidStabilizerOutputError.d.ts.map +0 -1
- package/build/core/exceptions/InvalidStabilizerOutputError.js +0 -6
- package/build/core/factory/read_stabilizer_config_helpers.d.ts +0 -29
- package/build/core/factory/read_stabilizer_config_helpers.d.ts.map +0 -1
- package/build/core/factory/read_stabilizer_config_helpers.js +0 -73
- package/build/core/filters/collect_movable_items.d.ts +0 -18
- package/build/core/filters/collect_movable_items.d.ts.map +0 -1
- package/build/core/filters/collect_movable_items.js +0 -53
- package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.d.ts +0 -8
- package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.d.ts.map +0 -1
- package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.js +0 -41
- package/build/core/filters/is_item_on_cm_floor.d.ts +0 -8
- package/build/core/filters/is_item_on_cm_floor.d.ts.map +0 -1
- package/build/core/filters/is_item_on_cm_floor.js +0 -9
- package/build/core/geometry/has_penetrating_overlap.d.ts +0 -9
- package/build/core/geometry/has_penetrating_overlap.d.ts.map +0 -1
- package/build/core/geometry/has_penetrating_overlap.js +0 -27
- package/build/core/orchestration/build_milkrun_bands_from_config.d.ts +0 -13
- package/build/core/orchestration/build_milkrun_bands_from_config.d.ts.map +0 -1
- package/build/core/orchestration/build_milkrun_bands_from_config.js +0 -14
- package/build/core/orchestration/read_primary_env.d.ts +0 -9
- package/build/core/orchestration/read_primary_env.d.ts.map +0 -1
- package/build/core/orchestration/read_primary_env.js +0 -13
- package/build/core/strategies/reorder/select_beam_expansion_candidates.d.ts +0 -9
- package/build/core/strategies/reorder/select_beam_expansion_candidates.d.ts.map +0 -1
- package/build/core/strategies/reorder/select_beam_expansion_candidates.js +0 -28
- package/build/core/strategies/reorder/select_surviving_beam.d.ts +0 -10
- package/build/core/strategies/reorder/select_surviving_beam.d.ts.map +0 -1
- package/build/core/strategies/reorder/select_surviving_beam.js +0 -12
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts +0 -37
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +0 -1
- package/build/core/validation/contract/cargo_movement_wire_field_map.js +0 -43
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts +0 -14
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts.map +0 -1
- package/build/core/validation/contract/cargo_movement_wire_mapper.js +0 -34
- package/build/core/validation/contract/format_zod_error.d.ts +0 -8
- package/build/core/validation/contract/format_zod_error.d.ts.map +0 -1
- package/build/core/validation/contract/format_zod_error.js +0 -11
- package/build/core/validation/contract/index.d.ts +0 -9
- package/build/core/validation/contract/index.d.ts.map +0 -1
- package/build/core/validation/contract/index.js +0 -8
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts +0 -3
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts.map +0 -1
- package/build/core/validation/contract/map_contract_to_wire_shape.js +0 -45
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts +0 -2
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +0 -1
- package/build/core/validation/contract/map_wire_input_to_contract_shape.js +0 -61
- package/build/core/validation/contract/map_wire_item_to_contract.d.ts +0 -12
- package/build/core/validation/contract/map_wire_item_to_contract.d.ts.map +0 -1
- package/build/core/validation/contract/map_wire_item_to_contract.js +0 -57
- package/build/core/validation/contract/parse_stabilizer_input.d.ts +0 -48
- package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +0 -1
- package/build/core/validation/contract/parse_stabilizer_input.js +0 -26
- package/build/core/validation/contract/parse_stabilizer_output.d.ts +0 -50
- package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +0 -1
- package/build/core/validation/contract/parse_stabilizer_output.js +0 -24
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts +0 -101
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +0 -1
- package/build/core/validation/contract/stabilizer_domain_schema.js +0 -64
- package/build/core/validation/contract/stabilizer_input_schema.d.ts +0 -36
- package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +0 -1
- package/build/core/validation/contract/stabilizer_input_schema.js +0 -11
- package/build/core/validation/contract/stabilizer_output_schema.d.ts +0 -76
- package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +0 -1
- package/build/core/validation/contract/stabilizer_output_schema.js +0 -16
- package/build/core/validation/contract/uniquify_contract_item_ids.d.ts +0 -8
- package/build/core/validation/contract/uniquify_contract_item_ids.d.ts.map +0 -1
- package/build/core/validation/contract/uniquify_contract_item_ids.js +0 -38
- package/build/core/validation/contract/wire_mapper_record_utils.d.ts +0 -34
- package/build/core/validation/contract/wire_mapper_record_utils.d.ts.map +0 -1
- package/build/core/validation/contract/wire_mapper_record_utils.js +0 -66
- package/build/core/waypoint/milkrun_wall_reservation.d.ts +0 -24
- package/build/core/waypoint/milkrun_wall_reservation.d.ts.map +0 -1
- package/build/core/waypoint/milkrun_wall_reservation.js +0 -57
- package/build/core/waypoint/milkrun_wall_reservation_helpers.d.ts +0 -15
- package/build/core/waypoint/milkrun_wall_reservation_helpers.d.ts.map +0 -1
- package/build/core/waypoint/milkrun_wall_reservation_helpers.js +0 -48
- package/build/core/waypoint/milkrun_wall_reservation_types.d.ts +0 -16
- package/build/core/waypoint/milkrun_wall_reservation_types.d.ts.map +0 -1
- package/build/core/waypoint/milkrun_wall_reservation_types.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,33 +8,8 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
8
8
|
|
|
9
9
|
### Added
|
|
10
10
|
|
|
11
|
-
- Strict English internal I/O contract with bidirectional cargo-movement wire mapper (`map_wire_input_to_contract`, `map_contract_to_wire_output`).
|
|
12
|
-
- Organization gates: waypoint Z zones, macro delivery order (`preserve_tie_block_organization`), and milkrun wall reservation (`enforce_milkrun_wall_reservation`).
|
|
13
|
-
- Empty-space candidate discovery for floor and elevated slots via `@jetta/empty-spaces-manager`.
|
|
14
|
-
- Supporter-top candidate slots aligned to each stacked item footprint, included in beam expansion (`top_k ∪ supporter_top`).
|
|
15
|
-
- Elevated candidates must sit on a supporter `(x, z)` origin so stacked loose items copy the supporter footprint.
|
|
16
|
-
- `cargo_stabilizer.pin_tie_ratio_blocks` (default `false`): when true, only **floor five-slot** `3_2`/`2_3` walls stay pinned; stacked tie-ratio items and generic groups stay movable.
|
|
17
|
-
- Public contract exports: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_parse_stabilizer_input`, `safe_parse_stabilizer_output`, and related domain types.
|
|
18
|
-
|
|
19
|
-
### Changed
|
|
20
|
-
|
|
21
|
-
- README documents I/O contract mapping, configuration keys, dependencies, and test/coverage commands.
|
|
22
|
-
- Reorder objective is whole-cargo `transport_score`; loose-item score sum is only a tie-break. Axle, waypoint, and milkrun gates are unchanged.
|
|
23
|
-
- `pin_tie_ratio_blocks` pins only floor five-slot `3_2`/`2_3` walls; stacked members of the same group stay movable.
|
|
24
|
-
|
|
25
|
-
### Testing
|
|
26
|
-
|
|
27
|
-
- Expanded Mocha suite to 126 tests mirroring `src/` under `test/src/`.
|
|
28
|
-
- Local coverage gate at 80% on lines, functions, branches, and statements (`npm run coverage`).
|
|
29
|
-
- CI coverage gate at 75% (`npm run coverage:ci`).
|
|
30
|
-
- Mocha setup preloads core modules so c8 attributes coverage consistently across the full suite.
|
|
31
|
-
|
|
32
|
-
## [0.1.0-3] - 2026-08-14
|
|
33
|
-
|
|
34
|
-
### Added
|
|
35
|
-
|
|
36
11
|
- Initial library scaffold (JET-2262).
|
|
37
12
|
- Five config-selectable reorder strategies: gravity, greedy, beam search, simulated annealing, genetic.
|
|
38
|
-
- Zod-validated input contract with
|
|
13
|
+
- Zod-validated input contract with waypoint_id rules and multi-container support.
|
|
39
14
|
- Shared evaluator: cargo-stability transport gate, axle-load-calculator folga gate, waypoint order.
|
|
40
15
|
- Public `stabilize()` API compatible with cargo-movement legacy response shape.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @jetta/cargo-stabilizer
|
|
2
2
|
|
|
3
|
-
TypeScript library that reorders items to improve
|
|
3
|
+
TypeScript library that reorders **loose items only** to improve cargo stability while keeping compound blocks pinned. Implements five config-selectable strategies (JET-2262).
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
@@ -47,35 +47,13 @@ if (response.status === 'success') {
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
## I/O contract
|
|
51
|
-
|
|
52
|
-
The stabilizer uses a **strict English contract** internally (`src/core/validation/contract/`). Cargo-movement wire payloads keep legacy Portuguese keys; a bidirectional mapper translates at the public boundary.
|
|
53
|
-
|
|
54
|
-
| CM wire | Contract (English) |
|
|
55
|
-
|---------|-------------------|
|
|
56
|
-
| `_id` | `item_id` |
|
|
57
|
-
| `groupId` | `group_id` |
|
|
58
|
-
| `w`, `h`, `d` | `width`, `height`, `depth` |
|
|
59
|
-
| `peso` | `weight` |
|
|
60
|
-
| `sequencia` | `sequence` |
|
|
61
|
-
| `largura`, `altura`, `comprimento` | `width`, `height`, `length` |
|
|
62
|
-
| `eixos` | `axles` |
|
|
63
|
-
|
|
64
|
-
Flow: `map_wire_input_to_contract` → strict Zod parse → stabilizer flow → output validation → `map_contract_to_wire_output`.
|
|
65
|
-
|
|
66
|
-
Exported parsers: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_parse_*`.
|
|
67
|
-
|
|
68
50
|
## Configuration
|
|
69
51
|
|
|
70
52
|
| Key | Default | Description |
|
|
71
53
|
|-----|---------|-------------|
|
|
72
54
|
| `cargo_stabilizer.reorder_strategy` | `gravity` | `gravity`, `greedy`, `beam_search`, `simulated_annealing`, `genetic` |
|
|
73
|
-
| `cargo_stabilizer.transport_stability_floor` | `0` | Hard minimum transport stability score
|
|
55
|
+
| `cargo_stabilizer.transport_stability_floor` | `0` | Hard minimum transport stability score |
|
|
74
56
|
| `cargo_stabilizer.max_iteration` | `10` | Greedy / SA iteration budget |
|
|
75
|
-
| `cargo_stabilizer.preserve_tie_block_organization` | `true` | When true, enforce waypoint Z zones and macro delivery order |
|
|
76
|
-
| `cargo_stabilizer.pin_tie_ratio_blocks` | `false` | When true, do not move floor five-slot `3_2`/`2_3` walls; stacked tie-ratio items and other groups remain movable |
|
|
77
|
-
| `cargo_stabilizer.enforce_milkrun_wall_reservation` | `false` | When true, reserve rear compound-wall Z bands using profile key below |
|
|
78
|
-
| `number_of_wall_to_allocate_from_last_waypoints` | `0` | Count of trailing waypoints whose compound walls are reserved (read from `cargo_state.config.algoritmo` when milkrun enforcement is enabled) |
|
|
79
57
|
| `folga_de_peso_nos_eixos` | `0` | Axle folga percent |
|
|
80
58
|
|
|
81
59
|
## Errors
|
|
@@ -83,7 +61,6 @@ Exported parsers: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_par
|
|
|
83
61
|
| Error | When |
|
|
84
62
|
|-------|------|
|
|
85
63
|
| `InvalidStabilizerInputError` | Zod validation failure on input |
|
|
86
|
-
| `InvalidStabilizerOutputError` | Internal response failed output contract parse |
|
|
87
64
|
| `MixedWaypointIdError` | Some items have `waypoint_id` and others omit it |
|
|
88
65
|
| `UnknownReorderStrategyError` | Invalid `cargo_stabilizer.reorder_strategy` |
|
|
89
66
|
|
|
@@ -91,54 +68,36 @@ Import `ZodError` from `zod` when validating externally.
|
|
|
91
68
|
|
|
92
69
|
## Dependencies
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- `@jetta/
|
|
97
|
-
- `@jetta/
|
|
98
|
-
-
|
|
99
|
-
- `@jetta/logger` — structured logging at orchestration boundary (transitive via cargo-stability)
|
|
100
|
-
- `zod` — I/O contract validation
|
|
71
|
+
- `cargo-stability` — transport stability scoring
|
|
72
|
+
- `@jetta/axle-load-calculator` — axle weight validation
|
|
73
|
+
- `@jetta/empty-spaces-manager` — empty region discovery (future slot expansion)
|
|
74
|
+
- `@jetta/logger` — structured logging at orchestration boundary
|
|
75
|
+
- `zod` — input validation
|
|
101
76
|
|
|
102
77
|
## Scripts
|
|
103
78
|
|
|
104
79
|
| Command | Description |
|
|
105
80
|
|---------|-------------|
|
|
106
|
-
| `npm test` | Mocha tests
|
|
81
|
+
| `npm test` | Mocha tests |
|
|
107
82
|
| `npm run lint` | ESLint |
|
|
108
83
|
| `npm run build` | TypeScript compile to `build/` |
|
|
109
|
-
| `npm run coverage` | Tests with
|
|
110
|
-
| `npm run coverage:ci` | Tests with **75%** coverage gate (CI) |
|
|
84
|
+
| `npm run coverage:ci` | Tests with 75% coverage gate |
|
|
111
85
|
| `npm run lint:package` | publint strict check |
|
|
112
86
|
|
|
113
87
|
## Layout
|
|
114
88
|
|
|
115
89
|
- `src/index.ts` — public API (`stabilize`)
|
|
116
|
-
- `src/core/validation
|
|
90
|
+
- `src/core/validation/` — Zod schemas
|
|
117
91
|
- `src/core/strategies/reorder/` — five reorder algorithms
|
|
118
92
|
- `src/core/evaluation/` — shared stability + axle + waypoint gates
|
|
119
|
-
- `src
|
|
120
|
-
- `test/src/` — mirrors `src/`; fixtures under `test/data/src/`
|
|
121
|
-
|
|
122
|
-
## Testing and coverage
|
|
123
|
-
|
|
124
|
-
Tests run via Mocha + Chai with quiet logging (`test/mocha_setup.ts`). Core modules are preloaded at startup so `c8` reports accurate coverage when the full suite runs.
|
|
125
|
-
|
|
126
|
-
| Gate | Command | Threshold |
|
|
127
|
-
|------|---------|-----------|
|
|
128
|
-
| Local | `npm run coverage` | 80% lines, functions, branches, statements |
|
|
129
|
-
| CI | `npm run coverage:ci` | 75% on all metrics |
|
|
93
|
+
- `test/src/` — mirrors `src/`
|
|
130
94
|
|
|
131
95
|
## Test plan
|
|
132
96
|
|
|
133
97
|
```bash
|
|
134
|
-
npm test -- --grep "wire_mapper_shape"
|
|
135
98
|
npm test -- --grep "input_validation"
|
|
136
99
|
npm test -- --grep "waypoint_order"
|
|
137
|
-
npm test -- --grep "milkrun_wall_reservation"
|
|
138
|
-
npm test -- --grep "apply_move"
|
|
139
|
-
npm test -- --grep "state_evaluator"
|
|
140
100
|
npm test -- --grep "gravity_compaction"
|
|
141
|
-
npm test -- --grep "
|
|
101
|
+
npm test -- --grep "greedy_reorder"
|
|
142
102
|
npm test -- --grep "strategy_factory"
|
|
143
|
-
npm run coverage
|
|
144
103
|
```
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { StabilizerEnv } from '../validation/
|
|
1
|
+
import type { StabilizerEnv } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
2
|
/**
|
|
3
3
|
* @param final_kg - Loaded weight including tare.
|
|
4
4
|
* @param max_kg - Axle supported max.
|
|
5
|
-
* @param folga_pct -
|
|
5
|
+
* @param folga_pct - Folga percent from profile.
|
|
6
6
|
* @returns True when axle exceeds under folga rule.
|
|
7
7
|
*/
|
|
8
8
|
export declare function exceeds_with_folga(final_kg: number, max_kg: number, folga_pct: number): boolean;
|
|
9
9
|
/**
|
|
10
10
|
* Validates axle loads for an env using axle-load-calculator.
|
|
11
|
-
* @param env -
|
|
12
|
-
* @param folga_pct -
|
|
11
|
+
* @param env - CM env with containers and eixos.
|
|
12
|
+
* @param folga_pct - Folga percent.
|
|
13
13
|
* @returns True when all axles are within limits.
|
|
14
14
|
*/
|
|
15
15
|
export declare function is_axle_load_valid(env: StabilizerEnv, folga_pct: number): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axle_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/axle_adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"axle_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/axle_adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAA;AAErF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAClB,OAAO,CAGT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAUjF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { has_penetrating_overlap } from '../geometry/has_penetrating_overlap.js';
|
|
1
|
+
import { calculate_weight_on_axles_physics } from '@jetta/axle-load-calculator';
|
|
3
2
|
/**
|
|
4
3
|
* @param final_kg - Loaded weight including tare.
|
|
5
4
|
* @param max_kg - Axle supported max.
|
|
6
|
-
* @param folga_pct -
|
|
5
|
+
* @param folga_pct - Folga percent from profile.
|
|
7
6
|
* @returns True when axle exceeds under folga rule.
|
|
8
7
|
*/
|
|
9
8
|
export function exceeds_with_folga(final_kg, max_kg, folga_pct) {
|
|
@@ -11,23 +10,22 @@ export function exceeds_with_folga(final_kg, max_kg, folga_pct) {
|
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
12
|
* Validates axle loads for an env using axle-load-calculator.
|
|
14
|
-
* @param env -
|
|
15
|
-
* @param folga_pct -
|
|
13
|
+
* @param env - CM env with containers and eixos.
|
|
14
|
+
* @param folga_pct - Folga percent.
|
|
16
15
|
* @returns True when all axles are within limits.
|
|
17
16
|
*/
|
|
18
17
|
export function is_axle_load_valid(env, folga_pct) {
|
|
19
|
-
if (!env.
|
|
18
|
+
if (!env.eixos || env.eixos.length === 0) {
|
|
20
19
|
return true;
|
|
21
20
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
return is_false_positive_overlap(env, result.reason);
|
|
25
|
-
}
|
|
26
|
-
const containers = (result.env.containers ?? []);
|
|
21
|
+
const output_env = parse_axle_calculator_output(env);
|
|
22
|
+
const containers = (output_env.containers ?? []);
|
|
27
23
|
return containers.every(container => container_axles_within_folga(container, folga_pct));
|
|
28
24
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
25
|
+
function parse_axle_calculator_output(env) {
|
|
26
|
+
const request = { envs: [env] };
|
|
27
|
+
const output = JSON.parse(calculate_weight_on_axles_physics(JSON.stringify(request)));
|
|
28
|
+
return output.envs[0];
|
|
31
29
|
}
|
|
32
30
|
function container_axles_within_folga(container, folga_pct) {
|
|
33
31
|
const axles = (container.pesoEixos ?? []);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StabilizerContainer, StabilizerItem } from '../validation/
|
|
1
|
+
import type { StabilizerContainer, StabilizerItem } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
2
|
import { type AxisAlignedBox } from '../geometry/box_geometry.js';
|
|
3
3
|
export interface StabilityItemPayload {
|
|
4
4
|
x: number;
|
|
@@ -15,14 +15,14 @@ export interface StabilityContainerPayload {
|
|
|
15
15
|
item_list: StabilityItemPayload[];
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Maps
|
|
19
|
-
* @param item -
|
|
18
|
+
* Maps CM wire coordinates to cargo-stability payload coordinates.
|
|
19
|
+
* @param item - CM item record.
|
|
20
20
|
* @returns Stability item payload entry.
|
|
21
21
|
*/
|
|
22
22
|
export declare function map_item_to_stability(item: StabilizerItem): StabilityItemPayload;
|
|
23
23
|
/**
|
|
24
|
-
* Builds cargo-stability transport input from
|
|
25
|
-
* @param containers -
|
|
24
|
+
* Builds cargo-stability transport input from CM containers.
|
|
25
|
+
* @param containers - CM container records.
|
|
26
26
|
* @returns Stability containers array.
|
|
27
27
|
*/
|
|
28
28
|
export declare function build_stability_containers(containers: StabilizerContainer[]): StabilityContainerPayload[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate_mapper.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/coordinate_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"coordinate_mapper.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/coordinate_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAA;AAC3G,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE9E,MAAM,WAAW,oBAAoB;IAEjC,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,yBAAyB;IAEtC,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,SAAS,EAAE,oBAAoB,EAAE,CAAA;CACpC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,GAAG,oBAAoB,CAUhF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACtC,UAAU,EAAE,mBAAmB,EAAE,GAClC,yBAAyB,EAAE,CAQ7B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACnC,SAAS,EAAE,mBAAmB,EAC9B,eAAe,CAAC,EAAE,MAAM,GACzB,cAAc,EAAE,CAKlB"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { item_to_box } from '../geometry/box_geometry.js';
|
|
2
2
|
/**
|
|
3
|
-
* Maps
|
|
4
|
-
* @param item -
|
|
3
|
+
* Maps CM wire coordinates to cargo-stability payload coordinates.
|
|
4
|
+
* @param item - CM item record.
|
|
5
5
|
* @returns Stability item payload entry.
|
|
6
6
|
*/
|
|
7
7
|
export function map_item_to_stability(item) {
|
|
8
8
|
return {
|
|
9
9
|
x: item.x,
|
|
10
|
-
y: item.
|
|
11
|
-
z: item.
|
|
12
|
-
w: item.
|
|
13
|
-
h: item.
|
|
14
|
-
l: item.
|
|
10
|
+
y: item.z,
|
|
11
|
+
z: item.y,
|
|
12
|
+
w: item.w,
|
|
13
|
+
h: item.h,
|
|
14
|
+
l: item.d
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Builds cargo-stability transport input from
|
|
19
|
-
* @param containers -
|
|
18
|
+
* Builds cargo-stability transport input from CM containers.
|
|
19
|
+
* @param containers - CM container records.
|
|
20
20
|
* @returns Stability containers array.
|
|
21
21
|
*/
|
|
22
22
|
export function build_stability_containers(containers) {
|
|
23
23
|
return containers.map(container => ({
|
|
24
|
-
w: container.
|
|
25
|
-
h: container.
|
|
26
|
-
l: container.
|
|
24
|
+
w: container.largura,
|
|
25
|
+
h: container.altura,
|
|
26
|
+
l: container.comprimento,
|
|
27
27
|
item_list: container.items.map(map_item_to_stability)
|
|
28
28
|
}));
|
|
29
29
|
}
|
|
@@ -35,6 +35,6 @@ export function build_stability_containers(containers) {
|
|
|
35
35
|
*/
|
|
36
36
|
export function collect_container_boxes(container, exclude_item_id) {
|
|
37
37
|
return container.items
|
|
38
|
-
.filter(item => item.
|
|
38
|
+
.filter(item => item._id !== exclude_item_id)
|
|
39
39
|
.map(item_to_box);
|
|
40
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StabilizerContainer } from '../validation/
|
|
1
|
+
import type { StabilizerContainer } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
2
|
import type { LooseItemRef } from '../filters/loose_item_filter.js';
|
|
3
3
|
export interface StabilityEvaluation {
|
|
4
4
|
item_scores: number[][];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stability_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/stability_adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"stability_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/stability_adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAA;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,MAAM,WAAW,mBAAmB;IAEhC,WAAW,EAAE,MAAM,EAAE,EAAE,CAAA;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CACxC,UAAU,EAAE,mBAAmB,EAAE,GAClC,mBAAmB,CAiBrB;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC5C,UAAU,EAAE,mBAAmB,EAAE,GAClC,mBAAmB,GAAG,SAAS,CAUjC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,mBAAmB,EAAE,EACjC,WAAW,EAAE,YAAY,EAAE,GAC5B,MAAM,CAgBR;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC3B,SAAS,EAAE,mBAAmB,EAC9B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GACnB,MAAM,CAGR"}
|
|
@@ -41,7 +41,7 @@ export function sum_loose_item_scores(stability, containers, loose_items) {
|
|
|
41
41
|
let total = 0;
|
|
42
42
|
for (const loose of loose_items) {
|
|
43
43
|
const container = containers[loose.container_index];
|
|
44
|
-
const item_index = container.items.findIndex(item => item.
|
|
44
|
+
const item_index = container.items.findIndex(item => item._id === loose.item_id);
|
|
45
45
|
if (item_index < 0) {
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StabilizerContainer } from '../validation/
|
|
1
|
+
import type { StabilizerContainer } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
2
|
import type { LooseItemRef } from '../filters/loose_item_filter.js';
|
|
3
3
|
import type { ReorderContext } from '../strategies/reorder/ReorderStrategy.js';
|
|
4
4
|
import type { CandidateGenerationContext } from './candidate_context.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_candidate_context.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/build_candidate_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build_candidate_context.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/build_candidate_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAA;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAC9E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAExE;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACvC,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,mBAAmB,EAAE,EACjC,KAAK,EAAE,YAAY,GACpB,0BAA0B,CAQ5B"}
|
|
@@ -10,8 +10,6 @@ export function candidate_context_for_loose(context, containers, loose) {
|
|
|
10
10
|
containers,
|
|
11
11
|
loose,
|
|
12
12
|
mode: context.waypoint_mode,
|
|
13
|
-
zones: context.waypoint_zones
|
|
14
|
-
preserve_tie_block_organization: context.config.preserve_tie_block_organization,
|
|
15
|
-
milkrun_reserved_z_bands: context.milkrun_reserved_z_bands
|
|
13
|
+
zones: context.waypoint_zones
|
|
16
14
|
};
|
|
17
15
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { StabilizerContainer } from '../validation/
|
|
1
|
+
import type { StabilizerContainer } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
2
|
import type { LooseItemRef } from '../filters/loose_item_filter.js';
|
|
3
3
|
import type { WaypointMode, WaypointZone } from '../waypoint/WaypointMode.js';
|
|
4
|
-
import type { MilkrunReservedBand } from '../waypoint/milkrun_wall_reservation.js';
|
|
5
4
|
export interface CandidateGenerationContext {
|
|
6
5
|
containers: StabilizerContainer[];
|
|
7
6
|
loose: LooseItemRef;
|
|
8
7
|
mode: WaypointMode;
|
|
9
8
|
zones: WaypointZone[];
|
|
10
|
-
preserve_tie_block_organization: boolean;
|
|
11
|
-
milkrun_reserved_z_bands: MilkrunReservedBand[];
|
|
12
9
|
}
|
|
13
10
|
//# sourceMappingURL=candidate_context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate_context.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/candidate_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"candidate_context.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/candidate_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAA;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE7E,MAAM,WAAW,0BAA0B;IAEvC,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,KAAK,EAAE,YAAY,CAAA;IACnB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,YAAY,EAAE,CAAA;CACxB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MoveCandidate } from '../move/apply_move.js';
|
|
2
2
|
import type { CandidateGenerationContext } from './candidate_context.js';
|
|
3
3
|
/**
|
|
4
|
-
* Generates ranked candidate slots
|
|
4
|
+
* Generates ranked floor-first candidate slots for a loose item.
|
|
5
5
|
* @param context - Candidate generation context.
|
|
6
6
|
* @returns Candidate moves sorted floor-first, same container preferred.
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate_generator.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/candidate_generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"candidate_generator.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/candidate_generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAIxE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,aAAa,EAAE,CAuBxF"}
|
|
@@ -1,42 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { is_candidate_valid } from './candidate_validation.js';
|
|
1
|
+
import { enumerate_floor_slots, is_candidate_valid } from './candidate_validation.js';
|
|
3
2
|
import { rank_candidates } from './rank_candidates.js';
|
|
4
3
|
/**
|
|
5
|
-
* Generates ranked candidate slots
|
|
4
|
+
* Generates ranked floor-first candidate slots for a loose item.
|
|
6
5
|
* @param context - Candidate generation context.
|
|
7
6
|
* @returns Candidate moves sorted floor-first, same container preferred.
|
|
8
7
|
*/
|
|
9
8
|
export function generate_candidates(context) {
|
|
10
|
-
const candidates = context.containers.flatMap((container, target_index) => build_container_candidates(context, container, target_index));
|
|
11
|
-
return rank_candidates(candidates, context.loose.container_index);
|
|
12
|
-
}
|
|
13
|
-
function build_container_candidates(context, container, target_index) {
|
|
14
9
|
const candidates = [];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
context.containers.forEach((container, target_index) => {
|
|
11
|
+
const slots = enumerate_floor_slots(container, context.loose.item);
|
|
12
|
+
for (const position of slots) {
|
|
13
|
+
if (!is_candidate_valid(context, target_index, position)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
candidates.push({
|
|
17
|
+
item_id: context.loose.item_id,
|
|
18
|
+
source_container_index: context.loose.container_index,
|
|
19
|
+
target_container_index: target_index,
|
|
20
|
+
new_position: position
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
source_container_index: context.loose.container_index,
|
|
22
|
-
target_container_index: target_index,
|
|
23
|
-
new_position: tagged.position,
|
|
24
|
-
slot_kind: tagged.slot_kind
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return unique_kind_positions(candidates);
|
|
28
|
-
}
|
|
29
|
-
function unique_kind_positions(candidates) {
|
|
30
|
-
const seen = new Set();
|
|
31
|
-
const unique = [];
|
|
32
|
-
for (const candidate of candidates) {
|
|
33
|
-
const position = candidate.new_position;
|
|
34
|
-
const key = `${position.x}:${position.y}:${position.z}:${candidate.target_container_index}`;
|
|
35
|
-
if (seen.has(key)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
seen.add(key);
|
|
39
|
-
unique.push(candidate);
|
|
40
|
-
}
|
|
41
|
-
return unique;
|
|
23
|
+
});
|
|
24
|
+
return rank_candidates(candidates, context.loose.container_index);
|
|
42
25
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import type { StabilizerContainer, StabilizerItem } from '../validation/schemas/stabilizer_input_schema.js';
|
|
1
2
|
import type { CandidateGenerationContext } from './candidate_context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Enumerates floor-level slot positions for an item in a container.
|
|
5
|
+
* @param container - Target container.
|
|
6
|
+
* @param item - Item dimensions.
|
|
7
|
+
* @returns Floor slot positions.
|
|
8
|
+
*/
|
|
9
|
+
export declare function enumerate_floor_slots(container: StabilizerContainer, item: StabilizerItem): {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
}[];
|
|
2
14
|
/**
|
|
3
15
|
* Validates geometry and waypoint constraints for a candidate position.
|
|
4
16
|
* @param context - Candidate generation context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate_validation.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/candidate_validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"candidate_validation.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/candidate_validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAA;AAK3G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAIxE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,cAAc,GACrB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAevC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,0BAA0B,EACnC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,OAAO,CAOT"}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { collect_container_boxes } from '../adapters/coordinate_mapper.js';
|
|
2
|
-
import { has_overlap,
|
|
2
|
+
import { has_overlap, is_on_floor } from '../geometry/box_geometry.js';
|
|
3
3
|
import { is_position_in_zone } from '../waypoint/build_waypoint_zones.js';
|
|
4
|
-
import { is_position_in_milkrun_reserved_band } from '../waypoint/milkrun_wall_reservation.js';
|
|
5
4
|
import { resolve_item_waypoint_id } from '../waypoint/validate_waypoint_ids.js';
|
|
6
|
-
|
|
5
|
+
const POSITION_STEP = 0.05;
|
|
6
|
+
/**
|
|
7
|
+
* Enumerates floor-level slot positions for an item in a container.
|
|
8
|
+
* @param container - Target container.
|
|
9
|
+
* @param item - Item dimensions.
|
|
10
|
+
* @returns Floor slot positions.
|
|
11
|
+
*/
|
|
12
|
+
export function enumerate_floor_slots(container, item) {
|
|
13
|
+
const slots = [];
|
|
14
|
+
const max_x = container.largura - item.w;
|
|
15
|
+
const max_z = container.comprimento - item.d;
|
|
16
|
+
for (let z = 0; z <= max_z + 1e-6; z += POSITION_STEP) {
|
|
17
|
+
for (let x = 0; x <= max_x + 1e-6; x += POSITION_STEP) {
|
|
18
|
+
slots.push({ x, y: 0, z });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return slots;
|
|
22
|
+
}
|
|
7
23
|
/**
|
|
8
24
|
* Validates geometry and waypoint constraints for a candidate position.
|
|
9
25
|
* @param context - Candidate generation context.
|
|
@@ -15,52 +31,26 @@ export function is_candidate_valid(context, target_index, position) {
|
|
|
15
31
|
if (!is_candidate_geometry_valid(context, target_index, position)) {
|
|
16
32
|
return false;
|
|
17
33
|
}
|
|
18
|
-
if (!is_elevated_on_supporter_origin(context, target_index, position)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
if (!is_candidate_milkrun_valid(context, target_index, position)) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
34
|
return is_candidate_waypoint_valid(context, target_index, position);
|
|
25
35
|
}
|
|
26
|
-
function is_candidate_milkrun_valid(context, target_index, position) {
|
|
27
|
-
if (context.milkrun_reserved_z_bands.length === 0) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return !is_position_in_milkrun_reserved_band({
|
|
31
|
-
bands: context.milkrun_reserved_z_bands,
|
|
32
|
-
container_index: target_index,
|
|
33
|
-
item: context.loose.item,
|
|
34
|
-
position
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
36
|
function is_candidate_geometry_valid(context, target_index, position) {
|
|
38
|
-
const candidate_box = build_candidate_box(context, position);
|
|
39
37
|
const target = context.containers[target_index];
|
|
40
|
-
const
|
|
41
|
-
return is_valid_candidate_box(candidate_box, target, boxes);
|
|
42
|
-
}
|
|
43
|
-
function build_candidate_box(context, position) {
|
|
44
|
-
return {
|
|
38
|
+
const candidate_box = {
|
|
45
39
|
x: position.x,
|
|
46
40
|
y: position.y,
|
|
47
41
|
z: position.z,
|
|
48
|
-
w: context.loose.item.
|
|
49
|
-
h: context.loose.item.
|
|
50
|
-
d: context.loose.item.
|
|
42
|
+
w: context.loose.item.w,
|
|
43
|
+
h: context.loose.item.h,
|
|
44
|
+
d: context.loose.item.d
|
|
51
45
|
};
|
|
52
|
-
|
|
53
|
-
function is_valid_candidate_box(candidate_box, target, boxes) {
|
|
54
|
-
if (!is_inside_container(candidate_box, target)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (!is_fully_supported(candidate_box, boxes)) {
|
|
46
|
+
if (!is_on_floor(candidate_box)) {
|
|
58
47
|
return false;
|
|
59
48
|
}
|
|
49
|
+
const boxes = collect_container_boxes(target, context.loose.item_id);
|
|
60
50
|
return !has_overlap(candidate_box, boxes);
|
|
61
51
|
}
|
|
62
52
|
function is_candidate_waypoint_valid(context, target_index, position) {
|
|
63
|
-
if (context.mode.kind === 'SINGLE_WAYPOINT'
|
|
53
|
+
if (context.mode.kind === 'SINGLE_WAYPOINT') {
|
|
64
54
|
return true;
|
|
65
55
|
}
|
|
66
56
|
const waypoint_id = resolve_item_waypoint_id(context.loose.item, context.mode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rank_candidates.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/rank_candidates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"rank_candidates.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/rank_candidates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,EAAE,CAgBlG"}
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function rank_candidates(candidates, source_index) {
|
|
8
8
|
return candidates.sort((left, right) => {
|
|
9
|
-
if (left.new_position.y !== right.new_position.y) {
|
|
10
|
-
return left.new_position.y - right.new_position.y;
|
|
11
|
-
}
|
|
12
9
|
const same_left = left.target_container_index === source_index ? 0 : 1;
|
|
13
10
|
const same_right = right.target_container_index === source_index ? 0 : 1;
|
|
14
11
|
if (same_left !== same_right) {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { StabilizerContainer, StabilizerEnv } from '../validation/
|
|
1
|
+
import type { StabilizerContainer, StabilizerEnv } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
2
|
import type { StabilizerConfig } from '../validation/schemas/stabilizer_config_schema.js';
|
|
3
3
|
import type { LooseItemRef } from '../filters/loose_item_filter.js';
|
|
4
4
|
import type { WaypointMode } from '../waypoint/WaypointMode.js';
|
|
5
|
-
import type { MilkrunReservedBand } from '../waypoint/milkrun_wall_reservation.js';
|
|
6
5
|
export interface StateEvaluationContext {
|
|
7
6
|
env: StabilizerEnv;
|
|
8
7
|
loose_items: LooseItemRef[];
|
|
9
8
|
config: StabilizerConfig;
|
|
10
9
|
waypoint_mode: WaypointMode;
|
|
11
10
|
baseline_containers: StabilizerContainer[];
|
|
12
|
-
milkrun_reserved_z_bands: MilkrunReservedBand[];
|
|
13
11
|
}
|
|
14
12
|
//# sourceMappingURL=evaluation_context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluation_context.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/evaluation_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"evaluation_context.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/evaluation_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAA;AAC1G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE/D,MAAM,WAAW,sBAAsB;IAEnC,GAAG,EAAE,aAAa,CAAA;IAClB,WAAW,EAAE,YAAY,EAAE,CAAA;IAC3B,MAAM,EAAE,gBAAgB,CAAA;IACxB,aAAa,EAAE,YAAY,CAAA;IAC3B,mBAAmB,EAAE,mBAAmB,EAAE,CAAA;CAC7C"}
|