spack/lib
Todd Gamblin 0d387678b7
concretizer: improve display of optimization criteria (#22433)
By default, clingo doesn't show any optimization criteria (maximized or
minimized sums) if the set they aggregate is empty. Per the clingo
mailing list, we can get around that by adding, e.g.:

```
 #minimize{ 0@2 : #true }.
```

for the 2nd criterion. This forces clingo to print out the criterion but
does not affect the optimization.

This PR adds directives as above for all of our optimization criteria, as
well as facts with descriptions of each criterion,like this:

```
opt_criterion(2, "number of non-default variants")
```

We use facts in `concretize.lp` rather than hard-coding these in `asp.py`
so that the names can be maintained in the same place as the other
optimization criteria.

The now-displayed weights and the names are used to display optimization
output like this:

```console
(spackle):solver> spack solve --show opt zlib
==> Best of 0 answers.
==> Optimization Criteria:
  Priority  Criterion                                            Value
  1         version weight                                           0
  2         number of non-default variants (roots)                   0
  3         multi-valued variants + preferred providers for roots    0
  4         number of non-default variants (non-roots)               0
  5         number of non-default providers (non-roots)              0
  6         count of non-root multi-valued variants                  0
  7         compiler matches + number of nodes                       1
  8         version badness                                          0
  9         non-preferred compilers                                  0
  10        target matches                                           0
  11        non-preferred targets                                    0

zlib@1.2.11%apple-clang@12.0.0+optimize+pic+shared arch=darwin-catalina-skylake
```

Note that this is all hidden behind a `--show opt` option to `spack
solve`. Optimization weights are no longer shown by default, but you can
at least inspect them and more easily understand what is going on.

- [x] always show optimization criteria in `clingo` output
- [x] add `opt_criterion()` facts for all optimizationc criteria
- [x] make display of opt criteria optional in `spack solve`
- [x] rework how optimization criteria are displayed, and add a `--show opt`
      optiong to `spack solve`
2021-04-02 08:54:49 +00:00
..
spack concretizer: improve display of optimization criteria (#22433) 2021-04-02 08:54:49 +00:00