@jetta/cargo-stabilizer 0.1.0-9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -11
- package/build/core/adapters/axle_adapter.d.ts +1 -0
- package/build/core/adapters/axle_adapter.d.ts.map +1 -1
- package/build/core/adapters/axle_adapter.js +3 -18
- package/build/core/adapters/axle_load_evaluation.d.ts +8 -0
- package/build/core/adapters/axle_load_evaluation.d.ts.map +1 -0
- package/build/core/adapters/axle_load_evaluation.js +1 -0
- package/build/core/adapters/build_axle_request.d.ts +2 -9
- package/build/core/adapters/build_axle_request.d.ts.map +1 -1
- package/build/core/adapters/build_axle_request.js +52 -24
- package/build/core/adapters/compute_axle_excess_kg.d.ts +8 -0
- package/build/core/adapters/compute_axle_excess_kg.d.ts.map +1 -0
- package/build/core/adapters/compute_axle_excess_kg.js +19 -0
- package/build/core/adapters/coordinate_mapper.d.ts +1 -1
- package/build/core/adapters/coordinate_mapper.js +3 -3
- package/build/core/adapters/evaluate_axle_load.d.ts +10 -0
- package/build/core/adapters/evaluate_axle_load.d.ts.map +1 -0
- package/build/core/adapters/evaluate_axle_load.js +32 -0
- package/build/core/adapters/map_item_to_stacking_item.d.ts +14 -0
- package/build/core/adapters/map_item_to_stacking_item.d.ts.map +1 -0
- package/build/core/adapters/map_item_to_stacking_item.js +40 -0
- package/build/core/adapters/run_axle_calculator.d.ts.map +1 -1
- package/build/core/adapters/run_axle_calculator.js +21 -16
- package/build/core/candidates/candidate_validation.d.ts.map +1 -1
- package/build/core/candidates/candidate_validation.js +4 -0
- package/build/core/candidates/is_candidate_stacking_valid.d.ts +14 -0
- package/build/core/candidates/is_candidate_stacking_valid.d.ts.map +1 -0
- package/build/core/candidates/is_candidate_stacking_valid.js +43 -0
- package/build/core/constants/TieRatioOrientation.d.ts +6 -0
- package/build/core/constants/TieRatioOrientation.d.ts.map +1 -0
- package/build/core/constants/TieRatioOrientation.js +5 -0
- package/build/core/evaluation/compare_search_states.d.ts +12 -0
- package/build/core/evaluation/compare_search_states.d.ts.map +1 -0
- package/build/core/evaluation/compare_search_states.js +12 -0
- package/build/core/evaluation/evaluate_search_gates.d.ts +18 -0
- package/build/core/evaluation/evaluate_search_gates.d.ts.map +1 -0
- package/build/core/evaluation/evaluate_search_gates.js +30 -0
- package/build/core/evaluation/evaluation_result.d.ts +15 -0
- package/build/core/evaluation/evaluation_result.d.ts.map +1 -0
- package/build/core/evaluation/evaluation_result.js +1 -0
- package/build/core/evaluation/genetic_fitness.d.ts +9 -0
- package/build/core/evaluation/genetic_fitness.d.ts.map +1 -0
- package/build/core/evaluation/genetic_fitness.js +16 -0
- package/build/core/evaluation/is_non_axle_gates_pass.d.ts +8 -0
- package/build/core/evaluation/is_non_axle_gates_pass.d.ts.map +1 -0
- package/build/core/evaluation/is_non_axle_gates_pass.js +8 -0
- package/build/core/evaluation/is_search_trial_admissible.d.ts +10 -0
- package/build/core/evaluation/is_search_trial_admissible.d.ts.map +1 -0
- package/build/core/evaluation/is_search_trial_admissible.js +17 -0
- package/build/core/evaluation/is_waypoint_order_valid.d.ts +10 -0
- package/build/core/evaluation/is_waypoint_order_valid.d.ts.map +1 -0
- package/build/core/evaluation/is_waypoint_order_valid.js +14 -0
- package/build/core/evaluation/state_evaluator.d.ts +2 -10
- package/build/core/evaluation/state_evaluator.d.ts.map +1 -1
- package/build/core/evaluation/state_evaluator.js +6 -26
- package/build/core/factory/read_stabilizer_config.d.ts +3 -2
- package/build/core/factory/read_stabilizer_config.d.ts.map +1 -1
- package/build/core/factory/read_stabilizer_config_helpers.d.ts +9 -5
- package/build/core/factory/read_stabilizer_config_helpers.d.ts.map +1 -1
- package/build/core/factory/read_stabilizer_config_helpers.js +12 -1
- package/build/core/filters/collect_movable_items.d.ts +18 -0
- package/build/core/filters/collect_movable_items.d.ts.map +1 -0
- package/build/core/filters/collect_movable_items.js +53 -0
- package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.d.ts +8 -0
- package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.d.ts.map +1 -0
- package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.js +41 -0
- package/build/core/filters/is_item_on_cm_floor.d.ts +8 -0
- package/build/core/filters/is_item_on_cm_floor.d.ts.map +1 -0
- package/build/core/filters/is_item_on_cm_floor.js +9 -0
- package/build/core/geometry/has_penetrating_overlap.d.ts +9 -0
- package/build/core/geometry/has_penetrating_overlap.d.ts.map +1 -0
- package/build/core/geometry/has_penetrating_overlap.js +27 -0
- package/build/core/orchestration/StabilizerFlow.d.ts.map +1 -1
- package/build/core/orchestration/StabilizerFlow.js +1 -1
- package/build/core/orchestration/build_reorder_context.d.ts.map +1 -1
- package/build/core/orchestration/build_reorder_context.js +3 -5
- package/build/core/strategies/reorder/BeamSearchReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/BeamSearchReorder.js +10 -12
- package/build/core/strategies/reorder/GeneticReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/GeneticReorder.js +2 -1
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts.map +1 -1
- package/build/core/strategies/reorder/SimulatedAnnealingReorder.js +14 -5
- package/build/core/strategies/reorder/append_admitted_trial.d.ts +11 -0
- package/build/core/strategies/reorder/append_admitted_trial.d.ts.map +1 -0
- package/build/core/strategies/reorder/append_admitted_trial.js +22 -0
- package/build/core/strategies/reorder/beam_context.d.ts +1 -0
- package/build/core/strategies/reorder/beam_context.d.ts.map +1 -1
- package/build/core/strategies/reorder/greedy_improvement.d.ts.map +1 -1
- package/build/core/strategies/reorder/greedy_improvement.js +3 -2
- package/build/core/strategies/reorder/is_improving_greedy_trial.d.ts +10 -0
- package/build/core/strategies/reorder/is_improving_greedy_trial.d.ts.map +1 -0
- package/build/core/strategies/reorder/is_improving_greedy_trial.js +17 -0
- package/build/core/strategies/reorder/select_surviving_beam.d.ts +11 -0
- package/build/core/strategies/reorder/select_surviving_beam.d.ts.map +1 -0
- package/build/core/strategies/reorder/select_surviving_beam.js +13 -0
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts +37 -3
- package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +1 -1
- package/build/core/validation/contract/cargo_movement_wire_field_map.js +40 -6
- package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts.map +1 -1
- package/build/core/validation/contract/cargo_movement_wire_mapper.js +10 -1
- package/build/core/validation/contract/map_contract_to_wire_shape.d.ts.map +1 -1
- package/build/core/validation/contract/map_contract_to_wire_shape.js +12 -21
- package/build/core/validation/contract/map_input_config.d.ts +9 -0
- package/build/core/validation/contract/map_input_config.d.ts.map +1 -0
- package/build/core/validation/contract/map_input_config.js +40 -0
- package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +1 -1
- package/build/core/validation/contract/map_wire_input_to_contract_shape.js +28 -22
- package/build/core/validation/contract/map_wire_item_stacking.d.ts +7 -0
- package/build/core/validation/contract/map_wire_item_stacking.d.ts.map +1 -0
- package/build/core/validation/contract/map_wire_item_stacking.js +40 -0
- package/build/core/validation/contract/map_wire_item_to_contract.d.ts +1 -5
- package/build/core/validation/contract/map_wire_item_to_contract.d.ts.map +1 -1
- package/build/core/validation/contract/map_wire_item_to_contract.js +16 -14
- package/build/core/validation/contract/parse_stabilizer_input.d.ts +49 -7
- package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +1 -1
- package/build/core/validation/contract/parse_stabilizer_input.js +2 -0
- package/build/core/validation/contract/parse_stabilizer_output.d.ts +34 -5
- package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +1 -1
- package/build/core/validation/contract/reject_forbidden_input_fields.d.ts +6 -0
- package/build/core/validation/contract/reject_forbidden_input_fields.d.ts.map +1 -0
- package/build/core/validation/contract/reject_forbidden_input_fields.js +53 -0
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts +36 -65
- package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +1 -1
- package/build/core/validation/contract/stabilizer_domain_schema.js +16 -38
- package/build/core/validation/contract/stabilizer_env_schema.d.ts +112 -0
- package/build/core/validation/contract/stabilizer_env_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_env_schema.js +38 -0
- package/build/core/validation/contract/stabilizer_input_schema.d.ts +51 -7
- package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +1 -1
- package/build/core/validation/contract/stabilizer_input_schema.js +2 -2
- package/build/core/validation/contract/stabilizer_item_schema.d.ts +25 -0
- package/build/core/validation/contract/stabilizer_item_schema.d.ts.map +1 -0
- package/build/core/validation/contract/stabilizer_item_schema.js +23 -0
- package/build/core/validation/contract/stabilizer_output_schema.d.ts +68 -10
- package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +1 -1
- package/build/core/validation/contract/uniquify_contract_item_ids.d.ts +14 -0
- package/build/core/validation/contract/uniquify_contract_item_ids.d.ts.map +1 -0
- package/build/core/validation/contract/uniquify_contract_item_ids.js +54 -0
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts +2 -1
- package/build/core/validation/schemas/stabilizer_config_schema.d.ts.map +1 -1
- package/build/core/validation/schemas/stabilizer_config_schema.js +2 -1
- package/build/index.d.ts +11 -12
- package/build/index.d.ts.map +1 -1
- package/build/index.js +29 -21
- package/package.json +28 -13
- package/CHANGELOG.md +0 -38
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { collect_movable_items } from '../filters/collect_movable_items.js';
|
|
2
2
|
import { validate_waypoint_ids } from '../waypoint/validate_waypoint_ids.js';
|
|
3
3
|
import { build_waypoint_zones } from '../waypoint/build_waypoint_zones.js';
|
|
4
4
|
import { build_milkrun_bands_from_config } from './build_milkrun_bands_from_config.js';
|
|
@@ -12,15 +12,13 @@ import { clone_containers } from '../move/apply_move.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export function build_reorder_context(input, config) {
|
|
14
14
|
const env = read_primary_env(input);
|
|
15
|
-
const
|
|
16
|
-
const waypoint_mode = validate_waypoint_ids(all_items);
|
|
17
|
-
const loose_items = collect_loose_items(env.containers);
|
|
15
|
+
const waypoint_mode = validate_waypoint_ids(env.containers.flatMap(container => container.items));
|
|
18
16
|
const baseline_containers = clone_containers(env.containers);
|
|
19
17
|
return {
|
|
20
18
|
env,
|
|
21
19
|
containers: env.containers,
|
|
22
20
|
baseline_containers,
|
|
23
|
-
loose_items,
|
|
21
|
+
loose_items: collect_movable_items(env.containers, config.pin_tie_ratio_blocks),
|
|
24
22
|
config,
|
|
25
23
|
waypoint_mode,
|
|
26
24
|
waypoint_zones: build_waypoint_zones(baseline_containers, waypoint_mode),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeamSearchReorder.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/BeamSearchReorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;
|
|
1
|
+
{"version":3,"file":"BeamSearchReorder.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/BeamSearchReorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAehG;;GAEG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IAErD,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;CAoBtD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { generate_candidates } from '../../candidates/candidate_generator.js';
|
|
2
2
|
import { candidate_context_for_loose } from '../../candidates/build_candidate_context.js';
|
|
3
3
|
import { select_beam_expansion_candidates } from './select_beam_expansion_candidates.js';
|
|
4
|
-
import {
|
|
4
|
+
import { clone_containers } from '../../move/apply_move.js';
|
|
5
5
|
import { evaluate_trial_layout, evaluation_context_from_reorder } from '../../evaluation/state_evaluator.js';
|
|
6
6
|
import { read_item_score } from '../../adapters/stability_adapter.js';
|
|
7
|
+
import { select_surviving_beam } from './select_surviving_beam.js';
|
|
8
|
+
import { append_admitted_trial } from './append_admitted_trial.js';
|
|
7
9
|
/**
|
|
8
10
|
* Beam search reorder with configurable width and top-K expansion.
|
|
9
11
|
*/
|
|
@@ -11,9 +13,11 @@ export class BeamSearchReorder {
|
|
|
11
13
|
run(context) {
|
|
12
14
|
const eval_context = evaluation_context_from_reorder(context);
|
|
13
15
|
const sorted = sort_loose_by_stability(context, eval_context);
|
|
16
|
+
const root_eval = evaluate_trial_layout(context.containers, eval_context);
|
|
14
17
|
let beam = [{
|
|
15
18
|
containers: clone_containers(context.containers),
|
|
16
|
-
objective:
|
|
19
|
+
objective: root_eval.objective,
|
|
20
|
+
axle_excess_kg: root_eval.axle_excess_kg
|
|
17
21
|
}];
|
|
18
22
|
for (const loose of sorted) {
|
|
19
23
|
beam = expand_beam({ reorder: context, evaluation: eval_context, beam, loose });
|
|
@@ -34,21 +38,15 @@ function expand_beam(request) {
|
|
|
34
38
|
loose: request.loose
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
|
-
expanded
|
|
38
|
-
return expanded.slice(0, request.reorder.config.beam_width);
|
|
41
|
+
return select_surviving_beam(expanded, request.beam, request.reorder.config.beam_width);
|
|
39
42
|
}
|
|
40
43
|
function append_beam_branches(beam_context) {
|
|
41
|
-
const { reorder, evaluation,
|
|
44
|
+
const { reorder, evaluation, state, loose } = beam_context;
|
|
42
45
|
const loose_ref = { ...loose, container_index: find_container_index(state.containers, loose.item_id) };
|
|
46
|
+
const parent_eval = evaluate_trial_layout(state.containers, evaluation);
|
|
43
47
|
const candidates = select_beam_expansion_candidates(generate_candidates(candidate_context_for_loose(reorder, state.containers, loose_ref)), reorder.config.beam_top_k);
|
|
44
48
|
for (const candidate of candidates) {
|
|
45
|
-
|
|
46
|
-
apply_move(trial, candidate);
|
|
47
|
-
const result = evaluate_trial_layout(trial, evaluation);
|
|
48
|
-
if (!result.all_gates_pass) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
expanded.push({ containers: trial, objective: result.objective });
|
|
49
|
+
append_admitted_trial(beam_context, parent_eval, candidate);
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
function sort_loose_by_stability(context, eval_context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneticReorder.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/GeneticReorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;
|
|
1
|
+
{"version":3,"file":"GeneticReorder.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/GeneticReorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAchG;;GAEG;AACH,qBAAa,cAAe,YAAW,eAAe;IAElD,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;CAgBtD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { build_initial_population, crossover_organisms, materialize_organism, mutate_organism } from './genetic/Chromosome.js';
|
|
2
2
|
import { evaluate_trial_layout, evaluation_context_from_reorder } from '../../evaluation/state_evaluator.js';
|
|
3
|
+
import { genetic_fitness } from '../../evaluation/genetic_fitness.js';
|
|
3
4
|
/**
|
|
4
5
|
* Genetic algorithm reorder optimizing loose-item stability sum.
|
|
5
6
|
*/
|
|
@@ -39,5 +40,5 @@ function score_population(context, eval_context, population) {
|
|
|
39
40
|
function score_organism(context, eval_context, organism) {
|
|
40
41
|
const layout = materialize_organism(context.baseline_containers, organism);
|
|
41
42
|
const evaluation = evaluate_trial_layout(layout, eval_context);
|
|
42
|
-
organism.fitness = evaluation
|
|
43
|
+
organism.fitness = genetic_fitness(evaluation);
|
|
43
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatedAnnealingReorder.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/SimulatedAnnealingReorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;
|
|
1
|
+
{"version":3,"file":"SimulatedAnnealingReorder.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/SimulatedAnnealingReorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AA0BhG;;GAEG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAE7D,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;CAqBtD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { apply_move, clone_containers } from '../../move/apply_move.js';
|
|
2
2
|
import { evaluate_trial_layout, evaluation_context_from_reorder } from '../../evaluation/state_evaluator.js';
|
|
3
3
|
import { accept_move, propose_neighbor } from './anneal_helpers.js';
|
|
4
|
+
import { is_search_trial_admissible } from '../../evaluation/is_search_trial_admissible.js';
|
|
4
5
|
/**
|
|
5
6
|
* Simulated annealing reorder with hard gate rejection on invalid neighbors.
|
|
6
7
|
*/
|
|
@@ -10,7 +11,7 @@ export class SimulatedAnnealingReorder {
|
|
|
10
11
|
const state = {
|
|
11
12
|
working: clone_containers(context.containers),
|
|
12
13
|
best: clone_containers(context.containers),
|
|
13
|
-
best_energy:
|
|
14
|
+
best_energy: search_energy(context.containers, eval_context)
|
|
14
15
|
};
|
|
15
16
|
let temperature = 1.0;
|
|
16
17
|
const cooling_rate = 0.995;
|
|
@@ -37,12 +38,16 @@ function anneal_step(step_context) {
|
|
|
37
38
|
function evaluate_neighbor(step_context, neighbor) {
|
|
38
39
|
const trial = clone_containers(step_context.state.working);
|
|
39
40
|
apply_move(trial, neighbor);
|
|
41
|
+
const working_eval = evaluate_trial_layout(step_context.state.working, step_context.evaluation);
|
|
40
42
|
const evaluation = evaluate_trial_layout(trial, step_context.evaluation);
|
|
41
|
-
if (!evaluation
|
|
43
|
+
if (!is_search_trial_admissible(working_eval, evaluation)) {
|
|
42
44
|
return undefined;
|
|
43
45
|
}
|
|
46
|
+
if (!working_eval.axle_valid) {
|
|
47
|
+
return evaluation.axle_excess_kg;
|
|
48
|
+
}
|
|
44
49
|
const trial_energy = -evaluation.objective;
|
|
45
|
-
const delta = trial_energy -
|
|
50
|
+
const delta = trial_energy - search_energy(step_context.state.working, step_context.evaluation);
|
|
46
51
|
if (!accept_move(delta, step_context.temperature)) {
|
|
47
52
|
return undefined;
|
|
48
53
|
}
|
|
@@ -56,6 +61,10 @@ function apply_accepted_neighbor(step_context, neighbor, trial_energy) {
|
|
|
56
61
|
step_context.state.best = clone_containers(step_context.state.working);
|
|
57
62
|
step_context.state.best_energy = trial_energy;
|
|
58
63
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
64
|
+
function search_energy(containers, eval_context) {
|
|
65
|
+
const evaluation = evaluate_trial_layout(containers, eval_context);
|
|
66
|
+
if (!evaluation.axle_valid) {
|
|
67
|
+
return evaluation.axle_excess_kg;
|
|
68
|
+
}
|
|
69
|
+
return -evaluation.objective;
|
|
61
70
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EvaluationResult } from '../../evaluation/evaluation_result.js';
|
|
2
|
+
import type { MoveCandidate } from '../../move/apply_move.js';
|
|
3
|
+
import type { BeamExpansionContext } from './beam_context.js';
|
|
4
|
+
/**
|
|
5
|
+
* Evaluates one candidate and keeps it when search admission allows.
|
|
6
|
+
* @param beam_context - Beam expansion context.
|
|
7
|
+
* @param parent_eval - Parent layout evaluation.
|
|
8
|
+
* @param candidate - Move candidate.
|
|
9
|
+
*/
|
|
10
|
+
export declare function append_admitted_trial(beam_context: BeamExpansionContext, parent_eval: EvaluationResult, candidate: MoveCandidate): void;
|
|
11
|
+
//# sourceMappingURL=append_admitted_trial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append_admitted_trial.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/append_admitted_trial.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAE7D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,YAAY,EAAE,oBAAoB,EAClC,WAAW,EAAE,gBAAgB,EAC7B,SAAS,EAAE,aAAa,GACzB,IAAI,CAcN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { apply_move, clone_containers } from '../../move/apply_move.js';
|
|
2
|
+
import { evaluate_trial_layout } from '../../evaluation/state_evaluator.js';
|
|
3
|
+
import { is_search_trial_admissible } from '../../evaluation/is_search_trial_admissible.js';
|
|
4
|
+
/**
|
|
5
|
+
* Evaluates one candidate and keeps it when search admission allows.
|
|
6
|
+
* @param beam_context - Beam expansion context.
|
|
7
|
+
* @param parent_eval - Parent layout evaluation.
|
|
8
|
+
* @param candidate - Move candidate.
|
|
9
|
+
*/
|
|
10
|
+
export function append_admitted_trial(beam_context, parent_eval, candidate) {
|
|
11
|
+
const trial = clone_containers(beam_context.state.containers);
|
|
12
|
+
apply_move(trial, candidate);
|
|
13
|
+
const result = evaluate_trial_layout(trial, beam_context.evaluation);
|
|
14
|
+
if (!is_search_trial_admissible(parent_eval, result)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
beam_context.expanded.push({
|
|
18
|
+
containers: trial,
|
|
19
|
+
objective: result.objective,
|
|
20
|
+
axle_excess_kg: result.axle_excess_kg
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beam_context.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/beam_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAEpF,MAAM,WAAW,oBAAoB;IAEjC,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,sBAAsB,CAAA;IAClC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,YAAY,CAAA;CACtB;AAED,MAAM,WAAW,SAAS;IAEtB,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"beam_context.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/beam_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAEpF,MAAM,WAAW,oBAAoB;IAEjC,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,sBAAsB,CAAA;IAClC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,YAAY,CAAA;CACtB;AAED,MAAM,WAAW,SAAS;IAEtB,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greedy_improvement.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/greedy_improvement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAEhG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"greedy_improvement.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/greedy_improvement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAEhG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAiBpF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,EAAE,sBAAsB,GACrC,OAAO,CAiBT"}
|
|
@@ -2,6 +2,7 @@ import { generate_candidates } from '../../candidates/candidate_generator.js';
|
|
|
2
2
|
import { candidate_context_for_loose } from '../../candidates/build_candidate_context.js';
|
|
3
3
|
import { apply_move, clone_containers } from '../../move/apply_move.js';
|
|
4
4
|
import { evaluate_trial_layout } from '../../evaluation/state_evaluator.js';
|
|
5
|
+
import { is_improving_greedy_trial } from './is_improving_greedy_trial.js';
|
|
5
6
|
/**
|
|
6
7
|
* Attempts one greedy improvement on the worst loose item.
|
|
7
8
|
* @param context - Reorder context.
|
|
@@ -21,7 +22,7 @@ export function improve_worst_loose(context, working, eval_context) {
|
|
|
21
22
|
working,
|
|
22
23
|
evaluation: eval_context,
|
|
23
24
|
loose: worst,
|
|
24
|
-
|
|
25
|
+
parent_eval: current_eval
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
function try_candidate_moves(move_context) {
|
|
@@ -37,7 +38,7 @@ function apply_improving_candidate(move_context, candidate) {
|
|
|
37
38
|
const trial = clone_containers(move_context.working);
|
|
38
39
|
apply_move(trial, candidate);
|
|
39
40
|
const trial_eval = evaluate_trial_layout(trial, move_context.evaluation);
|
|
40
|
-
if (!
|
|
41
|
+
if (!is_improving_greedy_trial(move_context.parent_eval, trial_eval)) {
|
|
41
42
|
return false;
|
|
42
43
|
}
|
|
43
44
|
apply_move(move_context.working, candidate);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EvaluationResult } from '../../evaluation/evaluation_result.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true when a greedy trial improves the parent layout.
|
|
4
|
+
* Over parents climb on axle excess; legal parents require a better objective.
|
|
5
|
+
* @param parent_eval - Parent evaluation.
|
|
6
|
+
* @param trial_eval - Trial evaluation.
|
|
7
|
+
* @returns True when the trial should be applied.
|
|
8
|
+
*/
|
|
9
|
+
export declare function is_improving_greedy_trial(parent_eval: EvaluationResult, trial_eval: EvaluationResult): boolean;
|
|
10
|
+
//# sourceMappingURL=is_improving_greedy_trial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_improving_greedy_trial.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/is_improving_greedy_trial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAG7E;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACrC,WAAW,EAAE,gBAAgB,EAC7B,UAAU,EAAE,gBAAgB,GAC7B,OAAO,CAWT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { is_search_trial_admissible } from '../../evaluation/is_search_trial_admissible.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true when a greedy trial improves the parent layout.
|
|
4
|
+
* Over parents climb on axle excess; legal parents require a better objective.
|
|
5
|
+
* @param parent_eval - Parent evaluation.
|
|
6
|
+
* @param trial_eval - Trial evaluation.
|
|
7
|
+
* @returns True when the trial should be applied.
|
|
8
|
+
*/
|
|
9
|
+
export function is_improving_greedy_trial(parent_eval, trial_eval) {
|
|
10
|
+
if (!is_search_trial_admissible(parent_eval, trial_eval)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (!parent_eval.axle_valid) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return trial_eval.objective > parent_eval.objective;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BeamState } from './beam_context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps ranked expansions, or the parent beam when every trial failed admission.
|
|
4
|
+
* Ranks by axle excess then stability objective.
|
|
5
|
+
* @param expanded - Trial states that passed search admission.
|
|
6
|
+
* @param parent_beam - Beam states before this item's expansion.
|
|
7
|
+
* @param beam_width - Maximum states to keep.
|
|
8
|
+
* @returns Next beam, never empty when the parent beam had states.
|
|
9
|
+
*/
|
|
10
|
+
export declare function select_surviving_beam(expanded: BeamState[], parent_beam: BeamState[], beam_width: number): BeamState[];
|
|
11
|
+
//# sourceMappingURL=select_surviving_beam.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select_surviving_beam.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/select_surviving_beam.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGlD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,SAAS,EAAE,EACrB,WAAW,EAAE,SAAS,EAAE,EACxB,UAAU,EAAE,MAAM,GACnB,SAAS,EAAE,CAIb"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { compare_search_states } from '../../evaluation/compare_search_states.js';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps ranked expansions, or the parent beam when every trial failed admission.
|
|
4
|
+
* Ranks by axle excess then stability objective.
|
|
5
|
+
* @param expanded - Trial states that passed search admission.
|
|
6
|
+
* @param parent_beam - Beam states before this item's expansion.
|
|
7
|
+
* @param beam_width - Maximum states to keep.
|
|
8
|
+
* @returns Next beam, never empty when the parent beam had states.
|
|
9
|
+
*/
|
|
10
|
+
export function select_surviving_beam(expanded, parent_beam, beam_width) {
|
|
11
|
+
const ranked = [...parent_beam, ...expanded].sort(compare_search_states);
|
|
12
|
+
return ranked.slice(0, beam_width);
|
|
13
|
+
}
|
|
@@ -7,9 +7,7 @@ export declare const ITEM_WIRE_TO_CONTRACT: {
|
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Cargo-movement wire keys feeding each contract item field, in precedence
|
|
10
|
-
* order.
|
|
11
|
-
* these keys are read rather than renamed: the original wire record is
|
|
12
|
-
* retained in `attributes` and is what gets emitted back.
|
|
10
|
+
* order. Only modelled stabilizer and dependency fields are read.
|
|
13
11
|
*/
|
|
14
12
|
export declare const ITEM_CONTRACT_WIRE_KEYS: Readonly<{
|
|
15
13
|
item_id: string[];
|
|
@@ -19,6 +17,16 @@ export declare const ITEM_CONTRACT_WIRE_KEYS: Readonly<{
|
|
|
19
17
|
height: string[];
|
|
20
18
|
depth: string[];
|
|
21
19
|
weight: string[];
|
|
20
|
+
tie_ratio_orientation: string[];
|
|
21
|
+
family: string[];
|
|
22
|
+
supported_families: string[];
|
|
23
|
+
constraint: string[];
|
|
24
|
+
stack_families: string[];
|
|
25
|
+
stack_same_item: string[];
|
|
26
|
+
stack_same_area: string[];
|
|
27
|
+
stacking_unit: string[];
|
|
28
|
+
supported_weight: string[];
|
|
29
|
+
priority: string[];
|
|
22
30
|
}>;
|
|
23
31
|
/** Item fields the stabilizer mutates, and therefore must emit itself. */
|
|
24
32
|
export declare const ITEM_POSITION_KEYS: string[];
|
|
@@ -27,6 +35,30 @@ export declare const CONTAINER_WIRE_TO_CONTRACT: {
|
|
|
27
35
|
readonly largura: "width";
|
|
28
36
|
readonly altura: "height";
|
|
29
37
|
readonly comprimento: "length";
|
|
38
|
+
readonly distPinoRei: "kingpin_distance";
|
|
39
|
+
readonly containerDistanceAhead: "container_distance_ahead";
|
|
40
|
+
readonly pesoMaxSuportado: "max_supported_weight";
|
|
41
|
+
readonly tara: "tare";
|
|
42
|
+
readonly pesoDeCarga: "cargo_weight";
|
|
43
|
+
readonly grouper: "grouper";
|
|
44
|
+
};
|
|
45
|
+
export declare const VEHICLE_WIRE_TO_CONTRACT: {
|
|
46
|
+
readonly _id: "vehicle_id";
|
|
47
|
+
readonly tipoVeiculo: "vehicle_type";
|
|
48
|
+
readonly tipoVersao: "version_type";
|
|
49
|
+
readonly tipoSuspensao: "suspension_type";
|
|
50
|
+
readonly primeiroEixo: "first_axle";
|
|
51
|
+
readonly tara: "tare";
|
|
52
|
+
readonly pesoMaxSuportado: "max_supported_weight";
|
|
53
|
+
readonly qtd: "quantity";
|
|
54
|
+
};
|
|
55
|
+
export declare const AXLE_WIRE_TO_CONTRACT: {
|
|
56
|
+
readonly distanciaOrigem: "distance_from_origin";
|
|
57
|
+
readonly pesoMaxSuportado: "max_supported_weight";
|
|
58
|
+
readonly pesoDnit: "dnit_weight";
|
|
59
|
+
readonly tara: "tare";
|
|
60
|
+
readonly sequenciaContainer: "container_sequence";
|
|
61
|
+
readonly sequence: "sequence";
|
|
30
62
|
};
|
|
31
63
|
export declare const ENV_WIRE_TO_CONTRACT: {
|
|
32
64
|
readonly eixos: "axles";
|
|
@@ -34,4 +66,6 @@ export declare const ENV_WIRE_TO_CONTRACT: {
|
|
|
34
66
|
export declare const CONTRACT_TO_ITEM_WIRE: Record<string, string>;
|
|
35
67
|
export declare const CONTRACT_TO_CONTAINER_WIRE: Record<string, string>;
|
|
36
68
|
export declare const CONTRACT_TO_ENV_WIRE: Record<string, string>;
|
|
69
|
+
export declare const CONTRACT_TO_VEHICLE_WIRE: Record<string, string>;
|
|
70
|
+
export declare const CONTRACT_TO_AXLE_WIRE: Record<string, string>;
|
|
37
71
|
//# sourceMappingURL=cargo_movement_wire_field_map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo_movement_wire_field_map.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_field_map.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;CAMxB,CAAA;AAEV
|
|
1
|
+
{"version":3,"file":"cargo_movement_wire_field_map.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_field_map.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;CAMxB,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAkBlC,CAAA;AAEF,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,UAAkB,CAAA;AAEjD,eAAO,MAAM,0BAA0B;;;;;;;;;;;CAW7B,CAAA;AAEV,eAAO,MAAM,wBAAwB;;;;;;;;;CAS3B,CAAA;AAEV,eAAO,MAAM,qBAAqB;;;;;;;CAOxB,CAAA;AAEV,eAAO,MAAM,oBAAoB;;CAEvB,CAAA;AAEV,eAAO,MAAM,qBAAqB,wBAAoC,CAAA;AACtE,eAAO,MAAM,0BAA0B,wBAAyC,CAAA;AAChF,eAAO,MAAM,oBAAoB,wBAAmC,CAAA;AACpE,eAAO,MAAM,wBAAwB,wBAAuC,CAAA;AAC5E,eAAO,MAAM,qBAAqB,wBAAoC,CAAA"}
|
|
@@ -7,18 +7,26 @@ export const ITEM_WIRE_TO_CONTRACT = {
|
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Cargo-movement wire keys feeding each contract item field, in precedence
|
|
10
|
-
* order.
|
|
11
|
-
* these keys are read rather than renamed: the original wire record is
|
|
12
|
-
* retained in `attributes` and is what gets emitted back.
|
|
10
|
+
* order. Only modelled stabilizer and dependency fields are read.
|
|
13
11
|
*/
|
|
14
12
|
export const ITEM_CONTRACT_WIRE_KEYS = Object.freeze({
|
|
15
|
-
item_id: ['
|
|
13
|
+
item_id: ['_id', 'item_id'],
|
|
16
14
|
group_id: ['groupId', 'group_id'],
|
|
17
15
|
waypoint_id: ['waypoint_id'],
|
|
18
16
|
width: ['w', 'width'],
|
|
19
17
|
height: ['h', 'height'],
|
|
20
18
|
depth: ['d', 'depth'],
|
|
21
|
-
weight: ['wg', 'peso', 'weight']
|
|
19
|
+
weight: ['wg', 'peso', 'weight'],
|
|
20
|
+
tie_ratio_orientation: ['tie_ratio_orientation'],
|
|
21
|
+
family: ['family'],
|
|
22
|
+
supported_families: ['supported_families'],
|
|
23
|
+
constraint: ['constraint'],
|
|
24
|
+
stack_families: ['stack_families'],
|
|
25
|
+
stack_same_item: ['stack_same_item'],
|
|
26
|
+
stack_same_area: ['stack_same_area'],
|
|
27
|
+
stacking_unit: ['stacking_unit', 'stackingUnit'],
|
|
28
|
+
supported_weight: ['supported_weight', 'pesoMaxSuportado'],
|
|
29
|
+
priority: ['priority']
|
|
22
30
|
});
|
|
23
31
|
/** Item fields the stabilizer mutates, and therefore must emit itself. */
|
|
24
32
|
export const ITEM_POSITION_KEYS = ['x', 'y', 'z'];
|
|
@@ -26,7 +34,31 @@ export const CONTAINER_WIRE_TO_CONTRACT = {
|
|
|
26
34
|
sequencia: 'sequence',
|
|
27
35
|
largura: 'width',
|
|
28
36
|
altura: 'height',
|
|
29
|
-
comprimento: 'length'
|
|
37
|
+
comprimento: 'length',
|
|
38
|
+
distPinoRei: 'kingpin_distance',
|
|
39
|
+
containerDistanceAhead: 'container_distance_ahead',
|
|
40
|
+
pesoMaxSuportado: 'max_supported_weight',
|
|
41
|
+
tara: 'tare',
|
|
42
|
+
pesoDeCarga: 'cargo_weight',
|
|
43
|
+
grouper: 'grouper'
|
|
44
|
+
};
|
|
45
|
+
export const VEHICLE_WIRE_TO_CONTRACT = {
|
|
46
|
+
_id: 'vehicle_id',
|
|
47
|
+
tipoVeiculo: 'vehicle_type',
|
|
48
|
+
tipoVersao: 'version_type',
|
|
49
|
+
tipoSuspensao: 'suspension_type',
|
|
50
|
+
primeiroEixo: 'first_axle',
|
|
51
|
+
tara: 'tare',
|
|
52
|
+
pesoMaxSuportado: 'max_supported_weight',
|
|
53
|
+
qtd: 'quantity'
|
|
54
|
+
};
|
|
55
|
+
export const AXLE_WIRE_TO_CONTRACT = {
|
|
56
|
+
distanciaOrigem: 'distance_from_origin',
|
|
57
|
+
pesoMaxSuportado: 'max_supported_weight',
|
|
58
|
+
pesoDnit: 'dnit_weight',
|
|
59
|
+
tara: 'tare',
|
|
60
|
+
sequenciaContainer: 'container_sequence',
|
|
61
|
+
sequence: 'sequence'
|
|
30
62
|
};
|
|
31
63
|
export const ENV_WIRE_TO_CONTRACT = {
|
|
32
64
|
eixos: 'axles'
|
|
@@ -34,6 +66,8 @@ export const ENV_WIRE_TO_CONTRACT = {
|
|
|
34
66
|
export const CONTRACT_TO_ITEM_WIRE = invert_map(ITEM_WIRE_TO_CONTRACT);
|
|
35
67
|
export const CONTRACT_TO_CONTAINER_WIRE = invert_map(CONTAINER_WIRE_TO_CONTRACT);
|
|
36
68
|
export const CONTRACT_TO_ENV_WIRE = invert_map(ENV_WIRE_TO_CONTRACT);
|
|
69
|
+
export const CONTRACT_TO_VEHICLE_WIRE = invert_map(VEHICLE_WIRE_TO_CONTRACT);
|
|
70
|
+
export const CONTRACT_TO_AXLE_WIRE = invert_map(AXLE_WIRE_TO_CONTRACT);
|
|
37
71
|
function invert_map(source) {
|
|
38
72
|
const inverted = {};
|
|
39
73
|
for (const [wire_key, contract_key] of Object.entries(source)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo_movement_wire_mapper.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"cargo_movement_wire_mapper.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAQzE;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAcvE;AAqBD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAGtF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { map_cargo_state_to_wire } from './map_contract_to_wire_shape.js';
|
|
2
2
|
import { map_cargo_state_to_contract } from './map_wire_input_to_contract_shape.js';
|
|
3
|
+
import { map_envelope_config } from './map_input_config.js';
|
|
3
4
|
import { is_record } from './wire_mapper_record_utils.js';
|
|
4
|
-
const INPUT_ENVELOPE_KEYS = new Set(['id', 'company', 'cargo_state', 'config'
|
|
5
|
+
const INPUT_ENVELOPE_KEYS = new Set(['id', 'company', 'cargo_state', 'config']);
|
|
5
6
|
/**
|
|
6
7
|
* Maps a cargo-movement wire payload to the English contract shape.
|
|
7
8
|
* @param input_data - Unknown CM wire payload.
|
|
@@ -11,6 +12,14 @@ export function map_wire_input_to_contract(input_data) {
|
|
|
11
12
|
if (!is_record(input_data)) {
|
|
12
13
|
return input_data;
|
|
13
14
|
}
|
|
15
|
+
const mapped = map_envelope_fields(input_data);
|
|
16
|
+
const mapped_config = map_envelope_config(input_data.config, input_data.cargo_state);
|
|
17
|
+
if (mapped_config !== undefined) {
|
|
18
|
+
mapped.config = mapped_config;
|
|
19
|
+
}
|
|
20
|
+
return mapped;
|
|
21
|
+
}
|
|
22
|
+
function map_envelope_fields(input_data) {
|
|
14
23
|
const mapped = {};
|
|
15
24
|
for (const [key, value] of Object.entries(input_data)) {
|
|
16
25
|
if (!INPUT_ENVELOPE_KEYS.has(key)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map_contract_to_wire_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_contract_to_wire_shape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map_contract_to_wire_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_contract_to_wire_shape.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAIzE,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAKlF"}
|
|
@@ -1,42 +1,33 @@
|
|
|
1
|
-
import { CONTRACT_TO_CONTAINER_WIRE, CONTRACT_TO_ITEM_WIRE } from './cargo_movement_wire_field_map.js';
|
|
1
|
+
import { CONTRACT_TO_AXLE_WIRE, CONTRACT_TO_CONTAINER_WIRE, CONTRACT_TO_ITEM_WIRE, CONTRACT_TO_VEHICLE_WIRE } from './cargo_movement_wire_field_map.js';
|
|
2
2
|
import { omit_keys, rename_keys } from './wire_mapper_record_utils.js';
|
|
3
|
+
import { strip_uniquify_suffix } from './uniquify_contract_item_ids.js';
|
|
3
4
|
export function map_cargo_state_to_wire(cargo_state) {
|
|
4
|
-
|
|
5
|
+
return {
|
|
5
6
|
envs: cargo_state.envs.map(map_env_to_wire)
|
|
6
7
|
};
|
|
7
|
-
if (cargo_state.config !== undefined) {
|
|
8
|
-
wire.config = cargo_state.config;
|
|
9
|
-
}
|
|
10
|
-
return wire;
|
|
11
8
|
}
|
|
12
9
|
function map_env_to_wire(env) {
|
|
13
|
-
const wire =
|
|
10
|
+
const wire = env.vehicle === undefined
|
|
11
|
+
? {}
|
|
12
|
+
: rename_keys(env.vehicle, CONTRACT_TO_VEHICLE_WIRE);
|
|
14
13
|
wire.containers = env.containers.map(map_container_to_wire);
|
|
15
14
|
if (env.axles !== undefined) {
|
|
16
|
-
wire.eixos = env.axles;
|
|
15
|
+
wire.eixos = env.axles.map(axle => rename_keys(axle, CONTRACT_TO_AXLE_WIRE));
|
|
17
16
|
}
|
|
18
17
|
return wire;
|
|
19
18
|
}
|
|
20
19
|
function map_container_to_wire(container) {
|
|
21
|
-
const modelled = omit_keys(container, ['
|
|
22
|
-
const wire =
|
|
23
|
-
Object.assign(wire, rename_keys(modelled, CONTRACT_TO_CONTAINER_WIRE));
|
|
20
|
+
const modelled = omit_keys(container, ['items']);
|
|
21
|
+
const wire = rename_keys(modelled, CONTRACT_TO_CONTAINER_WIRE);
|
|
24
22
|
wire.items = container.items.map(map_item_to_wire);
|
|
25
23
|
return wire;
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
28
|
-
* Emits a contract item
|
|
29
|
-
*
|
|
30
|
-
* Position is the only field the stabilizer mutates, so an item that came from
|
|
31
|
-
* the cargo-movement wire is emitted as its retained original record with the
|
|
32
|
-
* new position stamped on. Items parsed straight from the English contract have
|
|
33
|
-
* no retained record and fall back to renaming the modelled fields.
|
|
26
|
+
* Emits a contract item to CM wire keys. Position stays in contract axes
|
|
27
|
+
* for English items; CM `w`-shaped callers swap y/z before parse.
|
|
34
28
|
* @param item - Contract item.
|
|
35
29
|
* @returns Wire item.
|
|
36
30
|
*/
|
|
37
31
|
function map_item_to_wire(item) {
|
|
38
|
-
|
|
39
|
-
return rename_keys(omit_keys(item, ['attributes']), CONTRACT_TO_ITEM_WIRE);
|
|
40
|
-
}
|
|
41
|
-
return { ...item.attributes, x: item.x, y: item.y, z: item.z };
|
|
32
|
+
return rename_keys({ ...item, item_id: strip_uniquify_suffix(item.item_id) }, CONTRACT_TO_ITEM_WIRE);
|
|
42
33
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps envelope plus cargo-profile algoritmo maps onto English stabilizer config.
|
|
3
|
+
* English config objects are returned unchanged for strict Zod checking.
|
|
4
|
+
* @param envelope_config - Envelope config from wire or English input.
|
|
5
|
+
* @param wire_cargo_state - Wire cargo state that may hold profile algoritmo.
|
|
6
|
+
* @returns Raw English config, or the original English object.
|
|
7
|
+
*/
|
|
8
|
+
export declare function map_envelope_config(envelope_config: unknown, wire_cargo_state: unknown): unknown;
|
|
9
|
+
//# sourceMappingURL=map_input_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map_input_config.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_input_config.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAgBhG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { is_record } from './wire_mapper_record_utils.js';
|
|
2
|
+
import { merge_algoritmo_maps, read_raw_stabilizer_config } from '../../factory/read_stabilizer_config_helpers.js';
|
|
3
|
+
const ALGORITMO_PREFIX = 'cargo_stabilizer.';
|
|
4
|
+
/**
|
|
5
|
+
* Maps envelope plus cargo-profile algoritmo maps onto English stabilizer config.
|
|
6
|
+
* English config objects are returned unchanged for strict Zod checking.
|
|
7
|
+
* @param envelope_config - Envelope config from wire or English input.
|
|
8
|
+
* @param wire_cargo_state - Wire cargo state that may hold profile algoritmo.
|
|
9
|
+
* @returns Raw English config, or the original English object.
|
|
10
|
+
*/
|
|
11
|
+
export function map_envelope_config(envelope_config, wire_cargo_state) {
|
|
12
|
+
if (envelope_config === undefined && !has_profile_algoritmo(wire_cargo_state)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
if (is_algoritmo_shaped(envelope_config) || has_profile_algoritmo(wire_cargo_state)) {
|
|
16
|
+
return read_raw_stabilizer_config(merge_algoritmo_maps(as_record(envelope_config), { config: read_wire_profile_config(wire_cargo_state) }));
|
|
17
|
+
}
|
|
18
|
+
return envelope_config;
|
|
19
|
+
}
|
|
20
|
+
function is_algoritmo_shaped(config) {
|
|
21
|
+
if (!is_record(config)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (is_record(config.algoritmo)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return Object.keys(config).some(key => key.startsWith(ALGORITMO_PREFIX));
|
|
28
|
+
}
|
|
29
|
+
function has_profile_algoritmo(wire_cargo_state) {
|
|
30
|
+
return is_record(read_wire_profile_config(wire_cargo_state)?.algoritmo);
|
|
31
|
+
}
|
|
32
|
+
function read_wire_profile_config(wire_cargo_state) {
|
|
33
|
+
if (!is_record(wire_cargo_state) || !is_record(wire_cargo_state.config)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return wire_cargo_state.config;
|
|
37
|
+
}
|
|
38
|
+
function as_record(value) {
|
|
39
|
+
return is_record(value) ? value : undefined;
|
|
40
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map_wire_input_to_contract_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_wire_input_to_contract_shape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map_wire_input_to_contract_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_wire_input_to_contract_shape.ts"],"names":[],"mappings":"AAkBA,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAYnE"}
|