Skip to content

Commit

Permalink
M agpl-cr-cost_matrix.adb
Browse files Browse the repository at this point in the history
M    agpl-cr-cost_matrix.ads
M    agpl-cr-agent.adb
M    agpl-cr-agent.ads
M    bellman_ford.c
  • Loading branch information
mosteo committed Apr 29, 2007
1 parent cd6e96d commit ecd5406
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions agpl-cr-agent.adb
Expand Up @@ -275,6 +275,15 @@ package body Agpl.Cr.Agent is
This.Tasks := Tasks;
end Set_Tasks;

-----------------------
-- Remove_First_Task --
-----------------------

procedure Remove_First_Task (This : in out Object) is
begin
This.Remove_Task (This.Get_First_Task.Get_Id);
end Remove_First_Task;

-----------------
-- Remove_Task --
-----------------
Expand Down
2 changes: 2 additions & 0 deletions agpl-cr-agent.ads
Expand Up @@ -124,6 +124,8 @@ package Agpl.Cr.Agent is
-- procedure Mark_Start (This : in out Object);
-- Marks the execution is starting now, and caches the estimated cost.

procedure Remove_First_Task (This : in out Object);

procedure Remove_Task (This : in out Object; Id : in Htn.Tasks.Task_Id);
-- Remove this task from this agent TO DO list.

Expand Down
28 changes: 28 additions & 0 deletions agpl-cr-cost_matrix.adb
Expand Up @@ -9,6 +9,8 @@ package body Agpl.Cr.Cost_Matrix is

use type Cr.Costs;
use type Htn.Tasks.Task_Id;
package AC renames Agpl.Cr.Agent.Containers;
package TC renames Agpl.Htn.Tasks.Containers;

---------
-- Key --
Expand Down Expand Up @@ -197,6 +199,32 @@ package body Agpl.Cr.Cost_Matrix is
Create (This, Agents, Add_Starting_Tasks (Agents, Tasks));
end Create_With_Start;

-----------------------
-- Create_Only_Start --
-----------------------

procedure Create_Only_Start
(This : in out Object;
Agents : in Cr.Agent.Containers.Lists.List;
Tasks : in Htn.Tasks.Containers.Lists.List)
is
A : AC.Lists.Cursor := Agents.First;
T : TC.Lists.Cursor;
begin
while AC.Lists.Has_Element (A) loop
T := Tasks.First;
while TC.Lists.Has_Element (T) loop
Set_Cost (This,
Cr.Agent.Get_Name (AC.Lists.Element (A)),
Htn.Tasks.No_Task,
Htn.Tasks.Get_Id (TC.Lists.Element (T)),
AC.Lists.Element (A).Get_Cost (TC.Lists.Element (T)));
TC.Lists.Next (T);
end loop;
AC.Lists.Next (A);
end loop;
end Create_Only_Start;

--------------
-- Get_Cost --
--------------
Expand Down
6 changes: 6 additions & 0 deletions agpl-cr-cost_matrix.ads
Expand Up @@ -83,6 +83,12 @@ package Agpl.Cr.Cost_Matrix is
-- agent, which should be planned as the first task for each agent.
-- These tasks are obtained via @Add_Starting_Tasks@

procedure Create_Only_Start
(This : in out Object;
Agents : in Cr.Agent.Containers.Lists.List;
Tasks : in Htn.Tasks.Containers.Lists.List);
-- Only costs for initial tasks from each robot

procedure Merge (Dst : in out Object; Src : in Object);
-- Overwrite Dst costs that are also present in Src, add new ones in Src.

Expand Down
3 changes: 3 additions & 0 deletions bellman_ford.c
@@ -1,3 +1,6 @@
#include <stdio.h>
#include <math.h>

#define INFINITY ((int) pow(2, sizeof(int)*8-2)-1)

typedef struct
Expand Down

0 comments on commit ecd5406

Please sign in to comment.