@jetta/cargo-stabilizer 0.1.0-14 → 0.1.0-15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/README.md +15 -10
  3. package/build/core/adapters/axle_adapter.d.ts +1 -0
  4. package/build/core/adapters/axle_adapter.d.ts.map +1 -1
  5. package/build/core/adapters/axle_adapter.js +3 -22
  6. package/build/core/adapters/axle_load_evaluation.d.ts +8 -0
  7. package/build/core/adapters/axle_load_evaluation.d.ts.map +1 -0
  8. package/build/core/adapters/axle_load_evaluation.js +1 -0
  9. package/build/core/adapters/build_axle_request.d.ts +2 -9
  10. package/build/core/adapters/build_axle_request.d.ts.map +1 -1
  11. package/build/core/adapters/build_axle_request.js +52 -24
  12. package/build/core/adapters/compute_axle_excess_kg.d.ts +8 -0
  13. package/build/core/adapters/compute_axle_excess_kg.d.ts.map +1 -0
  14. package/build/core/adapters/compute_axle_excess_kg.js +19 -0
  15. package/build/core/adapters/evaluate_axle_load.d.ts +10 -0
  16. package/build/core/adapters/evaluate_axle_load.d.ts.map +1 -0
  17. package/build/core/adapters/evaluate_axle_load.js +32 -0
  18. package/build/core/adapters/map_item_to_stacking_item.d.ts +14 -0
  19. package/build/core/adapters/map_item_to_stacking_item.d.ts.map +1 -0
  20. package/build/core/adapters/map_item_to_stacking_item.js +40 -0
  21. package/build/core/adapters/run_axle_calculator.d.ts.map +1 -1
  22. package/build/core/adapters/run_axle_calculator.js +21 -16
  23. package/build/core/candidates/candidate_validation.d.ts.map +1 -1
  24. package/build/core/candidates/candidate_validation.js +4 -0
  25. package/build/core/candidates/is_candidate_stacking_valid.d.ts +14 -0
  26. package/build/core/candidates/is_candidate_stacking_valid.d.ts.map +1 -0
  27. package/build/core/candidates/is_candidate_stacking_valid.js +43 -0
  28. package/build/core/evaluation/compare_search_states.d.ts +12 -0
  29. package/build/core/evaluation/compare_search_states.d.ts.map +1 -0
  30. package/build/core/evaluation/compare_search_states.js +12 -0
  31. package/build/core/evaluation/evaluate_search_gates.d.ts +18 -0
  32. package/build/core/evaluation/evaluate_search_gates.d.ts.map +1 -0
  33. package/build/core/evaluation/evaluate_search_gates.js +30 -0
  34. package/build/core/evaluation/evaluation_result.d.ts +15 -0
  35. package/build/core/evaluation/evaluation_result.d.ts.map +1 -0
  36. package/build/core/evaluation/evaluation_result.js +1 -0
  37. package/build/core/evaluation/genetic_fitness.d.ts +9 -0
  38. package/build/core/evaluation/genetic_fitness.d.ts.map +1 -0
  39. package/build/core/evaluation/genetic_fitness.js +16 -0
  40. package/build/core/evaluation/is_non_axle_gates_pass.d.ts +8 -0
  41. package/build/core/evaluation/is_non_axle_gates_pass.d.ts.map +1 -0
  42. package/build/core/evaluation/is_non_axle_gates_pass.js +8 -0
  43. package/build/core/evaluation/is_search_trial_admissible.d.ts +10 -0
  44. package/build/core/evaluation/is_search_trial_admissible.d.ts.map +1 -0
  45. package/build/core/evaluation/is_search_trial_admissible.js +17 -0
  46. package/build/core/evaluation/is_waypoint_order_valid.d.ts +10 -0
  47. package/build/core/evaluation/is_waypoint_order_valid.d.ts.map +1 -0
  48. package/build/core/evaluation/is_waypoint_order_valid.js +14 -0
  49. package/build/core/evaluation/state_evaluator.d.ts +2 -10
  50. package/build/core/evaluation/state_evaluator.d.ts.map +1 -1
  51. package/build/core/evaluation/state_evaluator.js +6 -26
  52. package/build/core/factory/read_stabilizer_config.d.ts +3 -2
  53. package/build/core/factory/read_stabilizer_config.d.ts.map +1 -1
  54. package/build/core/factory/read_stabilizer_config_helpers.d.ts +5 -2
  55. package/build/core/factory/read_stabilizer_config_helpers.d.ts.map +1 -1
  56. package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.js +1 -1
  57. package/build/core/geometry/has_penetrating_overlap.d.ts +1 -1
  58. package/build/core/geometry/has_penetrating_overlap.d.ts.map +1 -1
  59. package/build/core/geometry/has_penetrating_overlap.js +5 -5
  60. package/build/core/orchestration/StabilizerFlow.d.ts.map +1 -1
  61. package/build/core/orchestration/StabilizerFlow.js +1 -1
  62. package/build/core/strategies/reorder/BeamSearchReorder.d.ts.map +1 -1
  63. package/build/core/strategies/reorder/BeamSearchReorder.js +8 -10
  64. package/build/core/strategies/reorder/GeneticReorder.d.ts.map +1 -1
  65. package/build/core/strategies/reorder/GeneticReorder.js +2 -1
  66. package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts.map +1 -1
  67. package/build/core/strategies/reorder/SimulatedAnnealingReorder.js +14 -5
  68. package/build/core/strategies/reorder/append_admitted_trial.d.ts +11 -0
  69. package/build/core/strategies/reorder/append_admitted_trial.d.ts.map +1 -0
  70. package/build/core/strategies/reorder/append_admitted_trial.js +22 -0
  71. package/build/core/strategies/reorder/beam_context.d.ts +1 -0
  72. package/build/core/strategies/reorder/beam_context.d.ts.map +1 -1
  73. package/build/core/strategies/reorder/greedy_improvement.d.ts.map +1 -1
  74. package/build/core/strategies/reorder/greedy_improvement.js +3 -2
  75. package/build/core/strategies/reorder/is_improving_greedy_trial.d.ts +10 -0
  76. package/build/core/strategies/reorder/is_improving_greedy_trial.d.ts.map +1 -0
  77. package/build/core/strategies/reorder/is_improving_greedy_trial.js +17 -0
  78. package/build/core/strategies/reorder/select_surviving_beam.d.ts +3 -2
  79. package/build/core/strategies/reorder/select_surviving_beam.d.ts.map +1 -1
  80. package/build/core/strategies/reorder/select_surviving_beam.js +5 -4
  81. package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts +37 -3
  82. package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +1 -1
  83. package/build/core/validation/contract/cargo_movement_wire_field_map.js +40 -6
  84. package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts.map +1 -1
  85. package/build/core/validation/contract/cargo_movement_wire_mapper.js +10 -1
  86. package/build/core/validation/contract/map_contract_to_wire_shape.d.ts.map +1 -1
  87. package/build/core/validation/contract/map_contract_to_wire_shape.js +12 -24
  88. package/build/core/validation/contract/map_input_config.d.ts +9 -0
  89. package/build/core/validation/contract/map_input_config.d.ts.map +1 -0
  90. package/build/core/validation/contract/map_input_config.js +40 -0
  91. package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +1 -1
  92. package/build/core/validation/contract/map_wire_input_to_contract_shape.js +26 -21
  93. package/build/core/validation/contract/map_wire_item_stacking.d.ts +7 -0
  94. package/build/core/validation/contract/map_wire_item_stacking.d.ts.map +1 -0
  95. package/build/core/validation/contract/map_wire_item_stacking.js +40 -0
  96. package/build/core/validation/contract/map_wire_item_to_contract.d.ts +1 -5
  97. package/build/core/validation/contract/map_wire_item_to_contract.d.ts.map +1 -1
  98. package/build/core/validation/contract/map_wire_item_to_contract.js +3 -9
  99. package/build/core/validation/contract/parse_stabilizer_input.d.ts +49 -7
  100. package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +1 -1
  101. package/build/core/validation/contract/parse_stabilizer_input.js +2 -0
  102. package/build/core/validation/contract/parse_stabilizer_output.d.ts +34 -5
  103. package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +1 -1
  104. package/build/core/validation/contract/reject_forbidden_input_fields.d.ts +6 -0
  105. package/build/core/validation/contract/reject_forbidden_input_fields.d.ts.map +1 -0
  106. package/build/core/validation/contract/reject_forbidden_input_fields.js +53 -0
  107. package/build/core/validation/contract/stabilizer_domain_schema.d.ts +36 -65
  108. package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +1 -1
  109. package/build/core/validation/contract/stabilizer_domain_schema.js +16 -38
  110. package/build/core/validation/contract/stabilizer_env_schema.d.ts +112 -0
  111. package/build/core/validation/contract/stabilizer_env_schema.d.ts.map +1 -0
  112. package/build/core/validation/contract/stabilizer_env_schema.js +38 -0
  113. package/build/core/validation/contract/stabilizer_input_schema.d.ts +51 -7
  114. package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +1 -1
  115. package/build/core/validation/contract/stabilizer_input_schema.js +2 -2
  116. package/build/core/validation/contract/stabilizer_item_schema.d.ts +25 -0
  117. package/build/core/validation/contract/stabilizer_item_schema.d.ts.map +1 -0
  118. package/build/core/validation/contract/stabilizer_item_schema.js +23 -0
  119. package/build/core/validation/contract/stabilizer_output_schema.d.ts +68 -10
  120. package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +1 -1
  121. package/build/core/validation/contract/uniquify_contract_item_ids.d.ts +7 -1
  122. package/build/core/validation/contract/uniquify_contract_item_ids.d.ts.map +1 -1
  123. package/build/core/validation/contract/uniquify_contract_item_ids.js +17 -1
  124. package/build/core/validation/schemas/stabilizer_config_schema.d.ts +1 -1
  125. package/build/core/validation/schemas/stabilizer_config_schema.d.ts.map +1 -1
  126. package/build/core/validation/schemas/stabilizer_config_schema.js +1 -1
  127. package/build/index.d.ts +11 -12
  128. package/build/index.d.ts.map +1 -1
  129. package/build/index.js +29 -21
  130. package/package.json +12 -10
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate_search_gates.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/evaluate_search_gates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAM9D,MAAM,WAAW,iBAAiB;IAE9B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,WAAW,GAAG,gBAAgB,CAAC,CAAA;CAC9E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,EAC/B,SAAS,EAAE,mBAAmB,GAC/B,iBAAiB,CAanB"}
@@ -0,0 +1,30 @@
1
+ import { compute_reorder_objective } from './compute_reorder_objective.js';
2
+ import { evaluate_axle_load } from '../adapters/evaluate_axle_load.js';
3
+ import { is_layout_milkrun_valid } from '../waypoint/milkrun_wall_reservation.js';
4
+ import { is_waypoint_order_valid } from './is_waypoint_order_valid.js';
5
+ /**
6
+ * Computes reorder objective and legality flags for a layout.
7
+ * @param containers - Container layout.
8
+ * @param context - Evaluation context.
9
+ * @param stability - Transport stability evaluation.
10
+ * @returns Objective, pass flag, and gate fields.
11
+ */
12
+ export function evaluate_search_gates(containers, context, stability) {
13
+ const objective = compute_reorder_objective(stability, containers, context.loose_items);
14
+ const axle_load = evaluate_axle_load({ ...context.env, containers }, context.config.axle_load_margin_percent);
15
+ const flags = build_gate_flags({ containers, context, stability, axle_load });
16
+ return {
17
+ objective,
18
+ pass: flags.transport_floor_valid && flags.axle_valid && flags.waypoint_valid && flags.milkrun_valid,
19
+ flags
20
+ };
21
+ }
22
+ function build_gate_flags(input) {
23
+ return {
24
+ transport_floor_valid: input.stability.transport_score >= input.context.config.transport_stability_floor,
25
+ axle_valid: input.axle_load.valid,
26
+ waypoint_valid: is_waypoint_order_valid(input.containers, input.context),
27
+ milkrun_valid: is_layout_milkrun_valid(input.containers, input.context.milkrun_reserved_z_bands),
28
+ axle_excess_kg: input.axle_load.excess_kg
29
+ };
30
+ }
@@ -0,0 +1,15 @@
1
+ import type { StabilityEvaluation } from '../adapters/stability_adapter.js';
2
+ /**
3
+ * Outcome of evaluating a layout against stabilizer gates.
4
+ */
5
+ export interface EvaluationResult {
6
+ stability: StabilityEvaluation;
7
+ objective: number;
8
+ transport_floor_valid: boolean;
9
+ axle_valid: boolean;
10
+ waypoint_valid: boolean;
11
+ milkrun_valid: boolean;
12
+ all_gates_pass: boolean;
13
+ axle_excess_kg: number;
14
+ }
15
+ //# sourceMappingURL=evaluation_result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation_result.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/evaluation_result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAE3E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAE7B,SAAS,EAAE,mBAAmB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,UAAU,EAAE,OAAO,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;CACzB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { EvaluationResult } from './evaluation_result.js';
2
+ export declare const LEGAL_FITNESS_OFFSET = 1000000;
3
+ /**
4
+ * Scores a genetic organism: legal layouts outrank every illegal one.
5
+ * @param evaluation - Layout evaluation.
6
+ * @returns Fitness; higher is better.
7
+ */
8
+ export declare function genetic_fitness(evaluation: EvaluationResult): number;
9
+ //# sourceMappingURL=genetic_fitness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genetic_fitness.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/genetic_fitness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG9D,eAAO,MAAM,oBAAoB,UAAY,CAAA;AAE7C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAWpE"}
@@ -0,0 +1,16 @@
1
+ import { is_non_axle_gates_pass } from './is_non_axle_gates_pass.js';
2
+ export const LEGAL_FITNESS_OFFSET = 1_000_000;
3
+ /**
4
+ * Scores a genetic organism: legal layouts outrank every illegal one.
5
+ * @param evaluation - Layout evaluation.
6
+ * @returns Fitness; higher is better.
7
+ */
8
+ export function genetic_fitness(evaluation) {
9
+ if (!is_non_axle_gates_pass(evaluation)) {
10
+ return Number.NEGATIVE_INFINITY;
11
+ }
12
+ if (evaluation.axle_valid) {
13
+ return LEGAL_FITNESS_OFFSET + evaluation.objective;
14
+ }
15
+ return -evaluation.axle_excess_kg;
16
+ }
@@ -0,0 +1,8 @@
1
+ import type { EvaluationResult } from './evaluation_result.js';
2
+ /**
3
+ * Returns true when waypoint, milkrun, and transport-floor gates pass.
4
+ * @param result - Evaluation result.
5
+ * @returns True when non-axle gates all pass.
6
+ */
7
+ export declare function is_non_axle_gates_pass(result: EvaluationResult): boolean;
8
+ //# sourceMappingURL=is_non_axle_gates_pass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_non_axle_gates_pass.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/is_non_axle_gates_pass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAGxE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns true when waypoint, milkrun, and transport-floor gates pass.
3
+ * @param result - Evaluation result.
4
+ * @returns True when non-axle gates all pass.
5
+ */
6
+ export function is_non_axle_gates_pass(result) {
7
+ return result.transport_floor_valid && result.waypoint_valid && result.milkrun_valid;
8
+ }
@@ -0,0 +1,10 @@
1
+ import type { EvaluationResult } from './evaluation_result.js';
2
+ /**
3
+ * Decides whether a one-item trial may enter the search.
4
+ * Over parents may climb with strictly less axle excess; legal parents keep a hard axle gate.
5
+ * @param parent - Parent layout evaluation.
6
+ * @param child - Trial layout evaluation.
7
+ * @returns True when the trial is admissible.
8
+ */
9
+ export declare function is_search_trial_admissible(parent: EvaluationResult, child: EvaluationResult): boolean;
10
+ //# sourceMappingURL=is_search_trial_admissible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_search_trial_admissible.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/is_search_trial_admissible.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG9D;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,gBAAgB,GACxB,OAAO,CAWT"}
@@ -0,0 +1,17 @@
1
+ import { is_non_axle_gates_pass } from './is_non_axle_gates_pass.js';
2
+ /**
3
+ * Decides whether a one-item trial may enter the search.
4
+ * Over parents may climb with strictly less axle excess; legal parents keep a hard axle gate.
5
+ * @param parent - Parent layout evaluation.
6
+ * @param child - Trial layout evaluation.
7
+ * @returns True when the trial is admissible.
8
+ */
9
+ export function is_search_trial_admissible(parent, child) {
10
+ if (!is_non_axle_gates_pass(child)) {
11
+ return false;
12
+ }
13
+ if (parent.axle_valid) {
14
+ return child.axle_valid;
15
+ }
16
+ return child.axle_excess_kg < parent.axle_excess_kg;
17
+ }
@@ -0,0 +1,10 @@
1
+ import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
2
+ import type { StateEvaluationContext } from './evaluation_context.js';
3
+ /**
4
+ * Returns true when waypoint order is satisfied for the layout.
5
+ * @param containers - Container layout.
6
+ * @param context - Evaluation context.
7
+ * @returns True when waypoint mode is single or order is preserved.
8
+ */
9
+ export declare function is_waypoint_order_valid(containers: StabilizerContainer[], context: StateEvaluationContext): boolean;
10
+ //# sourceMappingURL=is_waypoint_order_valid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_waypoint_order_valid.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/is_waypoint_order_valid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAGrE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC,OAAO,CAeT"}
@@ -0,0 +1,14 @@
1
+ import { preserves_waypoint_order } from '../waypoint/preserves_waypoint_order.js';
2
+ /**
3
+ * Returns true when waypoint order is satisfied for the layout.
4
+ * @param containers - Container layout.
5
+ * @param context - Evaluation context.
6
+ * @returns True when waypoint mode is single or order is preserved.
7
+ */
8
+ export function is_waypoint_order_valid(containers, context) {
9
+ if (context.waypoint_mode.kind === 'SINGLE_WAYPOINT' ||
10
+ !context.config.preserve_tie_block_organization) {
11
+ return true;
12
+ }
13
+ return preserves_waypoint_order(context.baseline_containers, containers, context.waypoint_mode);
14
+ }
@@ -1,16 +1,8 @@
1
1
  import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
2
- import { type StabilityEvaluation } from '../adapters/stability_adapter.js';
3
2
  import type { StateEvaluationContext } from './evaluation_context.js';
4
3
  import type { ReorderContext } from '../strategies/reorder/ReorderStrategy.js';
5
- export interface EvaluationResult {
6
- stability: StabilityEvaluation;
7
- objective: number;
8
- transport_floor_valid: boolean;
9
- axle_valid: boolean;
10
- waypoint_valid: boolean;
11
- milkrun_valid: boolean;
12
- all_gates_pass: boolean;
13
- }
4
+ import type { EvaluationResult } from './evaluation_result.js';
5
+ export type { EvaluationResult };
14
6
  /**
15
7
  * Evaluates a container layout against all stabilizer gates.
16
8
  * @param containers - Container layout to evaluate.
@@ -1 +1 @@
1
- {"version":3,"file":"state_evaluator.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/state_evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,EAEH,KAAK,mBAAmB,EAC3B,MAAM,kCAAkC,CAAA;AAMzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAE9E,MAAM,WAAW,gBAAgB;IAE7B,SAAS,EAAE,mBAAmB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,UAAU,EAAE,OAAO,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAUlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,mBAAmB,EAAE,EAC5B,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAGlB;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,cAAc,GAAG,sBAAsB,CAU/F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,EAAE,CAGvF;AAwBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAMrD"}
1
+ {"version":3,"file":"state_evaluator.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/state_evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAG7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAI9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAUlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,mBAAmB,EAAE,EAC5B,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAGlB;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,cAAc,GAAG,sBAAsB,CAU/F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,EAAE,CAGvF;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAMrD"}
@@ -1,9 +1,8 @@
1
1
  import { try_evaluate_transport_stability } from '../adapters/stability_adapter.js';
2
- import { compute_reorder_objective } from './compute_reorder_objective.js';
3
- import { is_axle_load_valid } from '../adapters/axle_adapter.js';
4
- import { preserves_waypoint_order } from '../waypoint/preserves_waypoint_order.js';
5
- import { is_layout_milkrun_valid } from '../waypoint/milkrun_wall_reservation.js';
6
2
  import { clone_containers } from '../move/apply_move.js';
3
+ import { evaluate_search_gates } from './evaluate_search_gates.js';
4
+ import { is_waypoint_order_valid } from './is_waypoint_order_valid.js';
5
+ import { is_layout_milkrun_valid } from '../waypoint/milkrun_wall_reservation.js';
7
6
  /**
8
7
  * Evaluates a container layout against all stabilizer gates.
9
8
  * @param containers - Container layout to evaluate.
@@ -15,7 +14,7 @@ export function evaluate_state(containers, context) {
15
14
  if (!stability) {
16
15
  return invalid_evaluation_result();
17
16
  }
18
- const gates = evaluate_gates(containers, context, stability);
17
+ const gates = evaluate_search_gates(containers, context, stability);
19
18
  return { stability, objective: gates.objective, ...gates.flags, all_gates_pass: gates.pass };
20
19
  }
21
20
  /**
@@ -50,19 +49,6 @@ export function evaluation_context_from_reorder(context) {
50
49
  export function clone_baseline(containers) {
51
50
  return clone_containers(containers);
52
51
  }
53
- function evaluate_gates(containers, context, stability) {
54
- const objective = compute_reorder_objective(stability, containers, context.loose_items);
55
- const transport_floor_valid = stability.transport_score >= context.config.transport_stability_floor;
56
- const axle_valid = is_axle_load_valid({ ...context.env, containers }, context.config.axle_load_margin_percent);
57
- const waypoint_valid = is_waypoint_order_valid(containers, context);
58
- const milkrun_valid = is_layout_milkrun_valid(containers, context.milkrun_reserved_z_bands);
59
- const flags = { transport_floor_valid, axle_valid, waypoint_valid, milkrun_valid };
60
- return {
61
- objective,
62
- pass: transport_floor_valid && axle_valid && waypoint_valid && milkrun_valid,
63
- flags
64
- };
65
- }
66
52
  /**
67
53
  * Evaluates organization constraint gates without stability or axle checks.
68
54
  * @param containers - Container layout to evaluate.
@@ -75,13 +61,6 @@ export function evaluate_organization_gates(containers, context) {
75
61
  milkrun_valid: is_layout_milkrun_valid(containers, context.milkrun_reserved_z_bands)
76
62
  };
77
63
  }
78
- function is_waypoint_order_valid(containers, context) {
79
- if (context.waypoint_mode.kind === 'SINGLE_WAYPOINT' ||
80
- !context.config.preserve_tie_block_organization) {
81
- return true;
82
- }
83
- return preserves_waypoint_order(context.baseline_containers, containers, context.waypoint_mode);
84
- }
85
64
  function invalid_evaluation_result() {
86
65
  return {
87
66
  stability: { item_scores: [], container_scores: [], transport_score: 0 },
@@ -90,6 +69,7 @@ function invalid_evaluation_result() {
90
69
  axle_valid: false,
91
70
  waypoint_valid: false,
92
71
  milkrun_valid: false,
93
- all_gates_pass: false
72
+ all_gates_pass: false,
73
+ axle_excess_kg: Number.POSITIVE_INFINITY
94
74
  };
95
75
  }
@@ -1,10 +1,11 @@
1
1
  import { type StabilizerConfig } from '../validation/schemas/stabilizer_config_schema.js';
2
- import type { StabilizerCargoState } from '../validation/contract/stabilizer_domain_schema.js';
3
2
  /**
4
3
  * Reads stabilizer config from cargo-movement config and cargo profile algoritmo maps.
5
4
  * @param config - Top-level stabilizer input config object.
6
5
  * @param cargo_state - Cargo profile (optional) for merged algoritmo keys.
7
6
  * @returns Parsed stabilizer configuration.
8
7
  */
9
- export declare function read_stabilizer_config(config: Record<string, unknown> | undefined, cargo_state?: StabilizerCargoState): StabilizerConfig;
8
+ export declare function read_stabilizer_config(config: Record<string, unknown> | undefined, cargo_state?: {
9
+ config?: unknown;
10
+ }): StabilizerConfig;
10
11
  //# sourceMappingURL=read_stabilizer_config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read_stabilizer_config.d.ts","sourceRoot":"","sources":["../../../src/core/factory/read_stabilizer_config.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,KAAK,gBAAgB,EACxB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAA;AAG9F;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,WAAW,CAAC,EAAE,oBAAoB,GACnC,gBAAgB,CAYlB"}
1
+ {"version":3,"file":"read_stabilizer_config.d.ts","sourceRoot":"","sources":["../../../src/core/factory/read_stabilizer_config.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,KAAK,gBAAgB,EACxB,MAAM,mDAAmD,CAAA;AAG1D;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,WAAW,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACnC,gBAAgB,CAYlB"}
@@ -1,11 +1,13 @@
1
- import type { StabilizerCargoState } from '../validation/contract/stabilizer_domain_schema.js';
1
+ type CargoStateConfigHolder = {
2
+ config?: unknown;
3
+ };
2
4
  /**
3
5
  * Merges root and cargo profile algoritmo maps (profile overrides root).
4
6
  * @param config - Root stabilizer input config.
5
7
  * @param cargo_state - Cargo profile state.
6
8
  * @returns Merged algoritmo map.
7
9
  */
8
- export declare function merge_algoritmo_maps(config: Record<string, unknown> | undefined, cargo_state?: StabilizerCargoState): Record<string, unknown>;
10
+ export declare function merge_algoritmo_maps(config: Record<string, unknown> | undefined, cargo_state?: CargoStateConfigHolder): Record<string, unknown>;
9
11
  /**
10
12
  * Reads raw stabilizer config fields from merged algoritmo map.
11
13
  * @param algoritmo - Merged algoritmo configuration map.
@@ -26,4 +28,5 @@ export declare function read_raw_stabilizer_config(algoritmo: Record<string, unk
26
28
  beam_top_k: number;
27
29
  axle_load_margin_percent: number;
28
30
  };
31
+ export {};
29
32
  //# sourceMappingURL=read_stabilizer_config_helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read_stabilizer_config_helpers.d.ts","sourceRoot":"","sources":["../../../src/core/factory/read_stabilizer_config_helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAA;AAK9F;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,WAAW,CAAC,EAAE,oBAAoB,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;;EAM5E"}
1
+ {"version":3,"file":"read_stabilizer_config_helpers.d.ts","sourceRoot":"","sources":["../../../src/core/factory/read_stabilizer_config_helpers.ts"],"names":[],"mappings":"AAGA,KAAK,sBAAsB,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAKlD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,WAAW,CAAC,EAAE,sBAAsB,GACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;;EAM5E"}
@@ -32,7 +32,7 @@ function groups_with_full_floor_wall(counts) {
32
32
  return pinned;
33
33
  }
34
34
  function read_tie_ratio_orientation(item) {
35
- const orientation = item.attributes?.tie_ratio_orientation;
35
+ const orientation = item.tie_ratio_orientation;
36
36
  return typeof orientation === 'string' ? orientation : undefined;
37
37
  }
38
38
  function is_tie_ratio_orientation(orientation) {
@@ -1,7 +1,7 @@
1
1
  import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
2
2
  /**
3
3
  * True when any two items penetrate in the contract frame
4
- * (x + width, y + height, z + depth) by more than a face-touch epsilon.
4
+ * (x + width, y + height, z + depth). Face-touch uses `@jetta/number-compare`.
5
5
  * @param containers - Layout to inspect.
6
6
  * @returns True when a pair occupies the same volume beyond float error.
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"has_penetrating_overlap.d.ts","sourceRoot":"","sources":["../../../src/core/geometry/has_penetrating_overlap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,oDAAoD,CAAA;AAI7G;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAGlF"}
1
+ {"version":3,"file":"has_penetrating_overlap.d.ts","sourceRoot":"","sources":["../../../src/core/geometry/has_penetrating_overlap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,oDAAoD,CAAA;AAE7G;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAGlF"}
@@ -1,7 +1,7 @@
1
- const PENETRATION_EPSILON = 1e-6;
1
+ import { lt } from '@jetta/number-compare';
2
2
  /**
3
3
  * True when any two items penetrate in the contract frame
4
- * (x + width, y + height, z + depth) by more than a face-touch epsilon.
4
+ * (x + width, y + height, z + depth). Face-touch uses `@jetta/number-compare`.
5
5
  * @param containers - Layout to inspect.
6
6
  * @returns True when a pair occupies the same volume beyond float error.
7
7
  */
@@ -20,8 +20,8 @@ function container_has_penetrating_overlap(container) {
20
20
  return false;
21
21
  }
22
22
  function items_penetrate(left, right) {
23
- return interval_penetration({ min: left.x, max: left.x + left.width }, { min: right.x, max: right.x + right.width }) && interval_penetration({ min: left.y, max: left.y + left.height }, { min: right.y, max: right.y + right.height }) && interval_penetration({ min: left.z, max: left.z + left.depth }, { min: right.z, max: right.z + right.depth });
23
+ return intervals_overlap({ min: left.x, max: left.x + left.width }, { min: right.x, max: right.x + right.width }) && intervals_overlap({ min: left.y, max: left.y + left.height }, { min: right.y, max: right.y + right.height }) && intervals_overlap({ min: left.z, max: left.z + left.depth }, { min: right.z, max: right.z + right.depth });
24
24
  }
25
- function interval_penetration(left, right) {
26
- return Math.min(left.max, right.max) - Math.max(left.min, right.min) > PENETRATION_EPSILON;
25
+ function intervals_overlap(left, right) {
26
+ return lt(left.min, right.max) && lt(right.min, left.max);
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StabilizerFlow.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/StabilizerFlow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAA;AACxF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAA;AAO9F;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,CAiBhF;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,OAAO,GAAG,oBAAoB,CAI1F"}
1
+ {"version":3,"file":"StabilizerFlow.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/StabilizerFlow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAA;AACxF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAA;AAO9F;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,CAgBhF;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,OAAO,GAAG,oBAAoB,CAI1F"}
@@ -9,7 +9,7 @@ import { stabilizer_logger } from '../logging/stabilizer_logger.js';
9
9
  * @returns Updated cargo_state.
10
10
  */
11
11
  export function run_stabilizer_flow(input) {
12
- const config = read_stabilizer_config(input.config, input.cargo_state);
12
+ const config = read_stabilizer_config(input.config);
13
13
  const context = build_reorder_context(input, config);
14
14
  stabilizer_logger.debug('reorder_strategy=' + config.reorder_strategy);
15
15
  stabilizer_logger.debug('container_count=' + context.containers.length +
@@ -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;AAchG;;GAEG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IAErD,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;CAkBtD"}
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,10 +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 { apply_move, clone_containers } from '../../move/apply_move.js';
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
7
  import { select_surviving_beam } from './select_surviving_beam.js';
8
+ import { append_admitted_trial } from './append_admitted_trial.js';
8
9
  /**
9
10
  * Beam search reorder with configurable width and top-K expansion.
10
11
  */
@@ -12,9 +13,11 @@ export class BeamSearchReorder {
12
13
  run(context) {
13
14
  const eval_context = evaluation_context_from_reorder(context);
14
15
  const sorted = sort_loose_by_stability(context, eval_context);
16
+ const root_eval = evaluate_trial_layout(context.containers, eval_context);
15
17
  let beam = [{
16
18
  containers: clone_containers(context.containers),
17
- objective: evaluate_trial_layout(context.containers, eval_context).objective
19
+ objective: root_eval.objective,
20
+ axle_excess_kg: root_eval.axle_excess_kg
18
21
  }];
19
22
  for (const loose of sorted) {
20
23
  beam = expand_beam({ reorder: context, evaluation: eval_context, beam, loose });
@@ -38,17 +41,12 @@ function expand_beam(request) {
38
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, expanded, state, loose } = beam_context;
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
- const trial = clone_containers(state.containers);
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;AAahG;;GAEG;AACH,qBAAa,cAAe,YAAW,eAAe;IAElD,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;CAgBtD"}
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.all_gates_pass ? evaluation.objective : Number.NEGATIVE_INFINITY;
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;AAyBhG;;GAEG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAE7D,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,mBAAmB,EAAE;CAqBtD"}
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: energy(context.containers, eval_context)
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.all_gates_pass) {
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 - energy(step_context.state.working, step_context.evaluation);
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 energy(containers, eval_context) {
60
- return -evaluate_trial_layout(containers, eval_context).objective;
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
+ }
@@ -12,5 +12,6 @@ export interface BeamExpansionContext {
12
12
  export interface BeamState {
13
13
  containers: StabilizerContainer[];
14
14
  objective: number;
15
+ axle_excess_kg: number;
15
16
  }
16
17
  //# sourceMappingURL=beam_context.d.ts.map
@@ -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;CACpB"}
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;AAepF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,EAAE,sBAAsB,GACrC,OAAO,CAiBT"}
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
- baseline_objective: current_eval.objective
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 (!trial_eval.all_gates_pass || trial_eval.objective <= move_context.baseline_objective) {
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