1 20 package gov.nasa.jpf.jvm.choice; 21 22 import gov.nasa.jpf.Config; 23 import gov.nasa.jpf.jvm.DoubleChoiceGenerator; 24 import gov.nasa.jpf.jvm.JVM; 25 26 30 public class DoubleThresholdGenerator extends DoubleChoiceGenerator { 31 32 double low, threshold, high; 33 int state; 34 35 public DoubleThresholdGenerator (Config conf, String id) { 36 super(id); 37 38 low = conf.getDouble (id + ".low"); 39 threshold = conf.getDouble(id + ".threshold"); 40 high = conf.getDouble(id + ".high"); 41 state = -1; 42 } 43 44 public boolean hasMoreChoices (JVM vm) { 45 return (state < 2); 46 } 47 48 public double getNextChoice (JVM vm) { 49 switch (state) { 50 case -1: 51 case 0: return low; 52 case 1: return threshold; 53 default: return high; 54 } 55 } 56 57 public void advance (JVM vm) { 58 state++; 59 } 60 } 61 | Popular Tags |