Ensure we select the least possible number of configurations

This commit is contained in:
Marco Castelluccio 2020-09-28 01:07:13 +02:00
Родитель f4a91cb012
Коммит 945e524a3c
2 изменённых файлов: 271 добавлений и 37 удалений

Просмотреть файл

@ -355,21 +355,19 @@ class TestSelectModel(Model):
sorted_tasks = sorted(tasks) sorted_tasks = sorted(tasks)
for i, task1 in enumerate(sorted_tasks): for i, task1 in enumerate(sorted_tasks):
create_group(task1)
try: try:
failing_together_stats = load_failing_together(task1) failing_together_stats = load_failing_together(task1)
except KeyError: except KeyError:
if not assume_redundant: failing_together_stats = {}
create_group(task1)
continue
else:
failing_together_stats = {}
for task2 in sorted_tasks[i + 1 :]: for task2 in sorted_tasks[i + 1 :]:
try: try:
support, confidence = failing_together_stats[task2] support, confidence = failing_together_stats[task2]
except KeyError: except KeyError:
if not assume_redundant: if not assume_redundant:
continue confidence = 0.0
else: else:
confidence = 1.0 confidence = 1.0
@ -378,10 +376,6 @@ class TestSelectModel(Model):
else: else:
mark_incompatible(task1, task2) mark_incompatible(task1, task2)
# Create group consisting only of task1, if there was nothing equivalent
# with it.
create_group(task1)
return groups return groups
def _get_equivalence_sets(self, min_redundancy_confidence: float): def _get_equivalence_sets(self, min_redundancy_confidence: float):
@ -447,7 +441,10 @@ class TestSelectModel(Model):
return True return True
def reduce( def reduce(
self, tasks: Collection[str], min_redundancy_confidence: float self,
tasks: Collection[str],
min_redundancy_confidence: float,
assume_redundant: bool = False,
) -> Set[str]: ) -> Set[str]:
failing_together = test_scheduling.get_failing_together_db( failing_together = test_scheduling.get_failing_together_db(
self.granularity, True self.granularity, True
@ -464,7 +461,7 @@ class TestSelectModel(Model):
task_vars = {task: solver.BoolVar(task) for task in tasks} task_vars = {task: solver.BoolVar(task) for task in tasks}
equivalence_sets = self._generate_equivalence_sets( equivalence_sets = self._generate_equivalence_sets(
tasks, min_redundancy_confidence, load_failing_together, False tasks, min_redundancy_confidence, load_failing_together, assume_redundant
) )
# Create constraints to ensure at least one task from each set of equivalent # Create constraints to ensure at least one task from each set of equivalent

Просмотреть файл

@ -206,7 +206,7 @@ def test_reduce5(failing_together: LMDBDict) -> None:
{"linux1804-64/opt-a", "windows10/opt-c", "windows10/opt-d"}, 1.0 {"linux1804-64/opt-a", "windows10/opt-c", "windows10/opt-d"}, 1.0
) )
assert result == { assert result == {
"linux1804-64/opt-a", "windows10/opt-d",
} }
@ -255,8 +255,32 @@ def test_reduce6(failing_together: LMDBDict) -> None:
) )
@pytest.mark.xfail
def test_reduce7(failing_together: LMDBDict) -> None: def test_reduce7(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-1"] = pickle.dumps(
{
"windows10/opt-3": (0.1, 0.0),
"windows10/opt-5": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-3"] = pickle.dumps(
{
"windows10/opt-5": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-1",
"windows10/opt-3",
"windows10/opt-5",
},
1.0,
)
assert result == {"windows10/opt-5"}
def test_reduce8(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-1"] = pickle.dumps( failing_together[b"windows10/opt-1"] = pickle.dumps(
{ {
"windows10/opt-5": (0.1, 1.0), "windows10/opt-5": (0.1, 1.0),
@ -292,38 +316,251 @@ def test_reduce7(failing_together: LMDBDict) -> None:
}, },
1.0, 1.0,
) )
assert ( assert result == {"windows10/opt-0", "windows10/opt-5", "windows10/opt-6"}
result
== {
def test_reduce9(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-0"] = pickle.dumps(
{
"windows10/opt-5": (0.1, 0.0),
}
)
failing_together[b"windows10/opt-1"] = pickle.dumps(
{
"windows10/opt-5": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-2"] = pickle.dumps(
{
"windows10/opt-6": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-3"] = pickle.dumps(
{
"windows10/opt-4": (0.1, 1.0),
"windows10/opt-5": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-4"] = pickle.dumps(
{
"windows10/opt-6": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-0", "windows10/opt-0",
"windows10/opt-1", "windows10/opt-1",
}
or result
== {
"windows10/opt-0",
"windows10/opt-2", "windows10/opt-2",
}
or result
== {
"windows10/opt-0",
"windows10/opt-3", "windows10/opt-3",
}
or result
== {
"windows10/opt-0",
"windows10/opt-4", "windows10/opt-4",
}
or result
== {
"windows10/opt-0",
"windows10/opt-5", "windows10/opt-5",
}
or result
== {
"windows10/opt-0",
"windows10/opt-6", "windows10/opt-6",
},
1.0,
)
assert result == {"windows10/opt-0", "windows10/opt-5", "windows10/opt-6"}
def test_reduce10(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-3"] = pickle.dumps(
{
"windows10/opt-5": (0.1, 1.0),
} }
) )
failing_together[b"windows10/opt-4"] = pickle.dumps(
{
"windows10/opt-6": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-5"] = pickle.dumps(
{
"windows10/opt-6": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-0",
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-3",
"windows10/opt-4",
"windows10/opt-5",
"windows10/opt-6",
},
1.0,
)
assert result == {
"windows10/opt-0",
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-3",
"windows10/opt-6",
} or result == {
"windows10/opt-0",
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-4",
"windows10/opt-5",
}
def test_reduce11(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-1"] = pickle.dumps(
{
"windows10/opt-2": (0.1, 0.0),
"windows10/opt-3": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-2"] = pickle.dumps(
{
"windows10/opt-3": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-3",
},
1.0,
)
assert result == {"windows10/opt-3"}
def test_reduce12(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-0"] = pickle.dumps(
{
"windows10/opt-1": (0.1, 0.0),
"windows10/opt-2": (0.1, 0.0),
"windows10/opt-3": (0.1, 0.0),
"windows10/opt-4": (0.1, 0.0),
"windows10/opt-5": (0.1, 0.0),
}
)
failing_together[b"windows10/opt-1"] = pickle.dumps(
{
"windows10/opt-2": (0.1, 0.0),
"windows10/opt-3": (0.1, 0.0),
"windows10/opt-4": (0.1, 0.0),
"windows10/opt-5": (0.1, 0.0),
}
)
failing_together[b"windows10/opt-2"] = pickle.dumps(
{
"windows10/opt-3": (0.1, 0.0),
"windows10/opt-4": (0.1, 1.0),
"windows10/opt-5": (0.1, 0.0),
}
)
failing_together[b"windows10/opt-3"] = pickle.dumps(
{
"windows10/opt-4": (0.1, 0.0),
"windows10/opt-5": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-4"] = pickle.dumps(
{
"windows10/opt-5": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-0",
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-3",
"windows10/opt-4",
"windows10/opt-5",
},
1.0,
)
assert result == {
"windows10/opt-0",
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-5",
} or result == {
"windows10/opt-0",
"windows10/opt-1",
"windows10/opt-3",
"windows10/opt-4",
}
def test_reduce13(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-2"] = pickle.dumps(
{
"windows10/opt-3": (0.1, 0.0),
"windows10/opt-4": (0.1, 1.0),
"windows10/opt-5": (0.1, 0.0),
}
)
failing_together[b"windows10/opt-3"] = pickle.dumps(
{
"windows10/opt-4": (0.1, 0.0),
"windows10/opt-5": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-2",
"windows10/opt-3",
"windows10/opt-4",
"windows10/opt-5",
},
1.0,
True,
)
assert result == {"windows10/opt-2", "windows10/opt-5"} or result == {
"windows10/opt-3",
"windows10/opt-4",
}
def test_reduce14(failing_together: LMDBDict) -> None:
failing_together[b"windows10/opt-1"] = pickle.dumps(
{
"windows10/opt-3": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-2"] = pickle.dumps(
{
"windows10/opt-4": (0.1, 1.0),
}
)
failing_together[b"windows10/opt-3"] = pickle.dumps(
{
"windows10/opt-4": (0.1, 1.0),
}
)
model = TestLabelSelectModel()
result = model.reduce(
{
"windows10/opt-1",
"windows10/opt-2",
"windows10/opt-3",
"windows10/opt-4",
},
1.0,
True,
)
assert (
result == {"windows10/opt-1"}
or result == {"windows10/opt-2"}
or result == {"windows10/opt-3"}
or result == {"windows10/opt-4"}
)
@st.composite @st.composite