Back to Blog
Solar StringingAutoCADAlgorithmAutomationReinforcement Learning

How Solar Stringing Automation Works

A technical look at the algorithms behind automated solar stringing — reinforcement learning, spatial reasoning, and where automation still needs an engineer.

Evan Haug
CEO, Leaf Automation
March 9, 2026

How Solar Stringing Automation Actually Works (And Where It Doesn't)

Most marketing copy about solar stringing automation says something like "advanced optimization algorithms" and leaves it there. That's not useful if you're an engineer trying to decide whether to trust a tool with your construction documents.

This post explains what's actually happening under the hood when Branch solves strings — the algorithms, the training, and the situations where automation still needs an engineer.

The Problem, Stated Precisely

String routing on a solar array is a spatial sequencing problem. Given a 2D grid of panels with gaps and obstacles, connect panels into strings of a fixed length while minimizing total wire distance. Prefer horizontal runs (natural snake paths through rows). Avoid long vertical jumps that waste cable. Don't strand isolated panels that can't form complete strings.

This is harder than it sounds. A 1,200-panel rooftop with skylights, HVAC, and irregular edges creates a combinatorial space that rule-based heuristics struggle with — they hit edge cases where rigid rules produce suboptimal or nonsensical routing.

How Branch's Solver Actually Works

Branch uses a reinforcement learning agent — specifically, a convolutional neural network trained with PPO (Proximal Policy Optimization) — to route strings through panel arrays.

Here's what that means in plain terms:

The agent sees a 2D grid. The panel layout is encoded as a multi-channel spatial grid — think of it like a small image with a few layers. One layer shows which panels are still available. Another shows which moves are valid right now. Another preserves the original layout as reference. The agent reads this grid the same way image recognition reads a photo — it understands spatial relationships between panels, not just a list of coordinates.

The agent picks one panel at a time. Each action is selecting the next panel to visit. The agent does this in two phases per string:

  1. Pick the starting panel — The agent selects where to begin a new string, ideally at an edge or corner where routing can proceed cleanly.
  2. Route the string — The agent connects panels in sequence, preferring horizontal snake paths through rows, until the string reaches the configured length.

Then it picks the next starting panel and repeats until every panel is covered.

The agent learned from thousands of layouts. We trained the model on synthetic panel arrays — varying sizes, shapes, obstacle patterns, and string lengths. The agent learned which routing strategies generalize well: start at edges, snake horizontally, minimize vertical jumps, don't split the remaining panels into disconnected islands that can't form complete strings.

It runs in seconds. Once trained, the model evaluates the grid and selects actions fast. The training took significant compute; inference is lightweight.

Why RL, Not Rule-Based Heuristics

We started with rule-based solvers. They work well for regular ground-mount arrays — predictable rows, uniform spacing, no surprises. But commercial rooftops are messy. Skylights punch holes in the middle of arrays. HVAC equipment creates irregular gaps. Parapets produce narrow panel strips at odd angles.

Rule-based heuristics need a decision tree for every edge case. Add one more obstacle pattern and you need more rules. The rule set grows, interactions between rules create bugs, and the solver becomes fragile.

The RL agent handles novel layouts because it learned spatial patterns, not explicit rules. It's seen thousands of irregular shapes during training and developed routing strategies that generalize. When it encounters a layout it hasn't seen before, it applies the same spatial reasoning — start at edges, route horizontally, avoid isolating panels.

That said, the RL agent isn't magic. It's trained to optimize for specific objectives (minimize wire distance, prefer horizontal paths, avoid panel isolation). On layouts that are far outside its training distribution, it can produce suboptimal routes. That's what the manual tools are for.

K-Means Inverter Placement

After strings are solved, inverters need to be placed. Branch uses K-means clustering for this:

  • Input: XY coordinates of all string endpoints.
  • Process: K-means groups endpoints into K clusters (K = number of inverters), places each inverter at the centroid of its cluster — the point that minimizes total cable distance to the strings it serves.
  • Output: Suggested inverter positions on the drawing.

This is a starting point, not a mandate. You can accept the positions or move inverters based on structural constraints, accessibility, or customer requirements. The HOMERUNS command then routes cables from string endpoints to inverters with clean 90-degree paths.

Panel Group Detection

Before the solver runs, Branch needs to know which panels belong together. PANELGROUPCREATE groups panels using three geometric criteria:

| Criterion | What It Checks | |-----------|---------------| | Rotation angle | Panels must face the same direction | | Proximity | Panels must be within the configured Max Panel Gap | | Alignment tolerance | Allows slight row misalignment from CAD precision or terrain |

Getting panel groups right is the most important setup step. Each group's header shows +N or -N recommendations based on your string length — use ADDPANELS to balance counts before solving.

Where Automated Stringing Breaks Down

Here's where Branch produces output that needs manual intervention:

Irregular panel counts. If a group has 50 panels and your string length is 12, you get four strings of 12 and one partial of 2. The solver warns you, but the fix is an engineering decision — add panels, remove panels, change string length, or route a jumper cable. Branch gives you the tools; you decide.

Heavily fragmented rooftop geometry. The RL agent handles irregular shapes well, but highly fragmented arrays — narrow strips, multiple acute angles, many small islands from dense HVAC — can produce routes that don't match how a human would intuitively string the area. The agent is optimizing its objective function correctly, but the result may not match your preferences.

Jumper cable decisions. When panels from one sub-array need to share strings with an adjacent group, that's an engineering call. Branch supports it through ADDPANELS, but the decision of which panels to transfer and where to place the jumper is yours.

Aesthetic preferences. Some engineers want specific routing patterns — always start from a particular corner, match an existing standard. The solver optimizes for cable length, not visual convention. MULTISTRING and SINGLESTRING let you route individual strings manually while keeping Branch's metadata and export infrastructure.

What This Means in Practice

On a typical 500kW commercial rooftop — 1,200 panels across 8-10 panel groups:

  • Panel group detection handles 90%+ of grouping correctly. You'll adjust 1-2 groups to balance counts.
  • String solving produces construction-document-ready output for most groups. Maybe one complex section needs a few manual strings.
  • Inverter placement gives a good starting point you'll nudge based on site constraints.
  • Homeruns route cleanly. Occasional HOMERUNADJUST to avoid an obstruction.

Total time including adjustments: roughly 3 minutes. The value of automation isn't that it's perfect — it's that the floor-to-ceiling workflow is fast enough that imperfect output costs almost nothing to fix.


Want to see how the solver handles your projects? Start a 14-day free trial — no credit card, no sales call.

Start Free Trial — 14 days free