@jetta/cargo-stabilizer 0.1.0-3 → 0.1.0-5
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 +21 -1
- package/README.md +51 -11
- 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 +7 -5
- 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 +11 -11
- package/build/core/adapters/empty_space_adapter.d.ts +10 -0
- package/build/core/adapters/empty_space_adapter.d.ts.map +1 -0
- package/build/core/adapters/empty_space_adapter.js +24 -0
- package/build/core/adapters/map_item_to_positioned_cube.d.ts +9 -0
- package/build/core/adapters/map_item_to_positioned_cube.d.ts.map +1 -0
- package/build/core/adapters/map_item_to_positioned_cube.js +16 -0
- 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 +3 -1
- package/build/core/candidates/candidate_context.d.ts +4 -1
- 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 +19 -16
- package/build/core/candidates/candidate_validation.d.ts +0 -12
- package/build/core/candidates/candidate_validation.d.ts.map +1 -1
- package/build/core/candidates/candidate_validation.js +32 -26
- package/build/core/candidates/enumerate_empty_space_slots.d.ts +15 -0
- package/build/core/candidates/enumerate_empty_space_slots.d.ts.map +1 -0
- package/build/core/candidates/enumerate_empty_space_slots.js +44 -0
- package/build/core/candidates/rank_candidates.d.ts.map +1 -1
- package/build/core/candidates/rank_candidates.js +3 -0
- package/build/core/evaluation/evaluation_context.d.ts +3 -1
- package/build/core/evaluation/evaluation_context.d.ts.map +1 -1
- package/build/core/evaluation/state_evaluator.d.ts +12 -1
- package/build/core/evaluation/state_evaluator.d.ts.map +1 -1
- package/build/core/evaluation/state_evaluator.js +28 -5
- package/build/core/exceptions/InvalidStabilizerOutputError.d.ts +4 -0
- package/build/core/exceptions/InvalidStabilizerOutputError.d.ts.map +1 -0
- package/build/core/exceptions/InvalidStabilizerOutputError.js +6 -0
- package/build/core/factory/read_stabilizer_config.d.ts +4 -2
- package/build/core/factory/read_stabilizer_config.d.ts.map +1 -1
- package/build/core/factory/read_stabilizer_config.js +6 -25
- package/build/core/factory/read_stabilizer_config_helpers.d.ts +28 -0
- package/build/core/factory/read_stabilizer_config_helpers.d.ts.map +1 -0
- package/build/core/factory/read_stabilizer_config_helpers.js +62 -0
- 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 +17 -1
- package/build/core/geometry/box_geometry.d.ts.map +1 -1
- package/build/core/geometry/box_geometry.js +67 -2
- package/build/core/move/apply_move.d.ts +1 -1
- 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 +2 -1
- package/build/core/orchestration/StabilizerFlow.d.ts.map +1 -1
- package/build/core/orchestration/StabilizerFlow.js +2 -2
- package/build/core/orchestration/build_milkrun_bands_from_config.d.ts +13 -0
- package/build/core/orchestration/build_milkrun_bands_from_config.d.ts.map +1 -0
- package/build/core/orchestration/build_milkrun_bands_from_config.js +14 -0
- 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 +7 -7
- package/build/core/orchestration/read_primary_env.d.ts +9 -0
- package/build/core/orchestration/read_primary_env.d.ts.map +1 -0
- package/build/core/orchestration/read_primary_env.js +13 -0
- 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 +3 -3
- 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 +3 -1
- 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/contract/cargo_movement_wire_field_map.d.ts +21 -0
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +1 -0
- package/build/core/validation/contract/cargo_movement_wire_field_map.js +27 -0
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts +14 -0
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts.map +1 -0
- package/build/core/validation/contract/cargo_movement_wire_mapper.js +34 -0
- package/build/core/validation/contract/format_zod_error.d.ts +8 -0
- package/build/core/validation/contract/format_zod_error.d.ts.map +1 -0
- package/build/core/validation/contract/format_zod_error.js +11 -0
- package/build/core/validation/contract/index.d.ts +9 -0
- package/build/core/validation/contract/index.d.ts.map +1 -0
- package/build/core/validation/contract/index.js +8 -0
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts +3 -0
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts.map +1 -0
- package/build/core/validation/contract/map_contract_to_wire_shape.js +28 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts +2 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +1 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.js +62 -0
- package/build/core/validation/contract/parse_stabilizer_input.d.ts +45 -0
- package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +1 -0
- package/build/core/validation/contract/parse_stabilizer_input.js +26 -0
- package/build/core/validation/contract/parse_stabilizer_output.d.ts +47 -0
- package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +1 -0
- package/build/core/validation/contract/parse_stabilizer_output.js +24 -0
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts +92 -0
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_domain_schema.js +61 -0
- package/build/core/validation/contract/stabilizer_input_schema.d.ts +33 -0
- package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_input_schema.js +11 -0
- package/build/core/validation/contract/stabilizer_output_schema.d.ts +70 -0
- package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_output_schema.js +16 -0
- package/build/core/validation/contract/wire_mapper_record_utils.d.ts +20 -0
- package/build/core/validation/contract/wire_mapper_record_utils.d.ts.map +1 -0
- package/build/core/validation/contract/wire_mapper_record_utils.js +36 -0
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts +4 -1
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts.map +1 -1
- package/build/core/validation/schemas/stabilizer_config_schema.js +4 -1
- 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/milkrun_wall_reservation.d.ts +24 -0
- package/build/core/waypoint/milkrun_wall_reservation.d.ts.map +1 -0
- package/build/core/waypoint/milkrun_wall_reservation.js +57 -0
- package/build/core/waypoint/milkrun_wall_reservation_helpers.d.ts +15 -0
- package/build/core/waypoint/milkrun_wall_reservation_helpers.d.ts.map +1 -0
- package/build/core/waypoint/milkrun_wall_reservation_helpers.js +48 -0
- package/build/core/waypoint/milkrun_wall_reservation_types.d.ts +16 -0
- package/build/core/waypoint/milkrun_wall_reservation_types.d.ts.map +1 -0
- package/build/core/waypoint/milkrun_wall_reservation_types.js +1 -0
- 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 +15 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +30 -7
- package/package.json +1 -1
- package/build/core/validation/parse_stabilizer_input.d.ts +0 -8
- package/build/core/validation/parse_stabilizer_input.d.ts.map +0 -1
- package/build/core/validation/parse_stabilizer_input.js +0 -20
- package/build/core/validation/schemas/stabilizer_input_schema.d.ts +0 -110
- package/build/core/validation/schemas/stabilizer_input_schema.d.ts.map +0 -1
- package/build/core/validation/schemas/stabilizer_input_schema.js +0 -34
- package/build/core/validation/schemas/stabilizer_output_schema.d.ts +0 -13
- package/build/core/validation/schemas/stabilizer_output_schema.d.ts.map +0 -1
- package/build/core/validation/schemas/stabilizer_output_schema.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,8 +8,28 @@ 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
|
+
- Public contract exports: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_parse_stabilizer_input`, `safe_parse_stabilizer_output`, and related domain types.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- README documents I/O contract mapping, configuration keys, dependencies, and test/coverage commands.
|
|
19
|
+
|
|
20
|
+
### Testing
|
|
21
|
+
|
|
22
|
+
- Expanded Mocha suite to 126 tests mirroring `src/` under `test/src/`.
|
|
23
|
+
- Local coverage gate at 80% on lines, functions, branches, and statements (`npm run coverage`).
|
|
24
|
+
- CI coverage gate at 75% (`npm run coverage:ci`).
|
|
25
|
+
- Mocha setup preloads core modules so c8 attributes coverage consistently across the full suite.
|
|
26
|
+
|
|
27
|
+
## [0.1.0-3] - 2026-08-14
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
11
31
|
- Initial library scaffold (JET-2262).
|
|
12
32
|
- Five config-selectable reorder strategies: gravity, greedy, beam search, simulated annealing, genetic.
|
|
13
|
-
- Zod-validated input contract with waypoint_id rules and multi-container support.
|
|
33
|
+
- Zod-validated input contract with `waypoint_id` rules and multi-container support.
|
|
14
34
|
- Shared evaluator: cargo-stability transport gate, axle-load-calculator folga gate, waypoint order.
|
|
15
35
|
- 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 **loose items only** to improve cargo stability while keeping compound blocks pinned. Implements five config-selectable strategies (JET-2262).
|
|
3
|
+
TypeScript library that reorders **loose items only** to improve cargo stability while keeping compound blocks pinned. Implements five config-selectable strategies with organization gates (waypoint order, milkrun wall reservation) and empty-space candidate discovery (JET-2262).
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
@@ -47,6 +47,24 @@ 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
|
+
|
|
50
68
|
## Configuration
|
|
51
69
|
|
|
52
70
|
| Key | Default | Description |
|
|
@@ -54,6 +72,9 @@ if (response.status === 'success') {
|
|
|
54
72
|
| `cargo_stabilizer.reorder_strategy` | `gravity` | `gravity`, `greedy`, `beam_search`, `simulated_annealing`, `genetic` |
|
|
55
73
|
| `cargo_stabilizer.transport_stability_floor` | `0` | Hard minimum transport stability score |
|
|
56
74
|
| `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.enforce_milkrun_wall_reservation` | `false` | When true, reserve rear compound-wall Z bands using profile key below |
|
|
77
|
+
| `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) |
|
|
57
78
|
| `folga_de_peso_nos_eixos` | `0` | Axle folga percent |
|
|
58
79
|
|
|
59
80
|
## Errors
|
|
@@ -61,6 +82,7 @@ if (response.status === 'success') {
|
|
|
61
82
|
| Error | When |
|
|
62
83
|
|-------|------|
|
|
63
84
|
| `InvalidStabilizerInputError` | Zod validation failure on input |
|
|
85
|
+
| `InvalidStabilizerOutputError` | Internal response failed output contract parse |
|
|
64
86
|
| `MixedWaypointIdError` | Some items have `waypoint_id` and others omit it |
|
|
65
87
|
| `UnknownReorderStrategyError` | Invalid `cargo_stabilizer.reorder_strategy` |
|
|
66
88
|
|
|
@@ -68,36 +90,54 @@ Import `ZodError` from `zod` when validating externally.
|
|
|
68
90
|
|
|
69
91
|
## Dependencies
|
|
70
92
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- `@jetta/
|
|
74
|
-
- `@jetta/
|
|
75
|
-
- `
|
|
93
|
+
Runtime integrations (all declared in `package.json`):
|
|
94
|
+
|
|
95
|
+
- `@jetta/cargo-stability` — transport stability scoring gate and objective (`stability_adapter`)
|
|
96
|
+
- `@jetta/axle-load-calculator` — axle load validation gate (`axle_adapter`)
|
|
97
|
+
- `@jetta/empty-spaces-manager` — empty-region candidate slot discovery (`empty_space_adapter`)
|
|
98
|
+
- `@jetta/logger` — structured logging at orchestration boundary (transitive via cargo-stability)
|
|
99
|
+
- `zod` — I/O contract validation
|
|
76
100
|
|
|
77
101
|
## Scripts
|
|
78
102
|
|
|
79
103
|
| Command | Description |
|
|
80
104
|
|---------|-------------|
|
|
81
|
-
| `npm test` | Mocha tests |
|
|
105
|
+
| `npm test` | Mocha tests (126 cases) |
|
|
82
106
|
| `npm run lint` | ESLint |
|
|
83
107
|
| `npm run build` | TypeScript compile to `build/` |
|
|
84
|
-
| `npm run coverage
|
|
108
|
+
| `npm run coverage` | Tests with **80%** coverage gate (local) |
|
|
109
|
+
| `npm run coverage:ci` | Tests with **75%** coverage gate (CI) |
|
|
85
110
|
| `npm run lint:package` | publint strict check |
|
|
86
111
|
|
|
87
112
|
## Layout
|
|
88
113
|
|
|
89
114
|
- `src/index.ts` — public API (`stabilize`)
|
|
90
|
-
- `src/core/validation/` —
|
|
115
|
+
- `src/core/validation/contract/` — strict English I/O contract and CM wire mapper
|
|
91
116
|
- `src/core/strategies/reorder/` — five reorder algorithms
|
|
92
117
|
- `src/core/evaluation/` — shared stability + axle + waypoint gates
|
|
93
|
-
- `
|
|
118
|
+
- `src/core/candidates/` — empty-space slot discovery and candidate ranking
|
|
119
|
+
- `test/src/` — mirrors `src/`; fixtures under `test/data/src/`
|
|
120
|
+
|
|
121
|
+
## Testing and coverage
|
|
122
|
+
|
|
123
|
+
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.
|
|
124
|
+
|
|
125
|
+
| Gate | Command | Threshold |
|
|
126
|
+
|------|---------|-----------|
|
|
127
|
+
| Local | `npm run coverage` | 80% lines, functions, branches, statements |
|
|
128
|
+
| CI | `npm run coverage:ci` | 75% on all metrics |
|
|
94
129
|
|
|
95
130
|
## Test plan
|
|
96
131
|
|
|
97
132
|
```bash
|
|
133
|
+
npm test -- --grep "wire_mapper_shape"
|
|
98
134
|
npm test -- --grep "input_validation"
|
|
99
135
|
npm test -- --grep "waypoint_order"
|
|
136
|
+
npm test -- --grep "milkrun_wall_reservation"
|
|
137
|
+
npm test -- --grep "apply_move"
|
|
138
|
+
npm test -- --grep "state_evaluator"
|
|
100
139
|
npm test -- --grep "gravity_compaction"
|
|
101
|
-
npm test -- --grep "
|
|
140
|
+
npm test -- --grep "reorder_strategy_depth"
|
|
102
141
|
npm test -- --grep "strategy_factory"
|
|
142
|
+
npm run coverage
|
|
103
143
|
```
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { StabilizerEnv } from '../validation/
|
|
1
|
+
import type { StabilizerEnv } from '../validation/contract/stabilizer_domain_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 - Axle load margin 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 - Stabilizer env with containers and axles.
|
|
12
|
+
* @param folga_pct - Axle load margin 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":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAA;AAEvF;;;;;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,8 +1,9 @@
|
|
|
1
1
|
import { calculate_weight_on_axles_physics } from '@jetta/axle-load-calculator';
|
|
2
|
+
import { map_contract_to_wire_output } from '../validation/contract/cargo_movement_wire_mapper.js';
|
|
2
3
|
/**
|
|
3
4
|
* @param final_kg - Loaded weight including tare.
|
|
4
5
|
* @param max_kg - Axle supported max.
|
|
5
|
-
* @param folga_pct -
|
|
6
|
+
* @param folga_pct - Axle load margin percent from profile.
|
|
6
7
|
* @returns True when axle exceeds under folga rule.
|
|
7
8
|
*/
|
|
8
9
|
export function exceeds_with_folga(final_kg, max_kg, folga_pct) {
|
|
@@ -10,12 +11,12 @@ export function exceeds_with_folga(final_kg, max_kg, folga_pct) {
|
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Validates axle loads for an env using axle-load-calculator.
|
|
13
|
-
* @param env -
|
|
14
|
-
* @param folga_pct -
|
|
14
|
+
* @param env - Stabilizer env with containers and axles.
|
|
15
|
+
* @param folga_pct - Axle load margin percent.
|
|
15
16
|
* @returns True when all axles are within limits.
|
|
16
17
|
*/
|
|
17
18
|
export function is_axle_load_valid(env, folga_pct) {
|
|
18
|
-
if (!env.
|
|
19
|
+
if (!env.axles || env.axles.length === 0) {
|
|
19
20
|
return true;
|
|
20
21
|
}
|
|
21
22
|
const output_env = parse_axle_calculator_output(env);
|
|
@@ -23,7 +24,8 @@ export function is_axle_load_valid(env, folga_pct) {
|
|
|
23
24
|
return containers.every(container => container_axles_within_folga(container, folga_pct));
|
|
24
25
|
}
|
|
25
26
|
function parse_axle_calculator_output(env) {
|
|
26
|
-
const
|
|
27
|
+
const wire_cargo_state = map_contract_to_wire_output({ envs: [env] });
|
|
28
|
+
const request = { envs: wire_cargo_state.envs };
|
|
27
29
|
const output = JSON.parse(calculate_weight_on_axles_physics(JSON.stringify(request)));
|
|
28
30
|
return output.envs[0];
|
|
29
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StabilizerContainer, StabilizerItem } from '../validation/
|
|
1
|
+
import type { StabilizerContainer, StabilizerItem } from '../validation/contract/stabilizer_domain_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 contract coordinates to cargo-stability payload coordinates.
|
|
19
|
+
* @param item - Stabilizer 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 stabilizer containers.
|
|
25
|
+
* @param containers - Stabilizer 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,oDAAoD,CAAA;AAC7G,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,7 +1,7 @@
|
|
|
1
1
|
import { item_to_box } from '../geometry/box_geometry.js';
|
|
2
2
|
/**
|
|
3
|
-
* Maps
|
|
4
|
-
* @param item -
|
|
3
|
+
* Maps contract coordinates to cargo-stability payload coordinates.
|
|
4
|
+
* @param item - Stabilizer item record.
|
|
5
5
|
* @returns Stability item payload entry.
|
|
6
6
|
*/
|
|
7
7
|
export function map_item_to_stability(item) {
|
|
@@ -9,21 +9,21 @@ export function map_item_to_stability(item) {
|
|
|
9
9
|
x: item.x,
|
|
10
10
|
y: item.z,
|
|
11
11
|
z: item.y,
|
|
12
|
-
w: item.
|
|
13
|
-
h: item.
|
|
14
|
-
l: item.
|
|
12
|
+
w: item.width,
|
|
13
|
+
h: item.height,
|
|
14
|
+
l: item.depth
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Builds cargo-stability transport input from
|
|
19
|
-
* @param containers -
|
|
18
|
+
* Builds cargo-stability transport input from stabilizer containers.
|
|
19
|
+
* @param containers - Stabilizer 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.width,
|
|
25
|
+
h: container.height,
|
|
26
|
+
l: container.length,
|
|
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.item_id !== exclude_item_id)
|
|
39
39
|
.map(item_to_box);
|
|
40
40
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Space } from '@jetta/empty-spaces-manager';
|
|
2
|
+
import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Finds empty regions in a container after allocating pinned and other items.
|
|
5
|
+
* @param container - Stabilizer container layout.
|
|
6
|
+
* @param exclude_item_id - Loose item id to omit from obstacles (virtual remove).
|
|
7
|
+
* @returns Empty space fragments from EmptySpaceFinder.
|
|
8
|
+
*/
|
|
9
|
+
export declare function find_empty_spaces_in_container(container: StabilizerContainer, exclude_item_id?: string): Space[];
|
|
10
|
+
//# sourceMappingURL=empty_space_adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty_space_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/empty_space_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,MAAM,6BAA6B,CAAA;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAE7F;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC1C,SAAS,EAAE,mBAAmB,EAC9B,eAAe,CAAC,EAAE,MAAM,GACzB,KAAK,EAAE,CAgBT"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EmptySpaceFinder, Space } from '@jetta/empty-spaces-manager';
|
|
2
|
+
import { map_item_to_positioned_cube } from './map_item_to_positioned_cube.js';
|
|
3
|
+
/**
|
|
4
|
+
* Finds empty regions in a container after allocating pinned and other items.
|
|
5
|
+
* @param container - Stabilizer container layout.
|
|
6
|
+
* @param exclude_item_id - Loose item id to omit from obstacles (virtual remove).
|
|
7
|
+
* @returns Empty space fragments from EmptySpaceFinder.
|
|
8
|
+
*/
|
|
9
|
+
export function find_empty_spaces_in_container(container, exclude_item_id) {
|
|
10
|
+
const container_space = new Space({
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
z: 0,
|
|
14
|
+
width: container.width,
|
|
15
|
+
height: container.height,
|
|
16
|
+
length: container.length
|
|
17
|
+
});
|
|
18
|
+
const obstacles = container.items
|
|
19
|
+
.filter(item => item.item_id !== exclude_item_id)
|
|
20
|
+
.map(map_item_to_positioned_cube);
|
|
21
|
+
const finder = new EmptySpaceFinder(container_space, []);
|
|
22
|
+
finder.allocate_item_list(obstacles);
|
|
23
|
+
return finder.empty_spaces();
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Space } from '@jetta/empty-spaces-manager';
|
|
2
|
+
import type { StabilizerItem } from '../validation/contract/stabilizer_domain_schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Maps a stabilizer item to an empty-spaces positioned cube.
|
|
5
|
+
* @param item - Stabilizer item record.
|
|
6
|
+
* @returns Positioned cube for EmptySpaceFinder allocation.
|
|
7
|
+
*/
|
|
8
|
+
export declare function map_item_to_positioned_cube(item: StabilizerItem): Space;
|
|
9
|
+
//# sourceMappingURL=map_item_to_positioned_cube.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map_item_to_positioned_cube.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/map_item_to_positioned_cube.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AAExF;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,cAAc,GAAG,KAAK,CAUvE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Space } from '@jetta/empty-spaces-manager';
|
|
2
|
+
/**
|
|
3
|
+
* Maps a stabilizer item to an empty-spaces positioned cube.
|
|
4
|
+
* @param item - Stabilizer item record.
|
|
5
|
+
* @returns Positioned cube for EmptySpaceFinder allocation.
|
|
6
|
+
*/
|
|
7
|
+
export function map_item_to_positioned_cube(item) {
|
|
8
|
+
return new Space({
|
|
9
|
+
x: item.x,
|
|
10
|
+
y: item.y,
|
|
11
|
+
z: item.z,
|
|
12
|
+
width: item.width,
|
|
13
|
+
height: item.height,
|
|
14
|
+
length: item.depth
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StabilizerContainer } from '../validation/
|
|
1
|
+
import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_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,oDAAoD,CAAA;AAC7F,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.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/contract/stabilizer_domain_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,oDAAoD,CAAA;AAC7F,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,CAU5B"}
|
|
@@ -10,6 +10,8 @@ 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
|
|
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
|
|
14
16
|
};
|
|
15
17
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { StabilizerContainer } from '../validation/
|
|
1
|
+
import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_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';
|
|
4
5
|
export interface CandidateGenerationContext {
|
|
5
6
|
containers: StabilizerContainer[];
|
|
6
7
|
loose: LooseItemRef;
|
|
7
8
|
mode: WaypointMode;
|
|
8
9
|
zones: WaypointZone[];
|
|
10
|
+
preserve_tie_block_organization: boolean;
|
|
11
|
+
milkrun_reserved_z_bands: MilkrunReservedBand[];
|
|
9
12
|
}
|
|
10
13
|
//# 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,oDAAoD,CAAA;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAElF,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;IACrB,+BAA+B,EAAE,OAAO,CAAA;IACxC,wBAAwB,EAAE,mBAAmB,EAAE,CAAA;CAClD"}
|
|
@@ -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
|
|
4
|
+
* Generates ranked candidate slots from empty-space regions 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;AAKxE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,aAAa,EAAE,CAMxF"}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { enumerate_empty_space_slots } from './enumerate_empty_space_slots.js';
|
|
2
|
+
import { is_candidate_valid } from './candidate_validation.js';
|
|
2
3
|
import { rank_candidates } from './rank_candidates.js';
|
|
3
4
|
/**
|
|
4
|
-
* Generates ranked
|
|
5
|
+
* Generates ranked candidate slots from empty-space regions for a loose item.
|
|
5
6
|
* @param context - Candidate generation context.
|
|
6
7
|
* @returns Candidate moves sorted floor-first, same container preferred.
|
|
7
8
|
*/
|
|
8
9
|
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
|
+
const slots = enumerate_empty_space_slots(container, context.loose.item, context.loose.item_id);
|
|
9
15
|
const candidates = [];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
});
|
|
16
|
+
for (const position of slots) {
|
|
17
|
+
if (!is_candidate_valid(context, target_index, position)) {
|
|
18
|
+
continue;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
candidates.push({
|
|
21
|
+
item_id: context.loose.item_id,
|
|
22
|
+
source_container_index: context.loose.container_index,
|
|
23
|
+
target_container_index: target_index,
|
|
24
|
+
new_position: position
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return candidates;
|
|
25
28
|
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import type { StabilizerContainer, StabilizerItem } from '../validation/schemas/stabilizer_input_schema.js';
|
|
2
1
|
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
|
-
}[];
|
|
14
2
|
/**
|
|
15
3
|
* Validates geometry and waypoint constraints for a candidate position.
|
|
16
4
|
* @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":"AAUA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAExE;;;;;;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,CAWT"}
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import { collect_container_boxes } from '../adapters/coordinate_mapper.js';
|
|
2
|
-
import { has_overlap,
|
|
2
|
+
import { has_overlap, is_fully_supported, is_inside_container } 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';
|
|
4
5
|
import { resolve_item_waypoint_id } from '../waypoint/validate_waypoint_ids.js';
|
|
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
|
-
}
|
|
23
6
|
/**
|
|
24
7
|
* Validates geometry and waypoint constraints for a candidate position.
|
|
25
8
|
* @param context - Candidate generation context.
|
|
@@ -31,26 +14,49 @@ export function is_candidate_valid(context, target_index, position) {
|
|
|
31
14
|
if (!is_candidate_geometry_valid(context, target_index, position)) {
|
|
32
15
|
return false;
|
|
33
16
|
}
|
|
17
|
+
if (!is_candidate_milkrun_valid(context, target_index, position)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
34
20
|
return is_candidate_waypoint_valid(context, target_index, position);
|
|
35
21
|
}
|
|
22
|
+
function is_candidate_milkrun_valid(context, target_index, position) {
|
|
23
|
+
if (context.milkrun_reserved_z_bands.length === 0) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return !is_position_in_milkrun_reserved_band({
|
|
27
|
+
bands: context.milkrun_reserved_z_bands,
|
|
28
|
+
container_index: target_index,
|
|
29
|
+
item: context.loose.item,
|
|
30
|
+
position
|
|
31
|
+
});
|
|
32
|
+
}
|
|
36
33
|
function is_candidate_geometry_valid(context, target_index, position) {
|
|
34
|
+
const candidate_box = build_candidate_box(context, position);
|
|
37
35
|
const target = context.containers[target_index];
|
|
38
|
-
const
|
|
36
|
+
const boxes = collect_container_boxes(target, context.loose.item_id);
|
|
37
|
+
return is_valid_candidate_box(candidate_box, target, boxes);
|
|
38
|
+
}
|
|
39
|
+
function build_candidate_box(context, position) {
|
|
40
|
+
return {
|
|
39
41
|
x: position.x,
|
|
40
42
|
y: position.y,
|
|
41
43
|
z: position.z,
|
|
42
|
-
w: context.loose.item.
|
|
43
|
-
h: context.loose.item.
|
|
44
|
-
d: context.loose.item.
|
|
44
|
+
w: context.loose.item.width,
|
|
45
|
+
h: context.loose.item.height,
|
|
46
|
+
d: context.loose.item.depth
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
}
|
|
49
|
+
function is_valid_candidate_box(candidate_box, target, boxes) {
|
|
50
|
+
if (!is_inside_container(candidate_box, target)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (!is_fully_supported(candidate_box, boxes)) {
|
|
47
54
|
return false;
|
|
48
55
|
}
|
|
49
|
-
const boxes = collect_container_boxes(target, context.loose.item_id);
|
|
50
56
|
return !has_overlap(candidate_box, boxes);
|
|
51
57
|
}
|
|
52
58
|
function is_candidate_waypoint_valid(context, target_index, position) {
|
|
53
|
-
if (context.mode.kind === 'SINGLE_WAYPOINT') {
|
|
59
|
+
if (context.mode.kind === 'SINGLE_WAYPOINT' || !context.preserve_tie_block_organization) {
|
|
54
60
|
return true;
|
|
55
61
|
}
|
|
56
62
|
const waypoint_id = resolve_item_waypoint_id(context.loose.item, context.mode);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StabilizerContainer, StabilizerItem } from '../validation/contract/stabilizer_domain_schema.js';
|
|
2
|
+
export interface EmptySpaceSlot {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
z: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Enumerates candidate positions from empty-space regions where the item fits.
|
|
9
|
+
* @param container - Target container layout.
|
|
10
|
+
* @param item - Loose item dimensions.
|
|
11
|
+
* @param exclude_item_id - Item id to omit from obstacle list.
|
|
12
|
+
* @returns Slot positions at each fitting empty-space origin.
|
|
13
|
+
*/
|
|
14
|
+
export declare function enumerate_empty_space_slots(container: StabilizerContainer, item: StabilizerItem, exclude_item_id: string): EmptySpaceSlot[];
|
|
15
|
+
//# sourceMappingURL=enumerate_empty_space_slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerate_empty_space_slots.d.ts","sourceRoot":"","sources":["../../../src/core/candidates/enumerate_empty_space_slots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AAG7G,MAAM,WAAW,cAAc;IAE3B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,cAAc,EACpB,eAAe,EAAE,MAAM,GACxB,cAAc,EAAE,CAmBlB"}
|