--rollback: undo a rip-up that leaves fewer connections routed
The connections a rip-up route crosses are rerouted at once in free space. If that leaves fewer connections routed than before, the new route comes out and every displaced connection goes back on its old path, with its rip count as it was. Even trades are kept.
This commit is contained in:
+12
-2
@@ -30,8 +30,8 @@ from freeroute.ses import write_ses
|
||||
#: which optional flags each engine actually implements. Anything not listed for
|
||||
#: an engine is rejected by :func:`_validate` rather than quietly ignored.
|
||||
ENGINE_OPTIONS: dict[str, frozenset[str]] = {
|
||||
"grid": frozenset({"rip_up", "max_passes", "seed", "orders", "promote", "access"}),
|
||||
"exact": frozenset({"shove", "diagonal", "rip_up", "max_passes", "seed", "orders", "promote", "access"}),
|
||||
"grid": frozenset({"rip_up", "max_passes", "seed", "orders", "promote", "access", "rollback"}),
|
||||
"exact": frozenset({"shove", "diagonal", "rip_up", "max_passes", "seed", "orders", "promote", "access", "rollback"}),
|
||||
"room": frozenset({"shove", "pack"}),
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ _FLAG_NAMES = {
|
||||
"orders": "--orders",
|
||||
"promote": "--promote-failures",
|
||||
"access": "--access-cost",
|
||||
"rollback": "--rollback",
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +167,12 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
help="grid and exact engines: extra cost for a route to pass where it would close "
|
||||
"another pin's way out while that pin still has connections to route (default 0: off)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rollback",
|
||||
action="store_true",
|
||||
help="grid and exact engines: reroute the connections a rip-up displaces at once, "
|
||||
"and undo the rip-up if fewer connections end up routed",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--jobs",
|
||||
type=int,
|
||||
@@ -195,6 +202,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
("orders", args.orders is not None),
|
||||
("promote", args.promote_failures is not None),
|
||||
("access", args.access_cost is not None),
|
||||
("rollback", args.rollback),
|
||||
)
|
||||
if asked
|
||||
]
|
||||
@@ -229,6 +237,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
"resolution": 2 if args.grid_resolution is None else args.grid_resolution,
|
||||
"heuristic_weight": args.heuristic_weight,
|
||||
"access_cost": args.access_cost or 0.0,
|
||||
"rollback": args.rollback,
|
||||
}
|
||||
elif args.engine == "grid":
|
||||
options = {
|
||||
@@ -238,6 +247,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
"edge_clearance_mm": args.edge_clearance,
|
||||
"resolution": 1 if args.grid_resolution is None else args.grid_resolution,
|
||||
"access_cost": args.access_cost or 0.0,
|
||||
"rollback": args.rollback,
|
||||
}
|
||||
if args.engine == "room":
|
||||
result = build_rooms_routing_result(
|
||||
|
||||
Reference in New Issue
Block a user