Passed
Push — master ( 00d193...bc2940 )
by Alessandro
08:14
created

init()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
package it.cnr.istc.pst.platinum.ai.deliberative.strategy;
2
3
import java.util.Map;
4
5
import it.cnr.istc.pst.platinum.ai.deliberative.solver.SearchSpaceNode;
6
import it.cnr.istc.pst.platinum.ai.framework.domain.component.DomainComponent;
7
import it.cnr.istc.pst.platinum.ai.framework.microkernel.annotation.lifecycle.PostConstruct;
8
9
/**
10
 * 
11
 * @author alessandro
12
 *
13
 */
14
public class GreedyDepthSearchStrategy extends SearchStrategy {
15
	
16
	/**
17
	 * 
18
	 */
19
	protected GreedyDepthSearchStrategy() {
20
		super("GreedyDepthSearchStrategy");
21
	}
22
	
23
	@PostConstruct
24
	public void init() {
0 ignored issues
show
Bug introduced by
An empty method may be confusing. Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.
Loading history...
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
			 
52
	}
53
}
54