summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2024-07-04 08:19:52 +0200
committerGitHub <noreply@github.com>2024-07-04 08:19:52 +0200
commitc5cdc2c0a2efc2ddf5b67abc6077b60173fd509a (patch)
tree993fa0cc9c06a8371eebe989ca84a10c0ecfa8de /lib
parent0eca86f64f936d7fa447daae1f76e31a3b46ea98 (diff)
downloadspack-c5cdc2c0a2efc2ddf5b67abc6077b60173fd509a.tar.gz
spack-c5cdc2c0a2efc2ddf5b67abc6077b60173fd509a.tar.bz2
spack-c5cdc2c0a2efc2ddf5b67abc6077b60173fd509a.tar.xz
spack-c5cdc2c0a2efc2ddf5b67abc6077b60173fd509a.zip
Heuristic decays to default over time (#45023)
This modifies heuristic to decay to clingo default over time. The hope is that this helps with specs that have an optimal solution with a high penalty. Let target and compiler heuristic decay too, do not guess compiler
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py2
-rw-r--r--lib/spack/spack/solver/heuristic.lp24
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 8512cdec8e..6d8520ec3f 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -95,7 +95,7 @@ def default_clingo_control():
control = clingo().Control()
control.configuration.configuration = "tweety"
control.configuration.solver.heuristic = "Domain"
- control.configuration.solver.opt_strategy = "usc,one,1"
+ control.configuration.solver.opt_strategy = "usc,one"
return control
diff --git a/lib/spack/spack/solver/heuristic.lp b/lib/spack/spack/solver/heuristic.lp
index 1f31d7eae0..a5d6767ff2 100644
--- a/lib/spack/spack/solver/heuristic.lp
+++ b/lib/spack/spack/solver/heuristic.lp
@@ -8,13 +8,17 @@
%=============================================================================
% No duplicates by default (most of them will be true)
-#heuristic attr("node", node(1..X-1, Package)) : max_dupes(Package, X), not virtual(Package), X > 1. [100, false]
-#heuristic attr("virtual_node", node(1..X-1, Package)) : max_dupes(Package, X), virtual(Package) , X > 1. [100, false]
+#heuristic attr("node", node(PackageID, Package)). [100, init]
+#heuristic attr("node", node(PackageID, Package)). [ 2, factor]
+#heuristic attr("virtual_node", node(VirtualID, Virtual)). [100, init]
+#heuristic attr("node", node(1..X-1, Package)) : max_dupes(Package, X), not virtual(Package), X > 1. [-1, sign]
+#heuristic attr("virtual_node", node(1..X-1, Package)) : max_dupes(Package, X), virtual(Package) , X > 1. [-1, sign]
% Pick preferred version
-#heuristic attr("version", node(PackageID, Package), Version) : pkg_fact(Package, version_declared(Version, 0 )), attr("node", node(PackageID, Package)). [40, true]
-#heuristic attr("version", node(PackageID, Package), Version) : pkg_fact(Package, version_declared(Version, Weight)), attr("node", node(PackageID, Package)), Weight > 0. [40+5*Weight, false]
-#heuristic version_weight(node(PackageID, Package), 0) : pkg_fact(Package, version_declared(Version, 0 )), attr("node", node(PackageID, Package)). [40, true]
+#heuristic attr("version", node(PackageID, Package), Version) : pkg_fact(Package, version_declared(Version, Weight)), attr("node", node(PackageID, Package)). [40, init]
+#heuristic version_weight(node(PackageID, Package), 0) : pkg_fact(Package, version_declared(Version, 0 )), attr("node", node(PackageID, Package)). [ 1, sign]
+#heuristic attr("version", node(PackageID, Package), Version) : pkg_fact(Package, version_declared(Version, 0 )), attr("node", node(PackageID, Package)). [ 1, sign]
+#heuristic attr("version", node(PackageID, Package), Version) : pkg_fact(Package, version_declared(Version, Weight)), attr("node", node(PackageID, Package)), Weight > 0. [-1, sign]
% Use default variants
#heuristic attr("variant_value", node(PackageID, Package), Variant, Value) : variant_default_value(Package, Variant, Value), attr("node", node(PackageID, Package)). [40, true]
@@ -25,10 +29,10 @@
#heuristic attr("node_platform", node(PackageID, Package), Platform) : allowed_platform(Platform), attr("root", node(PackageID, Package)). [40, true]
% Use default targets
-#heuristic attr("node_target", node(PackageID, Package), Target) : target_weight(Target, 0), attr("node", node(PackageID, Package)). [30, true]
-#heuristic attr("node_target", node(PackageID, Package), Target) : target_weight(Target, Weight), attr("node", node(PackageID, Package)), Weight > 0. [30, false]
-#heuristic node_target_weight(node(PackageID, Package), 0) : attr("node", node(PackageID, Package)). [30, true]
+#heuristic attr("node_target", node(PackageID, Package), Target) : target_weight(Target, Weight), attr("node", node(PackageID, Package)). [30, init]
+#heuristic attr("node_target", node(PackageID, Package), Target) : target_weight(Target, Weight), attr("node", node(PackageID, Package)). [ 2, factor]
+#heuristic attr("node_target", node(PackageID, Package), Target) : target_weight(Target, 0), attr("node", node(PackageID, Package)). [ 1, sign]
+#heuristic attr("node_target", node(PackageID, Package), Target) : target_weight(Target, Weight), attr("node", node(PackageID, Package)), Weight > 0. [-1, sign]
% Use the default compilers
-#heuristic node_compiler(node(0, Package), ID) : compiler_weight(ID, 0) , compiler_id(ID), attr("node", node(0, Package)). [30, true]
-#heuristic node_compiler(node(0, Package), ID) : compiler_weight(ID, Weight), compiler_id(ID), attr("node", node(0, Package)), Weight > 0. [30, false]
+#heuristic node_compiler(node(PackageID, Package), ID) : compiler_weight(ID, 0), compiler_id(ID), attr("node", node(PackageID, Package)). [30, init]