-
Notifications
You must be signed in to change notification settings - Fork 3
/
ISolver.cs
136 lines (119 loc) · 4.8 KB
/
ISolver.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System.Collections.Generic;
namespace mapf
{
public interface ISolver : IStatisticsCsvWriter
{
/// <summary>
/// Return the name of the solver, useful for outputing results.
/// </summary>
/// <returns>The name of the solver</returns>
string GetName();
/// <summary>
/// Solves the instance that was set by a call to Setup()
/// </summary>
/// <returns></returns>
bool Solve();
/// <summary>
/// Setup the relevant data structures for a run.
/// </summary>
/// <param name="problemInstance"></param>
/// <param name="runner"></param>
void Setup(ProblemInstance problemInstance, Run runner);
/// <summary>
/// Clears the relevant data structures and variables to free memory usage.
/// </summary>
void Clear();
/// <summary>
/// Returns the found plan, or null if no plan was found.
/// </summary>
/// <returns></returns>
Plan GetPlan();
/// <summary>
/// Returns the cost of the solution found, or error codes otherwise.
/// </summary>
int GetSolutionCost();
/// <summary>
/// Gets the delta of (actual solution cost - first state heuristics)
/// </summary>
int GetSolutionDepth();
long GetMemoryUsed();
// Not all algorithms have meaningful stats for expanded/generated, but many do
int GetExpanded();
int GetGenerated();
}
public interface IConflictReporting
{
/// <summary>
/// </summary>
/// <returns>Map each external agent to the number of conflicts with their path the solution has</returns>
Dictionary<int, int> GetExternalConflictCounts();
/// <summary>
/// </summary>
/// <returns>Map each external agent to a list of times the solution has a conflict with theirs</returns>
Dictionary<int, List<int>> GetConflictTimes();
}
public interface IIndependenceDetectionSolver : ISolver, IConflictReporting, IAccumulatingStatisticsCsvWriter
{
/// <summary>
/// For new groups
/// </summary>
/// <param name="problemInstance"></param>
/// <param name="runner"></param>
/// <param name="CAT"></param>
/// <param name="parentGroup1Cost"></param>
/// <param name="parentGroup2Cost"></param>
/// <param name="parentGroup1Size"></param>
void Setup(ProblemInstance problemInstance, Run runner, ConflictAvoidanceTable CAT,
int parentGroup1Cost, int parentGroup2Cost, int parentGroup1Size);
/// <summary>
/// For replanning groups to resolve a conflict
/// </summary>
/// <param name="problemInstance"></param>
/// <param name="runner"></param>
/// <param name="CAT"></param>
/// <param name="targetCost">/// </param>
/// <param name="illegalMoves"></param>
void Setup(ProblemInstance problemInstance, Run runner, ConflictAvoidanceTable CAT,
int targetCost, ISet<TimedMove> illegalMoves);
int[] GetSingleCosts();
int GetAccumulatedExpanded();
int GetAccumulatedGenerated();
}
public interface ICbsSolver : ISolver, IConflictReporting, IAccumulatingStatisticsCsvWriter
{
/// <summary>
///
/// </summary>
/// <param name="problemInstance"></param>
/// <param name="minTimeStep">Used mostly to force constraints to have an effect</param>
/// <param name="runner"></param>
/// <param name="CAT"></param>
/// <param name="constraints"></param>
/// <param name="positiveConstraints"></param>
/// <param name="minCost">
/// Goal nodes with a lower cost aren't considered a goal.
/// This can be used to speed up the search!
/// </param>
/// <param name="maxCost">If known, can speed up the search (no surplus nodes would be generated)</param>
/// <param name="mdd">Optional MDD of cost minCost=maxCost</param>
void Setup(ProblemInstance problemInstance, int minTimeStep, Run runner,
ConflictAvoidanceTable CAT, ISet<CbsConstraint> constraints, ISet<CbsConstraint> positiveConstraints,
int minCost, int maxCost, MDD mdd);
SinglePlan[] GetSinglePlans();
int[] GetSingleCosts();
int GetAccumulatedExpanded();
int GetAccumulatedGenerated();
}
public interface IMStarSolver : ICbsSolver
{
// Just does the appropriate thing when it's under M-Star
}
public interface IHeuristicSolver<in State>
{
/// <summary>
/// Get the heuristic
/// </summary>
/// <returns></returns>
IHeuristicCalculator<State> GetHeuristic();
}
}