public static void main(String[] args) throws IOException { long timeMillis = System.currentTimeMillis(); List<Point> pointList = parseToPoints(readFromFile("resources/data.tsp")); // List<Algorithm> algorithms = firstLab(); // List<Algorithm> algorithms = secondLab(); // List<Algorithm> algorithms = thirdLab(getTimeLimit(pointList)); List<Algorithm> algorithms = forthLab(getTimeLimit(pointList)); printResult(pointList, algorithms); System.out.println(System.currentTimeMillis() - timeMillis); }
private static void writeToFile(Algorithm a, RoundResult[] resultsToReport) { try { PrintWriter pw = new PrintWriter( "resources/results_" + a.getClass().getSimpleName() + "_" + new SimpleDateFormat("yyyyMMdd_kkmm") .format(new Date(System.currentTimeMillis()))); for (RoundResult r : resultsToReport) { pw.println(r.toString()); } pw.flush(); pw.close(); } catch (FileNotFoundException e) { System.err.println("File not found: " + e.getMessage()); for (RoundResult r : resultsToReport) { System.out.println(r.toString()); } } }