2026-11-27 10:16:12 -08:00
|
|
|
"""Export the advanced example inputs from the canonical benchmark fixtures."""
|
|
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
from json import dumps
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-11-27 19:28:48 -08:00
|
|
|
from examples.advanced_layouts import COMPLEX_EXAMPLE, COMPLEX_EXAMPLE_POINTS, INPUTS, build_problem
|
2026-11-27 10:16:12 -08:00
|
|
|
from inire.tests.routing_corpus import CASE_GROUPS, profile_options
|
|
|
|
|
from inire.tests.stress_routing_benchmarks import STRESS_BENCHMARK_CASES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
|
parser = ArgumentParser(description=__doc__)
|
|
|
|
|
parser.add_argument("--output", type=Path, default=INPUTS)
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
2026-11-27 19:28:48 -08:00
|
|
|
cases = [(case.name, case) for case in STRESS_BENCHMARK_CASES]
|
|
|
|
|
for name in (COMPLEX_EXAMPLE, COMPLEX_EXAMPLE_POINTS):
|
|
|
|
|
(case,) = CASE_GROUPS[name]
|
|
|
|
|
cases.append((name, case))
|
2026-11-27 10:16:12 -08:00
|
|
|
entries = []
|
2026-11-27 19:28:48 -08:00
|
|
|
for name, case in cases:
|
2026-11-27 10:16:12 -08:00
|
|
|
problem = case.problem
|
|
|
|
|
options = profile_options(case, "public-defaults")
|
|
|
|
|
data = {
|
|
|
|
|
"bounds": list(problem.bounds),
|
|
|
|
|
"clearance": problem.clearance,
|
|
|
|
|
"bend_radii": list(options.search.bend_radii),
|
|
|
|
|
"sbend_radii": list(options.search.sbend_radii),
|
|
|
|
|
"infer_terminal_headings": options.topology.infer_terminal_headings,
|
|
|
|
|
"keepouts": [polygon.wkt for polygon in problem.static_obstacles],
|
|
|
|
|
"nets": [(net.net_id, net.start.as_tuple(), net.target.as_tuple(), net.width) for net in problem.nets],
|
|
|
|
|
}
|
|
|
|
|
rebuilt, settings = build_problem(data)
|
|
|
|
|
if problem != rebuilt or options != settings:
|
2026-11-27 19:28:48 -08:00
|
|
|
raise ValueError(f"The advanced example no longer reproduces fixture {name}")
|
2026-11-27 10:16:12 -08:00
|
|
|
|
|
|
|
|
# Keep ports and each net on one line so the input file is easy to scan.
|
2026-11-27 19:28:48 -08:00
|
|
|
lines = [f" {dumps(name)}: {{"]
|
2026-11-27 10:16:12 -08:00
|
|
|
for field in ("bounds", "clearance", "bend_radii", "sbend_radii", "infer_terminal_headings"):
|
|
|
|
|
lines.append(f" {dumps(field)}: {dumps(data[field])},")
|
|
|
|
|
for field in ("keepouts", "nets"):
|
|
|
|
|
values = ",\n".join(f" {dumps(value)}" for value in data[field])
|
|
|
|
|
comma = "," if field == "keepouts" else ""
|
|
|
|
|
lines.append(f" {dumps(field)}: [\n{values}\n ]{comma}")
|
|
|
|
|
entries.append("\n".join((*lines, " }")))
|
|
|
|
|
|
|
|
|
|
args.output.write_text("{\n" + ",\n".join(entries) + "\n}\n", encoding="utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|