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 640fd49 + 36fec30 commit 8a21068
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/mqt/qao/karp/karp_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from collections import defaultdict
from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, Union
from typing import TYPE_CHECKING, Any, Literal

import matplotlib.pyplot as plt
import networkx as nx
Expand Down Expand Up @@ -136,7 +136,8 @@ def 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)

Expand Down Expand Up @@ -750,7 +751,7 @@ def number_partition(
@staticmethod
def check_number_partition_solution(
elements: list[int], set_variables: dict[str, float]
) -> dict[str, int | int | bool | list[int]] | dict[Any, Any]:
) -> dict[str, int | bool | list[int]] | dict[Any, Any]:
"""Validates a number partition solution by comparing subset sums."""
set_1 = []
set_2 = []
Expand All @@ -772,7 +773,7 @@ def check_number_partition_solution(
set_2.append(elements[index])
missing_elements.remove(elements[index])

result: dict[str, Union[int, bool, list[int]]] = {
result: dict[str, int | bool | list[int]] = {
"Sum 1": sum_1,
"Sum 2": sum_2,
}
Expand All @@ -794,15 +795,15 @@ def job_sequencing(
b: float = 1,
solve: bool = False,
solver_method: Callable[..., Any] | None = None,
read_solution : Literal["print", "file"] | None = None,
read_solution: Literal["print", "file"] | None = None,
solver_params: dict[str, Any] | None = None,
) -> Problem | list[list[int]]:
"""Initializes and optionally solves a job sequencing problem to minimize scheduling conflicts. Pattern check for files is not included."""
if any([solver_method is not None, read_solution is not None, solver_params is not None]) and not solve:
msg = "'solve' must be True if 'solver_method', 'read_solution', or 'solver_params' are provided."
raise ValueError(msg)

if isinstance(input_data , str):
if isinstance(input_data, str):
filename = input_data
try:
with Path(filename).open(encoding="utf-8") as file:
Expand Down

0 comments on commit 8a21068

Please sign in to comment.