Skip to content

ASP-based solver: rework version facts#25585

Merged
tgamblin merged 1 commit intospack:developfrom
alalazo:bugfix/clingo_version_facts_from_zero
Aug 24, 2021
Merged

ASP-based solver: rework version facts#25585
tgamblin merged 1 commit intospack:developfrom
alalazo:bugfix/clingo_version_facts_from_zero

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Aug 24, 2021

This PR reworks version facts so that:

  1. All the information on versions is collected before emitting the facts
  2. The same kind of atom is emitted for versions stemming from different origins (package.py vs. packages.yaml)

In the end all the possible versions for a given package have a total order and they are given different and increasing weights starting from zero. This refactor allows us to avoid using negative weights, which in some configurations might make parent node score "better" and lead to unexpected "optimal" results.

The facts emitted for versions look like:

%----------------------------------------------------------------------------
% Package rules: zlib
%----------------------------------------------------------------------------
version_declared("zlib","1.2.13",0,"external").
version_declared("zlib","1.2.11",1,"external").
version_declared("zlib","1.2.5",2,"packages_yaml").
version_declared("zlib","1.2.6",3,"packages_yaml").
version_declared("zlib","1.2.0",4,"packages_yaml").
version_declared("zlib","1.2.11",5,"package_py").
version_declared("zlib","1.2.8",6,"package_py").
version_declared("zlib","1.2.3",7,"package_py").
...

for the following packages.yaml:

packages:
  zlib:
    version: ['1.2.5', '1.2.6', '1.2.0']
    externals:
    - spec: [email protected]
      prefix: /usr
    - spec: [email protected]
      prefix: /usr

This commit rework version facts so that:
1. All the information on versions is collected
   before emitting the facts
2. The same kind of atom is emitted for versions
   stemming from different origins (package.py
   vs. packages.yaml)

In the end all the possible versions for a given
package are totally ordered and they are given
different and increasing weights staring from zero.

This refactor allow us to avoid using negative
weights, which in some configurations may make
parent node score "better" and lead to unexpected
"optimal" results.
@alalazo alalazo added concretization bugfix Something wasn't working, here's a fix labels Aug 24, 2021
@alalazo alalazo marked this pull request as ready for review August 24, 2021 16:16
@alalazo alalazo requested review from becker33 and tgamblin August 24, 2021 16:16
1 { version(Package, Version): external_version_declared(Package, Version, _, _) } 1 :- external(Package).
1 { external_version(Package, Version, Weight):
version_declared(Package, Version, Weight, "external") } 1
:- external(Package).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This is much more consistent.

@tgamblin tgamblin merged commit 31dcdf7 into spack:develop Aug 24, 2021
@alalazo alalazo deleted the bugfix/clingo_version_facts_from_zero branch August 24, 2021 16:42
@alalazo alalazo mentioned this pull request Sep 14, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something wasn't working, here's a fix concretization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants