concretizer: unify handling of single- and multi-valued variants
Multi-valued variants previously maximized default values to handle cases where the default contained two values, e.g.: variant("foo", default="bar,baz") This is because previously we were minimizing non-default values, and `foo=bar`, `foo=baz`, and `foo=bar,baz` all had the same score, as none of them had any "non-default" values. This commit changes the approach and considers a non-default value to be either a value set to something not default *or* the absence of a default value from the set value. This allows multi- and single-valued variants to be handled the same way, with the same minimization criterion. It alse means that the "best" value for every optimization criterion is now zero, which allows us to make useful assumptions about the optimization criteria.
This commit is contained in:
parent
b88da9d73d
commit
b60a95cd5d
1 changed files with 5 additions and 18 deletions
|
@ -429,9 +429,11 @@ variant_value(Package, Variant, Value)
|
||||||
% whenever possible. If a variant is set in a spec, or if it is
|
% whenever possible. If a variant is set in a spec, or if it is
|
||||||
% specified in an external, we score it as if it was a default value.
|
% specified in an external, we score it as if it was a default value.
|
||||||
variant_not_default(Package, Variant, Value, 1)
|
variant_not_default(Package, Variant, Value, 1)
|
||||||
:- variant_value(Package, Variant, Value),
|
:- variant_value(Package, Variant, Actual),
|
||||||
not variant_default_value(Package, Variant, Value),
|
not variant_value(Package, Variant, Value),
|
||||||
not variant_set(Package, Variant, Value),
|
variant_default_value(Package, Variant, Value),
|
||||||
|
Actual != Value,
|
||||||
|
not variant_set(Package, Variant, Actual),
|
||||||
not external_with_variant_set(Package, Variant, Value),
|
not external_with_variant_set(Package, Variant, Value),
|
||||||
node(Package).
|
node(Package).
|
||||||
|
|
||||||
|
@ -937,21 +939,6 @@ opt_criterion(5, "version badness").
|
||||||
build_priority(Package, Priority)
|
build_priority(Package, Priority)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
% If the value is a multivalued variant there could be multiple
|
|
||||||
% values set as default. Since a default value has a weight of 0 we
|
|
||||||
% need to maximize their number below to ensure they're all set
|
|
||||||
opt_criterion(104, "(build) number of values in multi valued variants (non-root)").
|
|
||||||
opt_criterion(4, "number of values in multi valued variants (non-root)").
|
|
||||||
#minimize{ 0@104 : #true }.
|
|
||||||
#minimize{ 0@4 : #true }.
|
|
||||||
#maximize {
|
|
||||||
1@4+Priority,Package,Variant,Value
|
|
||||||
: variant_not_default(Package, Variant, Value, _),
|
|
||||||
not variant_single_value(Package, Variant),
|
|
||||||
not root(Package),
|
|
||||||
build_priority(Package, Priority)
|
|
||||||
}.
|
|
||||||
|
|
||||||
% Try to use preferred compilers
|
% Try to use preferred compilers
|
||||||
opt_criterion(103, "(build) non-preferred compilers").
|
opt_criterion(103, "(build) non-preferred compilers").
|
||||||
opt_criterion(3, "non-preferred compilers").
|
opt_criterion(3, "non-preferred compilers").
|
||||||
|
|
Loading…
Reference in a new issue