fix examples
This commit is contained in:
parent
bc218a416b
commit
e11132b51d
20 changed files with 406 additions and 101 deletions
|
|
@ -3,17 +3,12 @@ import time
|
|||
from shapely.geometry import box
|
||||
|
||||
from inire import (
|
||||
CongestionOptions,
|
||||
DiagnosticsOptions,
|
||||
NetSpec,
|
||||
ObjectiveWeights,
|
||||
Port,
|
||||
RoutingOptions,
|
||||
RoutingProblem,
|
||||
RoutingResult,
|
||||
SearchOptions,
|
||||
route,
|
||||
)
|
||||
from inire.router._stack import build_routing_stack
|
||||
from inire.utils.visualization import plot_expanded_nodes, plot_routing_results
|
||||
|
||||
|
||||
|
|
@ -45,12 +40,15 @@ def main() -> None:
|
|||
static_obstacles=tuple(obstacles),
|
||||
clearance=6.0,
|
||||
)
|
||||
from inire import CongestionOptions, DiagnosticsOptions, ObjectiveWeights, RoutingOptions, SearchOptions
|
||||
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(
|
||||
node_limit=2_000_000,
|
||||
bend_radii=(50.0,),
|
||||
sbend_radii=(50.0,),
|
||||
greedy_h_weight=1.5,
|
||||
bend_clip_margin=10.0,
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
unit_length_cost=0.1,
|
||||
|
|
@ -61,48 +59,59 @@ def main() -> None:
|
|||
max_iterations=15,
|
||||
base_penalty=100.0,
|
||||
multiplier=1.4,
|
||||
net_order="shortest",
|
||||
shuffle_nets=True,
|
||||
seed=42,
|
||||
),
|
||||
diagnostics=DiagnosticsOptions(capture_expanded=True),
|
||||
)
|
||||
stack = build_routing_stack(problem, options)
|
||||
evaluator = stack.evaluator
|
||||
finder = stack.finder
|
||||
metrics = finder.metrics
|
||||
|
||||
iteration_stats: list[dict[str, int]] = []
|
||||
|
||||
def iteration_callback(iteration: int, current_results: dict[str, RoutingResult]) -> None:
|
||||
successes = sum(1 for result in current_results.values() if result.is_valid)
|
||||
total_collisions = sum(result.collisions for result in current_results.values())
|
||||
total_nodes = metrics.nodes_expanded
|
||||
print(f" Iteration {iteration} finished. Successes: {successes}/{len(netlist)}, Collisions: {total_collisions}")
|
||||
new_greedy = max(1.1, 1.5 - ((iteration + 1) / 10.0) * 0.4)
|
||||
evaluator.greedy_h_weight = new_greedy
|
||||
print(f" Adaptive Greedy Weight for Next Iteration: {new_greedy:.3f}")
|
||||
iteration_stats.append(
|
||||
{
|
||||
"Iteration": iteration,
|
||||
"Success": successes,
|
||||
"Congestion": total_collisions,
|
||||
"Nodes": total_nodes,
|
||||
}
|
||||
)
|
||||
metrics.reset_per_route()
|
||||
|
||||
print(f"Routing {len(netlist)} nets through 200um bottleneck...")
|
||||
start_time = time.perf_counter()
|
||||
run = route(problem, options=options, iteration_callback=iteration_callback)
|
||||
results = finder.route_all(iteration_callback=iteration_callback)
|
||||
end_time = time.perf_counter()
|
||||
|
||||
print(f"Routing took {end_time - start_time:.4f}s")
|
||||
print("\n--- Iteration Summary ---")
|
||||
print(f"{'Iter':<5} | {'Success':<8} | {'Congest':<8}")
|
||||
print("-" * 30)
|
||||
print(f"{'Iter':<5} | {'Success':<8} | {'Congest':<8} | {'Nodes':<10}")
|
||||
print("-" * 43)
|
||||
for stats in iteration_stats:
|
||||
print(f"{stats['Iteration']:<5} | {stats['Success']:<8} | {stats['Congestion']:<8}")
|
||||
print(f"{stats['Iteration']:<5} | {stats['Success']:<8} | {stats['Congestion']:<8} | {stats['Nodes']:<10}")
|
||||
|
||||
success_count = sum(1 for result in run.results_by_net.values() if result.is_valid)
|
||||
success_count = sum(1 for result in results.values() if result.is_valid)
|
||||
print(f"\nFinal: Routed {success_count}/{len(netlist)} nets successfully.")
|
||||
for net_id, result in run.results_by_net.items():
|
||||
for net_id, result in results.items():
|
||||
if not result.is_valid:
|
||||
print(f" FAILED: {net_id}, collisions={result.collisions}")
|
||||
else:
|
||||
print(f" {net_id}: SUCCESS")
|
||||
|
||||
fig, ax = plot_routing_results(run.results_by_net, list(obstacles), bounds, netlist=netlist)
|
||||
plot_expanded_nodes(list(run.expanded_nodes), ax=ax)
|
||||
fig, ax = plot_routing_results(results, list(obstacles), bounds, netlist=netlist)
|
||||
plot_expanded_nodes(list(finder.accumulated_expanded_nodes), ax=ax)
|
||||
fig.savefig("examples/07_large_scale_routing.png")
|
||||
print("Saved plot to examples/07_large_scale_routing.png")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue