mqt.qecc.cococo.hill_climber¶
Hill Climbing with random restarts for Routing Layouts.
Classes¶
Hill Climbing with random restarts for routing layouts. |
Functions¶
|
Safely saves data to a file. |
Module Contents¶
- class HillClimbing(max_restarts: int, max_iterations: int, circuit: list[tuple[int, int] | int], metric: str, t: int, custom_layout: list[list[mqt.qecc.cococo.types.pos] | networkx.Graph], use_dag: bool, valid_path: str, possible_factory_positions: list[mqt.qecc.cococo.types.pos] | None = None, num_factories: int | None = None, optimize_factories: bool = False, seed: int = 45)[source]¶
Hill Climbing with random restarts for routing layouts.
- evaluate_solution(layout: dict[int | str, tuple[int, int] | list[tuple[int, int]]]) int[source]¶
Evaluates the layout=solution according to self.metric.
- gen_random_qubit_assignment() dict[int | str, tuple[int, int] | list[tuple[int, int]]][source]¶
Yields a random qubit assignment given the data_qubit_locs.
- gen_neighborhood(layout: dict[int | str, tuple[int, int] | list[tuple[int, int]]]) list[dict[int | str, tuple[int, int] | list[tuple[int, int]]]][source]¶
Creates the Neighborhood of a given layout by going through each terminal pair and swapping their positions.
If there are no T gates, there will be l=len(terminal_pairs) elements in the neighborhood.
- single_hill_climbing(restart: int) tuple[int, dict[int | str, tuple[int, int] | list[tuple[int, int]]], int, HistoryTemp][source]¶
Helper method for parallel execution of hill climbing restarts.
- Parameters:
restart (int) – The restart index.
- Returns:
Tuple of (restart index, best solution, best score, history for this restart)
- run(prefix: str, suffix: str, parallel: bool, processes: int = 8) tuple[dict[int | str, tuple[int, int] | list[tuple[int, int]]], int, int, dict[int, HistoryTemp]][source]¶
Executes the Hill Climbing algorithm with random restarts.
- Parameters:
- Returns:
The best solution found. best_score: The score of the best solution.
- Return type:
best_solution