forked from eli-b/mapf
/
CostTreeSearch.cs
77 lines (60 loc) · 2.8 KB
/
CostTreeSearch.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace CPF_experiment
{
class CostTreeSearch : Trevor
{
public static string PARENT_GROUP1_KEY = "parentGroup1";
public static string PARENT_GROUP2_KEY = "parentGroup2";
public CostTreeSearch()
: base(new CostTreeSearchSolver()){}
public CostTreeSearch(ISolver groupSolver)
: base(groupSolver){}
public override string GetName() { return "CostTreeSearch+ID "; }
/// <summary>
/// Join the conflicting groups into a single group
/// </summary>
/// <param name="conflict">An object that describes the conflict</param>
/// <returns>The composite group of agents</returns>
protected override AgentsGroup JoinGroups(Conflict conflict)
{
AgentsGroup answer = conflict.group1.Join(conflict.group2);
// TODO: Currently storing the previous groups - this might lead to a memory problem when there are many agents
// (if this happens then store only the costs)
answer.instance.parameters[PARENT_GROUP1_KEY] = conflict.group1;
answer.instance.parameters[PARENT_GROUP2_KEY] = conflict.group2;
// Free memory of grandparents
conflict.group1.instance.parameters.Remove(PARENT_GROUP1_KEY);
conflict.group1.instance.parameters.Remove(PARENT_GROUP2_KEY);
conflict.group2.instance.parameters.Remove(PARENT_GROUP1_KEY);
conflict.group2.instance.parameters.Remove(PARENT_GROUP2_KEY);
return answer;
}
}
class CostTreeSearchOldMatching : CostTreeSearch
{
int sycSize;
public CostTreeSearchOldMatching(int sycSize)
: base(new CostTreeSearchSolverOldMatching(sycSize)) { this.sycSize = sycSize; }
public override string GetName() { return "ICTS " + sycSize + "E+ID "; }
}
class CostTreeSearchNoPruning : CostTreeSearch
{
public CostTreeSearchNoPruning()
: base(new CostTreeSearchSolverNoPruning()){}
public override string GetName() { return "ICTS " + "+ID "; }
}
class CostTreeSearchKMatch : CostTreeSearch
{
int maxGroupChecked;
public CostTreeSearchKMatch(int maxGroupChecked)
: base(new CostTreeSearchSolverKMatch(maxGroupChecked)) { this.maxGroupChecked = maxGroupChecked; }
public override string GetName() { return "ICTS " + maxGroupChecked + "S+ID "; }
}
class CostTreeSearchRepatedMatch : CostTreeSearch
{
int sycSize;
public CostTreeSearchRepatedMatch(int sycSize)
: base(new CostTreeSearchSolverRepatedMatch(sycSize)) { this.sycSize = sycSize; }
public override string GetName() { return "ICTS " + sycSize + "RE+ID "; }
}
}