Skip to content

Commit

Permalink
Merge branch 'Karp' of https://github.com/cda-tum/mqt-qao into Karp
Browse files Browse the repository at this point in the history
  • Loading branch information
petarpetrovv committed Nov 24, 2024
2 parents 579a428 + a7d56f8 commit dde6f1f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mqt/qao/karp/karp_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ def sat(

txt_outputname = "SAT: "


if isinstance(problem, Problem):
solution = solver_method(problem)
else:
raise TypeError("Expected `problem` to be of type `Problem`.")
msg = "Expected `problem` to be of type `Problem`."
raise TypeError(msg)

if solution is None or not hasattr(solution, "best_solution"):
msg = "Solver did not return a valid solution."
Expand Down Expand Up @@ -248,8 +248,9 @@ def three_sat(
clauses = [[str(item[0]), str(item[1])] for item in input_data]
filename = ""
else:
raise ValueError("Invalid input_data type. Expected str or list[tuple[int, int]].")

msg = "Invalid input_data type. Expected str or list[tuple[int, int]]."
raise ValueError(msg)

graph = KarpNumber._create_graph(clauses)

problem = KarpGraphs.independent_set(graph, solve=False)
Expand All @@ -268,7 +269,8 @@ def three_sat(
if isinstance(problem, Problem):
solution = solver_method(problem)
else:
raise TypeError("Expected `problem` to be of type `Problem`.")
msg = "Expected `problem` to be of type `Problem`."
raise TypeError(msg)

if solution is None or not hasattr(solution, "best_solution"):
msg = "Solver did not return a valid solution."
Expand Down Expand Up @@ -313,9 +315,7 @@ def three_sat(
return output_dict

@staticmethod
def check_three_sat_solution(
clauses: Any, solution: dict[str, float]
) -> dict[Any, Any]:
def check_three_sat_solution(clauses: Any, solution: dict[str, float]) -> dict[Any, Any]:
"""Validates a solution for the 3-SAT problem by checking clause satisfaction."""
not_satisfied_clauses = []

Expand Down

0 comments on commit dde6f1f

Please sign in to comment.