concretizer: only minimize builds when --reuse is enabled.

Make the first minimization conditional on whether `--reuse` is enabled in the solve.
If `--reuse` is not enabled, there will be nothing in the set to minimize and the
objective function (for this criterion) will be 0 for every answer set.
This commit is contained in:
Todd Gamblin 2021-08-08 21:36:44 -07:00
parent 40b914503e
commit 9eb94be6dd
2 changed files with 4 additions and 1 deletions

View file

@ -1570,6 +1570,8 @@ def setup(self, driver, specs, tests=False, reuse=False):
if reuse: if reuse:
self.gen.h1("Installed packages") self.gen.h1("Installed packages")
self.gen.fact(fn.optimize_for_reuse())
self.gen.newline()
self.define_installed_packages(possible) self.define_installed_packages(possible)
self.gen.h1('General Constraints') self.gen.h1('General Constraints')

View file

@ -794,7 +794,8 @@ build(Package) :- not hash(Package, _), node(Package).
% Try hard to reuse installed packages (i.e., minimize the number built) % Try hard to reuse installed packages (i.e., minimize the number built)
opt_criterion(16, "number of packages to build (vs. reuse)"). opt_criterion(16, "number of packages to build (vs. reuse)").
#minimize { 0@16: #true }. #minimize { 0@16: #true }.
#minimize { 1@16,Package : build(Package) }. #minimize { 1@16,Package : build(Package), optimize_for_reuse() }.
#defined optimize_for_reuse/0.
% Minimize the number of deprecated versions being used % Minimize the number of deprecated versions being used
opt_criterion(15, "deprecated versions used"). opt_criterion(15, "deprecated versions used").