From cdeeb0459758967ba0a7fa95b2265302f79259ef Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sat, 21 Sep 2024 15:39:32 +0200 Subject: [PATCH] Self-review --- TODO | 1 + src/alire/alire-solver.adb | 8 +++----- src/alire/alire-solver.ads | 5 +---- 3 files changed, 5 insertions(+), 9 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 000000000..4c336d1fa --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +- Test of solver timeout behaviors diff --git a/src/alire/alire-solver.adb b/src/alire/alire-solver.adb index b0970d6a9..ae9ae5860 100644 --- a/src/alire/alire-solver.adb +++ b/src/alire/alire-solver.adb @@ -678,9 +678,7 @@ package body Alire.Solver is -- Prefer states with fewer pending dependencies. This is simply to -- steer the search towards complete solutions first. - case Compare (L.Target.Leaf_Count + L.Remaining.Leaf_Count, - R.Target.Leaf_Count + R.Remaining.Leaf_Count) - is + case Compare (Pending_Count (L), Pending_Count (R)) is when Left => return True; when Right => return False; when Equal => null; @@ -951,7 +949,7 @@ package body Alire.Solver is raise Program_Error with "Search state lost!"; end if; - if This.Target.Is_Empty and then This.Remaining.Is_Empty then + if Pending_Count (This.all) = 0 then Store_Solution (State_Ptr'(This.all'Unchecked_Access)); end if; end Enqueue; @@ -1721,7 +1719,7 @@ package body Alire.Solver is declare Head : constant State_Ptr := States.First_Element; begin - if Head.Target.Is_Empty and then Head.Remaining.Is_Empty + if Pending_Count (Head.all) = 0 and then not Contains_All_Satisfiable (States.First_Element.To_Solution) then diff --git a/src/alire/alire-solver.ads b/src/alire/alire-solver.ads index 6b544cb7f..25b88ca69 100644 --- a/src/alire/alire-solver.ads +++ b/src/alire/alire-solver.ads @@ -113,10 +113,7 @@ package Alire.Solver is end record; Default_Options : constant Query_Options := (others => <>); - -- Default options is to keep looking without asking. This is potentially - -- more time consuming but it should be safe in the sense that no spurious - -- incomplete solutions should be returned. When interaction/early stop is - -- preferred, it must be tweaked (see child package Predefined_Options). + -- Default options is to ask on timeout -- See child package Predefined_Options for more.