Total Complexity | 8 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | package it.cnr.istc.pst.platinum.ai.deliberative.strategy; |
||
14 | public class GreedyDepthSearchStrategy extends SearchStrategy { |
||
15 | |||
16 | /** |
||
17 | * |
||
18 | */ |
||
19 | protected GreedyDepthSearchStrategy() { |
||
20 | super("GreedyDepthSearchStrategy"); |
||
21 | } |
||
22 | |||
23 | @PostConstruct |
||
24 | public void init() { |
||
|
|||
25 | |||
26 | } |
||
27 | |||
28 | /** |
||
29 | * |
||
30 | */ |
||
31 | @Override |
||
32 | public void enqueue(SearchSpaceNode node) |
||
33 | { |
||
34 | // compute heuristic cost |
||
35 | Map<DomainComponent, Double[]> h = this.computeHeuristicCost(node); |
||
36 | // set heuristic estimation |
||
37 | node.setHeuristicCost(h); |
||
38 | // add the node to the priority queue |
||
39 | this.fringe.offer(node); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * |
||
44 | */ |
||
45 | @Override |
||
46 | public int compare(SearchSpaceNode o1, SearchSpaceNode o2) |
||
47 | { |
||
48 | // compare heuristics and makespan of nodes and use depth as last selection criterion |
||
49 | return o1.getPlanHeuristicCost()[0] < o2.getPlanHeuristicCost()[0] ? -1 : o1.getPlanHeuristicCost()[0] > o2.getPlanHeuristicCost()[0] ? 1 : |
||
50 | o1.getDepth() > o2.getDepth() ? -1 : o1.getDepth() < o2.getDepth() ? 1 : 0; |
||
51 | |||
54 |