// BenchmarkParameters // a trivial "database" of the options set with the command line flags for // use by the Tree class and its derivatives. To add new flags, add a // private data field, an accessor function, a parse line in parse() and a // help line in showHelp(). public class BenchmarkParameters { // Generic Parameters -- (-1) indicates "unset". These are not the defaults! private final static int UNSETI = -1; private final static double UNSETD = -1.0; private int impltype = UNSETI; private int type = UNSETI; private int seed = UNSETI; private int gran = UNSETI; private int shape = UNSETI; private int depth = UNSETI; private int children = UNSETI; private double probability = UNSETD; private double branchfactor = UNSETD; private double transdepth = UNSETD; private int verbose = UNSETI; private int debug = UNSETI; private int stats = UNSETI; // implementation specific parameters added here // accessor functions public int implementationtype(int val) { return ( impltype==UNSETI)?val:impltype; }; public int treetype(int val) { return ( type==UNSETI)?val:type; }; public int rootseed(int val) { return ( seed==UNSETI)?val:seed; }; public int computegranularity(int val) { return ( gran==UNSETI)?val:gran; }; public int GEOshape(int val) { return ( shape==UNSETI)?val:shape; }; public int GEOdepth(int val) { return ( depth==UNSETI)?val:depth; }; public int BINnonleafnumchildren(int val) { return ( children==UNSETI)?val:children; }; public double BINnonleafprobability(double val) { return ( probability==UNSETD)?val:probability; }; public double branchingfactor(double val) { return (branchfactor==UNSETD)?val:branchfactor; }; public double HYBRIDtransitiondepth(double val) { return ( transdepth==UNSETD)?val:transdepth; }; public int verbosity(int val) { return ( verbose==UNSETI)?val:verbose; }; public int debuglevel(int val) { return ( debug==UNSETI)?val:debug; }; public int statlevel(int val) { return ( stats==UNSETI)?val:stats; }; // implementation specific accessor functions public void parse(String args[]){ // only store the numbers for later, Tree will decide if the // config is valid and will ignore garbage data appropriately. for(int i=0; i BIN transition (hybrid tree only)\n" + "-g int number of rng_spawns per node (aka compute granularity)\n" + "-v int nonzero to set verbose output\n" + "-x int debug level\n" + "\n" + "Additional Implementation Parameters:\n" + "-I int implementation type:\n" + " 0: sequential recursive search (default)\n" + "-S int statistics output level:\n" + " 0: none (default)\n" + " " ); // implementation specific help System.exit(0); }; public void show() { System.out.println("Command line arguments:"); System.out.println("======================="); if ( type > 0 ) System.out.println("TreeType = " + type); if ( seed > 0 ) System.out.println("Seed = " + seed); if ( gran > 0 ) System.out.println("Granularity = " + gran); if ( shape > 0 ) System.out.println("GEO:shape = " + shape); if ( depth > 0 ) System.out.println("GEO:depth = " + depth); if ( children > 0 ) System.out.println("BIN:nl#Children = " + children); if ( probability > 0.0 ) System.out.println("BIN:nlProb = " + probability); if ( branchfactor > 0.0 ) System.out.println("BranchingFactor = " + branchfactor); if ( transdepth > 0.0 ) System.out.println("HYBRID:transitionDepth = " + transdepth); if ( verbose > 0 ) System.out.println("Verbosity = " + verbose); if ( debug > 0 ) System.out.println("Debug = " + debug); if ( impltype > 0 ) System.out.println("Implementation Type = " + impltype); System.out.println(""); }; public static void main(String[] args) { BenchmarkParameters params = new BenchmarkParameters(); params.parse(args); params.show(); params.showHelp(); } }