import { RoutingGrid } from '../contracts/routing_grid.js'; import type { AStarRouter, IRoutePath } from './astar_router.js'; /** * Represents a Steiner point - an intermediate junction point that can reduce total trace length */ export interface ISteinerPoint { x: number; y: number; layer: string; /** Connection points this Steiner point serves */ connectedTerminals: number[]; /** Estimated savings if this point is used (mm) */ savings: number; } /** * Result of Steiner optimization */ export interface ISteinerOptimizationResult { /** Optimized path with Steiner points */ path: IRoutePath; /** Steiner points added */ steinerPoints: ISteinerPoint[]; /** Length reduction achieved (mm) */ lengthReduction: number; /** Percentage improvement */ improvement: number; /** Via count change (negative means fewer vias) */ viaReduction: number; } /** * Steiner Tree optimizer for PCB routing. * Optimizes multi-terminal nets by finding optimal junction points (Steiner points) * that minimize total trace length. */ export declare class SteinerOptimizer { private static readonly OPTIMIZATION_CONSTANTS; private grid; private clearance; private traceWidth; private net?; private router?; /** * Create a new Steiner optimizer * @param grid - Routing grid for pathfinding * @param clearance - Minimum clearance requirement * @param traceWidth - Trace width * @param net - Net name for obstacle checking * @param router - Optional router instance for re-routing segments */ constructor(grid: RoutingGrid, clearance: number, traceWidth: number, net?: string, router?: AStarRouter); private debugEnabled; /** * Optimize a routed path using Steiner tree algorithm * @param initialPath - Initial MST-based routing result * @param terminals - Original connection points (pins) * @param minImprovement - Minimum improvement threshold (default 5%) * @returns Optimization result with improved path or null if no improvement */ optimize(initialPath: IRoutePath, terminals: { x: number; y: number; layer: string; }[], minImprovement?: number): ISteinerOptimizationResult | null; /** * Generate candidate Steiner points by analyzing path intersections and geometric positions * @private */ private generateSteinerCandidates; /** * Calculate Fermat point (point minimizing sum of distances to three points) * Uses iterative Weiszfeld's algorithm * @private */ private calculateFermatPoint; /** * Find closest points between two path segments * @private */ private findClosestPointsBetweenSegments; /** * Check if a location is valid for placing a Steiner point (not blocked by obstacles) * @private */ private isValidSteinerLocation; /** * Remove duplicate Steiner points within tolerance * @private */ private removeDuplicatePoints; /** * Select the best Steiner points based on potential savings * @private */ private selectBestSteinerPoints; /** * Evaluate potential savings from using a Steiner point * Uses conservative estimation accounting for A* routing overhead * @private */ private evaluateSteinerPoint; /** * Calculate Euclidean distance between two points * @private */ private distance; /** * Build optimized routing tree using selected Steiner points. * Routes through each MST edge using the A* router to properly avoid obstacles. */ /** * Build optimized routing tree using selected Steiner points. * Routes through each MST edge using the A* router to properly avoid obstacles. */ private buildOptimizedTree; /** * Build MST for a set of nodes using Prim's algorithm * @private */ private buildMSTForNodes; } //# sourceMappingURL=steiner_optimizer.d.ts.map