public static void main(String[] args) { // Read out command line arguments processInputArguments(args); switch (mode) { case All: // Runs the given algorithms on all test sets in the given folder (recursively) TestRunner runner = new TestRunner(dataFilename, "output.txt", 10, toRun); runner.runTests(); break; case Single: // From the dataset file, read out the Graph object IGraph G = GraphReader.readGraphFromFile(dataFilename); // Run the algorithm if (algorithm == Algorithm.Optimal) runOptimal(G); else runAlgorithm(G); break; case Generate: // Generates "instanceCount" new datasets with "n" vertices with average degree "avgDegree" String resultDir = dataDirectory + "generated" + File.separator; ProblemInstanceGenerator.generateWeightedInstances( instanceCount, resultDir, n, avgDegree, minWeight, maxWeight); break; } System.out.println("Done!"); }
public static void main(String[] args) { // initialize student and class configuration data int studentNumber = 0; int runNumber = 1; String studentName = "blank"; String studentHandle = "000000"; String className = "242-1/"; String configFileName = "./configSingle.txt"; System.out.println("configFileName: " + configFileName); String path = "C:/java/jdk1.7.0_71/bin"; // set fixed paths and file names: String sourcePath = "./src/src-output"; String testDataPath = "./src"; String argsFileName = testDataPath + "/args.txt"; String testInputFileName = testDataPath + "/TestInput.txt"; /* make sure set correctly System.out.println("sourcePath: " + sourcePath); System.out.println("testDataPath: " + testDataPath); System.out.println("argsFileName: " + argsFileName); System.out.println("testInputFileName: " + testInputFileName); */ try { /* config file contains: - path to Java jdk (enclosed in quotes) on first line e.g. - "C:/Program Files/Java/jdk1.7.0_25/bin" - student name (lowercase lastnamefm) on second line e.g. - smithjq for John Q. Smith - random 6-digit handle on third line e.g. - 543890 - use the one given to you in class */ File configFile = new File(configFileName); Scanner in = new Scanner(configFile); String line = in.nextLine(); Scanner inLine = new Scanner(line); path = inLine.next(); line = in.nextLine(); inLine = new Scanner(line); studentName = inLine.next(); line = in.nextLine(); inLine = new Scanner(line); studentHandle = inLine.next(); // set paths and file names: String classPath = "/java/bin/" + className + studentName; String studentPath = sourcePath + "/" + studentName; String inputFileStub = studentPath + "/input"; String outputFileName = studentPath + "/output-" + studentName + ".txt"; System.out.println("classPath: " + classPath); System.out.println("studentPath: " + studentPath); System.out.println("inputFileStub: " + inputFileStub); System.out.println("outputFileName: " + outputFileName); System.out.println( "run #: " + runNumber + " ; studentNumber: " + studentNumber + "; Name: " + studentName + "; Handle: " + studentHandle); System.out.println("Output goes to: " + outputFileName); // run javac compiler - returns 0 on success // Compiler Constructor: // public Compiler(int numbr, String nme, String hndl, String pth, String clsPath, // String srcPath, String stdPath, String outFileName) Compiler c = new Compiler( runNumber, studentName, studentHandle, path, classPath, sourcePath, studentPath, outputFileName); int success = c.compileJava(); // Print whether or not compile successful if (success == 0) { System.out.println("Compiled Successfully"); } else { System.out.println("Compile Exception"); } // Run the test cases // TestRunner consructor: // public TestRunner(int numbr, String nme, String hndl, String pth, String clsPath, // String srcPath, String stdPath, String tstDataPath, String argFileName, // String tstInputFileName, String inputFileName, String outFileName) TestRunner r = new TestRunner( runNumber, studentName, studentHandle, path, classPath, sourcePath, studentPath, testDataPath, argsFileName, testInputFileName, inputFileStub, outputFileName); r.runJava(); runNumber++; System.out.println(); } catch (IOException ioe) { System.out.println("main IOException"); } }