Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merge nodes more aggressively when unsat #27

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ pub enum ConflictCause {
/// - They all have the same name
/// - They all have the same predecessor nodes
/// - They all have the same successor nodes
/// - None of them have incoming conflicting edges
pub(crate) struct MergedProblemNode {
pub ids: Vec<SolvableId>,
}
Expand Down Expand Up @@ -370,14 +369,6 @@ impl ProblemGraph {
}
};

if graph
.edges_directed(node_id, Direction::Incoming)
.any(|e| matches!(e.weight(), ProblemEdge::Conflict(..)))
{
// Nodes that are the target of a conflict should never be merged
continue;
}

let predecessors: Vec<_> = graph
.edges_directed(node_id, Direction::Incoming)
.map(|e| e.source())
Expand Down
10 changes: 10 additions & 0 deletions tests/snapshots/solver__merge_installable.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: tests/solver.rs
expression: "solve_snapshot(provider, &[\"a 0..3\", \"a 3..5\"])"
---
The following packages are incompatible
|-- a >=3, <5 can be installed with any of the following options:
|-- a 3 | 4
|-- a >=0, <3 cannot be installed because there are no viable options:
|-- a 1 | 2, which conflicts with the versions reported above.

13 changes: 1 addition & 12 deletions tests/snapshots/solver__unsat_constrains_2.snap
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
---
source: tests/solver.rs
assertion_line: 703
expression: error
---
The following packages are incompatible
|-- a * cannot be installed because there are no viable options:
|-- a 2 would require
|-- b *, which cannot be installed because there are no viable options:
|-- b 2 would require
|-- c >=2, <3, which cannot be installed because there are no viable options:
|-- c 2 would constrain
|-- a >=3, <4 , which conflicts with any installable versions previously reported
|-- b 1 would require
|-- c >=1, <2, which cannot be installed because there are no viable options:
|-- c 1 would constrain
|-- a >=3, <4 , which conflicts with any installable versions previously reported
|-- a 1 would require
|-- a 1 | 2 would require
baszalmstra marked this conversation as resolved.
Show resolved Hide resolved
|-- b *, which cannot be installed because there are no viable options:
|-- b 2 would require
|-- c >=2, <3, which cannot be installed because there are no viable options:
Expand Down
11 changes: 11 additions & 0 deletions tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,17 @@ fn test_merge_excluded() {
insta::assert_snapshot!(solve_snapshot(provider, &["a"]));
}

#[test]
fn test_merge_installable() {
let provider = BundleBoxProvider::from_packages(&[
("a", 1, vec![]),
("a", 2, vec![]),
("a", 3, vec![]),
("a", 4, vec![]),
]);
insta::assert_snapshot!(solve_snapshot(provider, &["a 0..3", "a 3..5"]));
}

#[test]
fn test_root_excluded() {
let mut provider = BundleBoxProvider::from_packages(&[("a", 1, vec![])]);
Expand Down