WIP
This commit is contained in:
parent
dc40e121a3
commit
06d5abe895
@ -159,10 +159,6 @@ def build_criteria_names(
|
|||||||
costs: List[int], opt_criteria: List["AspFunction"], max_depth: int
|
costs: List[int], opt_criteria: List["AspFunction"], max_depth: int
|
||||||
) -> Dict[str, Union[int, List[int]]]:
|
) -> Dict[str, Union[int, List[int]]]:
|
||||||
"""Construct an ordered mapping from criteria names to costs."""
|
"""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
|
# ensure names of all criteria are unique
|
||||||
names = {criterion.args[0] for criterion in opt_criteria}
|
names = {criterion.args[0] for criterion in opt_criteria}
|
||||||
@ -776,7 +772,7 @@ def visit(node):
|
|||||||
cores = [] # unsatisfiable cores if they do not
|
cores = [] # unsatisfiable cores if they do not
|
||||||
|
|
||||||
def on_model(model):
|
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 = {
|
solve_kwargs = {
|
||||||
"assumptions": self.assumptions,
|
"assumptions": self.assumptions,
|
||||||
@ -797,7 +793,7 @@ def on_model(model):
|
|||||||
if result.satisfiable:
|
if result.satisfiable:
|
||||||
# get the best model
|
# get the best model
|
||||||
builder = SpecBuilder(specs, hash_lookup=setup.reusable_and_possible)
|
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
|
# first check for errors
|
||||||
error_args = [fn.args for fn in extract_functions(best_model, "error")]
|
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")
|
depths = extract_functions(best_model, "depth")
|
||||||
print(depths)
|
print(depths)
|
||||||
max_depth = max(d.args[1] for d in 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)
|
result.criteria = build_criteria_names(min_cost, criteria, max_depth)
|
||||||
|
|
||||||
# record the number of models the solver considered
|
# record the number of models the solver considered
|
||||||
|
@ -1118,7 +1118,7 @@ build_priority(Package, 0) :- attr("node", Package), not optimize_for_reuse().
|
|||||||
depth(Package, 0) :- attr("root", Package).
|
depth(Package, 0) :- attr("root", Package).
|
||||||
|
|
||||||
% other nodes' depth is the minimum depth of any dependent plus one.
|
% other nodes' depth is the minimum depth of any dependent plus one.
|
||||||
depth(Package, N+1) :-
|
min_parent_depth(Package, N) :-
|
||||||
N = #min{
|
N = #min{
|
||||||
D: depends_on(Dependent, Package),
|
D: depends_on(Dependent, Package),
|
||||||
depth(Dependent, D),
|
depth(Dependent, D),
|
||||||
@ -1126,9 +1126,21 @@ depth(Package, N+1) :-
|
|||||||
D < max_depth
|
D < max_depth
|
||||||
},
|
},
|
||||||
0 <= N,
|
0 <= N,
|
||||||
N <= max_depth,
|
N < max_depth,
|
||||||
attr("node", Package).
|
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
|
% Optimization to avoid errors
|
||||||
%-----------------------------------------------------------------
|
%-----------------------------------------------------------------
|
||||||
|
@ -23,6 +23,8 @@ class Clingo(CMakePackage):
|
|||||||
url = "https://github.com/potassco/clingo/archive/v5.2.2.tar.gz"
|
url = "https://github.com/potassco/clingo/archive/v5.2.2.tar.gz"
|
||||||
git = "https://github.com/potassco/clingo.git"
|
git = "https://github.com/potassco/clingo.git"
|
||||||
tags = ["windows"]
|
tags = ["windows"]
|
||||||
|
submodules = True
|
||||||
|
|
||||||
maintainers = ["tgamblin", "alalazo"]
|
maintainers = ["tgamblin", "alalazo"]
|
||||||
|
|
||||||
version("master", branch="master", submodules=True)
|
version("master", branch="master", submodules=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user