Proper exhaustive solver

This commit is contained in:
Alejandro R Mosteo
2018-05-07 17:46:24 +02:00
parent 7e1a5c0c5b
commit bebbea1805
7 changed files with 80 additions and 37 deletions
+31 -26
View File
@@ -133,31 +133,36 @@ package Alire.Index.Alire is
(Operating_System = Windows and Operating_System /= GNU_Linux) or
(Compiler = GNAT_Unknown and Compiler /= GNAT_Unknown));
package Experimental is
function Project is new Catalogued_Project ("Experimental packages");
Base : constant Release := Project.Unreleased;
package V1 is new Released (Base);
package V2 is new Released (Base);
package V3 is new Released (Base);
package Greedy_Breaker is
function Project is new Catalogued_Project
("Dependency too complex for the greedy solver");
R : constant Release := Project.Register
(V ("1"),
No_Origin,
Dependencies =>
(V2.This_Version -- This causes V2 to be chosen greedily
or V3.This_Version) -- This will never be attempted
and V3.This_Version); -- And thus this will never be met
end Greedy_Breaker;
end Experimental;
-- package Experimental is
--
-- function Project is new Catalogued_Project ("Experimental packages");
--
-- Base : constant Release := Project.Unreleased;
--
-- package V1 is new Released (Base);
-- package V2 is new Released (Base);
-- package V3 is new Released (Base);
--
-- package Greedy_Breaker is
--
-- function Project is new Catalogued_Project
-- ("Dependency too complex for the greedy solver");
--
-- R1 : constant Release := Project.Register
-- (V ("1"),
-- No_Origin,
-- Dependencies =>
-- (V2.This_Version -- This causes V2 to be chosen greedily
-- or V3.This_Version) -- This will never be attempted
-- and V3.This_Version); -- And thus this will never be met
--
-- R2 : constant Release := Project.Register
-- (V ("2"),
-- No_Origin,
-- Dependencies =>
-- (V1.This_Version or V2.This_Version or V3.This_Version));
-- end Greedy_Breaker;
--
-- end Experimental;
end Alire.Index.Alire;
+10 -3
View File
@@ -2,9 +2,16 @@ with GNAT.IO;
package body Alire.Conditional_Values is
-------------
-- Flatten --
-------------
function All_But_First_Children (This : Conditional_Value) return Conditional_Value is
Children : Vectors.Vector := This.As_Vector;
begin
Children.Delete_First;
return To_Holder (Vector_Inner'(This.Conjunction, Children));
end All_But_First_Children;
-------------
-- Flatten --
-------------
procedure Flatten (Inner : in out Vector_Inner; -- The resulting vector
This : Inner_Node'Class; -- The next node to flatten
+18 -5
View File
@@ -83,6 +83,12 @@ package Alire.Conditional_Values with Preelaborate is
Visitor : access procedure (CV : Conditional_Value));
-- There is "of" notation too, but that bugs out when using this package as generic formal
type Children_Array is array (Positive range <>) of Conditional_Value;
function First_Child (This : Conditional_Value) return Conditional_Value;
function All_But_First_Children (This : Conditional_Value) return Conditional_Value;
--------------------
-- CONDITIONALS --
--------------------
@@ -174,7 +180,7 @@ private
end record;
function Conjunction (This : Vector_Inner) return Conjunctions is
(This.Conjunction);
(This.Conjunction);
package Non_Primitive is
function One_Liner_And is new Utils.Image_One_Line
@@ -193,9 +199,9 @@ private
end Non_Primitive;
overriding function Image (V : Vector_Inner) return String is
(if V.Conjunction = Anded
then Non_Primitive.One_Liner_And (V.Values)
else Non_Primitive.One_Liner_Or (V.Values));
("(" & (if V.Conjunction = Anded
then Non_Primitive.One_Liner_And (V.Values)
else Non_Primitive.One_Liner_Or (V.Values)) & ")");
type Conditional_Inner is new Inner_Node with record
Condition : Requisites.Tree;
@@ -238,7 +244,14 @@ private
-----------------
function Conjunction (This : Conditional_Value) return Conjunctions is
(Vector_Inner'Class (This.Element).Conjunction);
(Vector_Inner'Class (This.Element).Conjunction);
-----------------
-- First_Child --
-----------------
function First_Child (This : Conditional_Value) return Conditional_Value is
(To_Holder (This.As_Vector.First_Element));
---------------------
-- New_Conditional --
+3
View File
@@ -24,6 +24,9 @@ package body Alire.Containers is
end return;
end Inserting;
function Inserting (Dst : Release_Map; Src : Releases.Release) return Release_Map is
(Dst.Inserting (To_Map (Src)));
---------------
-- Excluding --
---------------
+2
View File
@@ -53,6 +53,8 @@ package Alire.Containers with Preelaborate is
function Inserting (Dst : Release_Map; Src : Release_Map) return Release_Map;
function Inserting (Dst : Release_Map; Src : Releases.release) return Release_Map;
function To_Dependencies (Map : Release_Map)
return Conditional.Dependencies;
+9 -3
View File
@@ -2,8 +2,7 @@ with Ada.Tags;
with Alire.Actions;
with Alire.Conditional;
-- with Alire.Dependencies;
-- with Alire.Dependencies.Vectors;
with Alire.Dependencies;
with Alire.Milestones;
with Alire.Origins;
with Alire.Properties;
@@ -134,6 +133,9 @@ package Alire.Releases with Preelaborate is
function Property_Contains (R : Release; Str : String) return Boolean;
-- True if some property contains the given string
function Satisfies (R : Release; Dep : Dependencies.Dependency) return Boolean;
-- Ascertain if this release is a valid candidate for Dep
private
use Semantic_Versioning;
@@ -213,6 +215,10 @@ private
else R.Origin.Commit (R.Origin.Commit'First .. R.Origin.Commit'First + 7))));
function On_Platform_Actions (R : Release; P : Properties.Vector) return Properties.Vector is
(R.On_Platform_Properties (P, Actions.Action'Tag));
(R.On_Platform_Properties (P, Actions.Action'Tag));
function Satisfies (R : Release; Dep : Dependencies.Dependency) return Boolean is
(R.Project = Dep.Project and then
Satisfies (R.Version, Dep.Versions));
end Alire.Releases;
+7
View File
@@ -3,6 +3,8 @@ with Alire.Dependencies;
-- with Alire.Dependencies.Vectors;
with Alire.Releases;
with Semantic_Versioning;
package Alire.Types with Preelaborate is
-- Recopilation of types for convenient use and documentation
@@ -20,6 +22,11 @@ package Alire.Types with Preelaborate is
function No_Dependencies return Conditional.Dependencies
renames Conditional.For_Dependencies.Empty;
function New_Dependency (Name : Alire.Project;
Versions : Semantic_Versioning.Version_Set)
return Platform_Dependencies
renames Conditional.New_Dependency;
subtype Release is Releases.Release;
-- A catalogued release