1 package gov.nasa.jpf.search.heuristic; 20 21 import gov.nasa.jpf.Config; 22 import gov.nasa.jpf.VM; 23 24 import java.util.TreeSet ; 25 26 27 32 public class BeamSearch extends HeuristicSearch { 33 private TreeSet parents; 34 35 public BeamSearch (Config config, VM vm) throws Config.Exception { 36 super(config, vm); 37 } 38 39 public void search () { 40 int maxDepth = getMaxSearchDepth(); 41 42 int sid = getStateNumber(); 43 h_state = new HeuristicState(sid, initHeuristicValue); 44 heuristic.processParent(); 45 46 if (pathCoverage) { 47 h_state.saveCoverage(); 48 } 49 50 done = false; 51 52 if (hasPropertyTermination()) { 53 return; 54 } 55 56 generateChildren(maxDepth); 57 58 while ((queue.size() != 0) && !done) { 59 expandChildren(maxDepth); 60 } 61 } 62 63 private void expandChildren (int maxDepth) { 64 66 parents = (TreeSet ) (queue.clone()); 67 queue = new TreeSet (parents.comparator()); 69 while ((parents.size() != 0) && !done) { 70 expandState(); 71 generateChildren(maxDepth); 72 } 73 } 74 75 private void expandState () { 76 int s = parents.size(); 77 h_state = (HeuristicState) (parents.first()); 78 parents.remove(h_state); 79 vm.restoreState(h_state.getVirtualState()); 80 heuristic.processParent(); 81 } 82 } 83 | Popular Tags |