-
Notifications
You must be signed in to change notification settings - Fork 0
/
hMax.cs
39 lines (37 loc) · 1.17 KB
/
hMax.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
using FlashPlanner.Core.Models;
using FlashPlanner.Core.Models.SAS;
using FlashPlanner.Core.RelaxedPlanningGraphs;
using FlashPlanner.Core.States;
namespace FlashPlanner.Core.Heuristics
{
/// <summary>
/// Retuns the max of actions needed to achive every goal fact
/// </summary>
public class hMax : BaseHeuristic
{
private readonly FactRPG _graphGenerator;
/// <summary>
/// Main constructor
/// </summary>
public hMax()
{
_graphGenerator = new FactRPG();
}
internal override uint GetValueInner(StateMove parent, SASStateSpace state, List<Operator> operators)
{
uint max = 0;
var dict = _graphGenerator.GenerateRelaxedGraph(state, operators);
foreach (var fact in state.Context.SAS.Goal)
{
if (!dict.ContainsKey(fact.ID))
return int.MaxValue;
var factCost = dict[fact.ID];
if (factCost == int.MaxValue)
return int.MaxValue;
if (factCost > max)
max = factCost;
}
return max;
}
}
}