Skip to content

Commit

Permalink
M agpl-htn-tasks.adb
Browse files Browse the repository at this point in the history
M    agpl-htn-tasks.ads
M    agpl-gdk/agpl-gdk-drawer.adb
M    agpl-gdk/agpl-gdk-drawer.ads
M    agpl-optimization-annealing.adb
M    agpl-optimization-annealing.ads
M    agpl-optimization-annealing-solver.adb
M    agpl-optimization-annealing-solver.ads
M    agpl-cr-assignment.adb
M    agpl-cr-assignment.ads
A    agpl-optimization.adb
M    agpl-cr-cost_matrix.adb
M    agpl-optimization.ads
M    agpl-cr-cost_matrix.ads
M    agpl-htn-plan_node.ads
M    agpl-cr-mutable_assignment.adb
M    agpl-cr-mutable_assignment.ads
M    agpl-htn-plan.adb
  • Loading branch information
mosteo committed Sep 22, 2006
1 parent b1a9542 commit d32cff8
Show file tree
Hide file tree
Showing 18 changed files with 886 additions and 209 deletions.
5 changes: 3 additions & 2 deletions agpl-cr-assignment.adb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ package body Agpl.Cr.Assignment is

function Empty_Object return Object is
begin
return (Cr.Agent.Maps.Empty_Map, True);
return (Agents => Cr.Agent.Maps.Empty_Map,
Ok => True);
end Empty_Object;

-----------------
Expand Down Expand Up @@ -465,7 +466,7 @@ package body Agpl.Cr.Assignment is
------------------------

function Invalid_Assignment return Object is
This : Object;
This : Object := (others => <>);
begin
This.Ok := False;
return This;
Expand Down
4 changes: 2 additions & 2 deletions agpl-cr-assignment.ads
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ package Agpl.Cr.Assignment is
private

type Object is tagged record
Agents : Agent.Maps.Map;

Ok : Boolean := True;
-- An assignment can be invalid.

Agents : Agent.Maps.Map;
end record;

end Agpl.Cr.Assignment;
54 changes: 46 additions & 8 deletions agpl-cr-cost_matrix.adb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ package body Agpl.Cr.Cost_Matrix is
while A /= AL.No_Element loop
Ini := TL.First (Tasks);
while Ini /= TL.No_Element loop

Fin := TL.First (Tasks);
while Fin /= TL.No_Element loop

Expand Down Expand Up @@ -92,14 +93,37 @@ package body Agpl.Cr.Cost_Matrix is
Htn.Tasks.Get_Id (Tl.Element (Ini)),
Htn.Tasks.Get_Id (Tl.Element (Fin))));
end if;
else
-- Same task... may be should be Infinite, maybe zero?
pragma Ummmm;
null;
end if;

TL.Next (Fin);
end loop;

TL.Next (Ini);
end loop;
AL.Next (A);
end loop;

-- Add the No_Task specials
A := Agents.First;
while Al.Has_Element (A) loop
Ini := Tasks.First;
while Tl.Has_Element (Ini) loop

Set_Cost (This,
Cr.Agent.Get_Name (Al.Element (A)),
Htn.Tasks.Get_Id (Tl.Element (Ini)),
Htn.Tasks.No_Task,
0.0);

Tl.Next (Ini);
end loop;
Al.Next (A);
end loop;

end Create;

------------
Expand Down Expand Up @@ -258,6 +282,28 @@ package body Agpl.Cr.Cost_Matrix is
This.Matrix.Iterate (Do_It'Access);
end Print;

-----------------
-- Print_Diffs --
-----------------

procedure Print_Diffs (L, R : in Object) is
I : Cursor := L.Matrix.First;
begin
Log ("DIFFS IN COST MATRIX", Always);
while Has_Element (I) loop
if not R.Matrix.Contains (Key (I)) then
Log ("Missing key: " & Key (I), Always);
elsif Element (I) /= Element (R.Matrix.Find (Key (I))) then
Log (Key (I) & ":" & Element (I)'Img & " /= " &
Key (I) & ":" & Element (R.Matrix.Find (Key (I)))'Img,
Always);
end if;

Next (I);
end loop;
Log ("END DIFFS", Always);
end Print_Diffs;

--------------
-- Set_Cost --
--------------
Expand All @@ -269,14 +315,6 @@ package body Agpl.Cr.Cost_Matrix is
Fin : in Htn.Tasks.Task_Id;
Cost : in Costs)
is
function Rounded (C : in Costs) return Costs is
begin
if C /= Infinite then
return Costs (Float'Floor (Float (C * 100.0)) / 100.0);
else
return C;
end if;
end Rounded;
begin
Include (This.Matrix, Key (Agent, Ini, Fin), Cost);
end Set_Cost;
Expand Down
2 changes: 2 additions & 0 deletions agpl-cr-cost_matrix.ads
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ package Agpl.Cr.Cost_Matrix is
procedure Print (This : in Object);
-- Debug dump

procedure Print_Diffs (L, R : in Object);

private

package ATT_Maps is new Ada.Containers.Indefinite_Hashed_Maps
Expand Down

0 comments on commit d32cff8

Please sign in to comment.