Skip to content

Commit

Permalink
fix: merge nodes more aggressively when unsat
Browse files Browse the repository at this point in the history
  • Loading branch information
aochagavia committed Jan 31, 2024
1 parent da56fa5 commit 1036424
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
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
|-- 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

0 comments on commit 1036424

Please sign in to comment.