This commit is contained in:
Todd Gamblin 2023-01-12 09:44:49 -08:00
parent dc40e121a3
commit 06d5abe895
No known key found for this signature in database
GPG Key ID: C16729F1AACF66C6
3 changed files with 25 additions and 8 deletions

View File

@ -159,10 +159,6 @@ def build_criteria_names(
costs: List[int], opt_criteria: List["AspFunction"], max_depth: int
) -> Dict[str, Union[int, List[int]]]:
"""Construct an ordered mapping from criteria names to costs."""
print(costs)
print(len(costs))
print(max_depth)
print(opt_criteria)
# ensure names of all criteria are unique
names = {criterion.args[0] for criterion in opt_criteria}
@ -776,7 +772,7 @@ def visit(node):
cores = [] # unsatisfiable cores if they do not
def on_model(model):
models.append((model.cost, model.symbols(shown=True, terms=True)))
models.append((model.cost, model.priority, model.symbols(shown=True, terms=True)))
solve_kwargs = {
"assumptions": self.assumptions,
@ -797,7 +793,7 @@ def on_model(model):
if result.satisfiable:
# get the best model
builder = SpecBuilder(specs, hash_lookup=setup.reusable_and_possible)
min_cost, best_model = min(models)
min_cost, priorities, best_model = min(models)
# first check for errors
error_args = [fn.args for fn in extract_functions(best_model, "error")]
@ -818,6 +814,13 @@ def on_model(model):
depths = extract_functions(best_model, "depth")
print(depths)
max_depth = max(d.args[1] for d in depths)
print(f"COST: {len(min_cost)} {min_cost}")
print(f"PRIO: {len(priorities)} {priorities}")
print(f"MAX_DEPTH: {max_depth}")
print()
print(opt_criteria)
result.criteria = build_criteria_names(min_cost, criteria, max_depth)
# record the number of models the solver considered

View File

@ -1118,7 +1118,7 @@ build_priority(Package, 0) :- attr("node", Package), not optimize_for_reuse().
depth(Package, 0) :- attr("root", Package).
% other nodes' depth is the minimum depth of any dependent plus one.
depth(Package, N+1) :-
min_parent_depth(Package, N) :-
N = #min{
D: depends_on(Dependent, Package),
depth(Dependent, D),
@ -1126,9 +1126,21 @@ depth(Package, N+1) :-
D < max_depth
},
0 <= N,
N <= max_depth,
N < max_depth,
attr("node", Package).
depth(Package, max_depth) :-
min_parent_depth(Package, P),
P >= max_depth,
attr("node", Package).
depth(Package, P+1) :-
min_parent_depth(Package, P),
P >= 0,
P < max_depth,
attr("node", Package).
%-----------------------------------------------------------------
% Optimization to avoid errors
%-----------------------------------------------------------------

View File

@ -23,6 +23,8 @@ class Clingo(CMakePackage):
url = "https://github.com/potassco/clingo/archive/v5.2.2.tar.gz"
git = "https://github.com/potassco/clingo.git"
tags = ["windows"]
submodules = True
maintainers = ["tgamblin", "alalazo"]
version("master", branch="master", submodules=True)