Neural-guided optimization of deterministic schematic routing heuristics
A learned preference signal improves an auditable routing mechanism. Deterministic checks continue to control electrical and geometric validity.
Abstract
Readable schematic routing requires more than a shortest path. A route must preserve the circuit graph and communicate structure to an engineer. We use a neural preference model to optimize a deterministic heuristic scorer. The model identifies useful style signals and difficult negative examples. These signals inform penalty weights, blend control, and a hard-negative guard.
The final runtime system validates candidates before it scores them. It then applies the optimized heuristic with a small neural correction. The broad held-out test produced similar heuristic and neural results by design. The heuristic mean target was 0.694, and the neural mean target was 0.692. This agreement shows that the heuristic absorbed much of the learned preference signal.
schematic routing, heuristic optimization, neural ranking, deterministic validation, KiCad
1 Introduction
Schematic wiring is a constrained representation problem. A valid route connects the required anchors without changing unrelated electrical relationships. A readable route also avoids symbols, labels, visual backtracking, and unnecessary changes in direction.
These requirements have different failure costs. An unintended short changes circuit behavior, while a weak visual route increases review effort. A learned score must not trade electrical validity for aesthetic preference.
Our method separates hard constraints from preference optimization. Deterministic code validates connectivity and geometry. A neural model then supplies a development signal for improving the heuristic scorer.
The learned and heuristic results are therefore related. They are not independent systems that happened to reach similar performance. The heuristic was revised with information from the neural model and its error cases.
2 Problem formulation
Each routing task contains a schematic scene, a set of anchors, and an expected connectivity graph. The candidate generator returns a set of orthogonal polylines. Each candidate contains its geometry, required junctions, metrics, and validation state.
The validator partitions the candidate set into valid and invalid subsets. The scorer operates on the valid subset. This order prevents a high preference score from promoting an invalid route.
r* = arg max S(r), for r in VV is the set of candidates that pass deterministic validation.The research objective is not to replace the heuristic with a neural network. The objective is to use learned preference to improve a transparent scoring mechanism. The final mechanism must remain measurable, versioned, and easy to inspect.
3 Corpus and task construction
The corpus contains 120 public KiCad schematics. The collection process records the source revision and license for each schematic. All collected source files parsed successfully in the recorded corpus build.
The task extractor removes one human route and preserves the remaining schematic scene. It then verifies that the removed route restores the original connectivity graph. This process produced 342 safe reconstruction tasks.
The broader training slice used 240 tasks and 5,570 candidate records. Task-level splitting assigned 168 tasks to training. The validation and test splits each contained 36 tasks.
Task-level splitting prevents candidates from one route task from entering different splits. This rule reduces leakage from shared anchor positions and reference geometry. The final broad test contained 856 candidates.
3.1 Candidate generation
The generator creates several deterministic route families. These families include Manhattan paths, obstacle-aware grid search, same-net merges, and multi-anchor trunks. Each family varies bend positions and port exit directions.
Candidate diversity sets an upper bound on ranking quality. The ranker cannot select a useful route when the generator does not provide one. We therefore report valid candidate rate together with selection quality.
3.2 Validation
The validator inserts each candidate into a copy of the schematic. It rebuilds the connectivity graph and compares the new graph hash with the expected hash. It also checks anchor connectivity and unintended net changes.
Geometry checks detect symbol collisions, off-grid points, out-of-bounds points, and missing junction dots. A round-trip check writes the route into KiCad source and parses it again. Invalid candidates remain available for failure analysis.
4 Neural preference model
The preference model is a one-hidden-layer multi-layer perceptron. It receives 25 normalized route features and produces one scalar quality estimate. The broad model uses 18 hidden units and 487 trainable parameters.
length, bends, points, segments, directness, monotonicity, backtracking
crossings, near misses, symbol overlap, text overlap, label clearance
port direction, component side, parallel spacing, bus structure, local whitespace
segment overlap, shape agreement, length ratio, heuristic score
Invalid candidates receive a target of zero. Valid candidates receive a human-similarity target with explicit style penalties. These penalties cover backtracking, excess bends, weak style, and low reference agreement.
t(r) = 0, if r is invalidt(r) = similarity(r) - penalties(r), otherwiseTraining used 400 epochs, a learning rate of 0.006, and L2 regularization of 0.0001. The optimizer was Adam, and the loss was mean squared error. The fixed random seed was 1337.
The model served two purposes. It ranked valid alternatives during experiments, and it exposed where the heuristic disagreed with human route geometry. The second purpose drove the heuristic revisions.
5 Heuristic optimization
The initial style heuristic combined route length with penalties for bends, crossings, symbols, text, and reference disagreement. Neural ranking exposed repeated weaknesses in visual backtracking and route-shape agreement. These failures informed the next heuristic configuration.
The second configuration increased the reference penalty from 190 to 205. It increased the backtrack penalty from 28 to 36. It also introduced a 30 percent neural blend for combined ranking.
The third configuration reduced the neural blend to 10 percent. It retained the stronger deterministic penalties. It also added a 25 percent hard-negative weight for loops, backtracks, excess bends, and weak style.
This sequence transfers learned behavior into an explicit scoring mechanism. The neural model remains useful, but it no longer carries most of the ranking authority. The scorer exposes every penalty in the route report.
6 Runtime scoring
Runtime begins with deterministic validation. The system sorts candidates by validation state before it compares quality scores. A neural score cannot move an invalid candidate above a valid candidate.
The final score uses the optimized heuristic, a conservative neural correction, and the hard-negative penalty. The correction is small because the heuristic already includes learned style information.
S = 0.90 Sₕ + 0.10 Sₙ - 0.25 PₕSₕ is the optimized heuristic. Sₙ is the neural score. Pₕ is the hard-negative penalty.This design has two operational benefits. Most runtime behavior remains deterministic and auditable. The neural term can still correct small ordering errors among candidates with similar heuristic scores.
7 Evaluation protocol
Candidate-level loss measures prediction error, but it does not measure task-level selection. We therefore group test candidates by task and select the highest-scored candidate from each group.
Selected validity measures the fraction of tasks with a valid selected route. Mean target measures the reference quality of the selected route. The oracle selects the highest target available in each candidate pool.
The optimized heuristic is not an untouched baseline. It contains penalties and guards developed from the neural model. Similar performance therefore measures successful transfer, not an absence of neural value.
Similar performance is the expected result. The optimized heuristic encodes preferences that the neural model helped identify.
8 Results
8.1 Broad held-out test
The broad test contained 36 tasks and 856 candidates. Both scoring methods selected valid routes for 33 tasks. The selected-valid rate was 91.7 percent for both methods.
The optimized heuristic mean target was 0.694. The neural mean target was 0.692, and the oracle mean target was 0.695. All three values were within 0.003.
The neural model selected the oracle candidate on 91.7 percent of test tasks. The close heuristic value shows that the explicit scorer reproduced most of the useful preference ordering.
8.2 Style-focused test
The style-focused test contained 18 tasks. Both methods achieved 100 percent selected validity. The neural model reached the oracle mean target of 0.837.
The optimized heuristic reached 0.833 on the same test. The remaining target gap was 0.004. This result supports a small neural correction after heuristic optimization.
8.3 Corpus and full-sheet tests
The final corpus evaluation contained 120 tasks. Both selection paths achieved a 95 percent pass rate. The candidate pool had a 59 percent valid candidate rate.
Three full-sheet tests reconstructed 40, 102, and 214 original wires. Each generated sheet reproduced the expected connectivity graph hash. These tests also exposed geometric failures that graph equivalence alone cannot detect.
9 Discussion
The main result is methodological. A small neural model can improve a deterministic router without replacing its explicit scoring structure. This approach preserves a clear safety boundary and a useful audit trail.
Metric convergence is an intended outcome of the method. The heuristic uses features and penalties that the neural experiments helped refine. A large final gap would instead indicate incomplete transfer or an overly weak feature set.
The conservative neural blend handles residual preference differences. The hard-negative guard prevents the neural term from rewarding known structural defects. Deterministic validation remains the final authority on route acceptance.
10 Limitations
The benchmark measures reconstruction, not new circuit synthesis. Human reference routes provide useful targets, but they also encode the style of the collected schematics. New designs require independent engineer review.
Reference features are available during reconstruction research. A production route does not have a hidden human reference. Production evaluation must therefore mask reference-only features.
The task sets remain small for statistical inference. The current evaluation does not include confidence intervals or repeated split estimates. The reported differences are descriptive results.
Candidate generation is also a limiting factor. Some failed tasks had no candidate that passed all checks. Better candidate families can improve the system before a larger model becomes necessary.
11 Conclusion
Neural preference and deterministic heuristics serve different roles in this system. The model identifies useful ranking behavior. The heuristic converts that behavior into explicit penalties, guards, and measurable runtime decisions.
Similar neural and heuristic performance is evidence of this transfer. The final router keeps deterministic validation, an optimized heuristic core, and a small learned correction. This structure balances route quality with control and auditability.