public CSV(Tournament t, Round r) { properties = TournamentProperties.getProperties(); separator = ";" + System.getProperty("line.separator"); logLocation = properties.getProperty("logLocation"); baseUrl = properties.getProperty("actionIndex.logUrl", "download?game=%d"); baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf("game")); if (t != null) { String name = "%stournament.%s.csv"; String levels = "%srounds.%s.csv"; names = new String[] { String.format(name, logLocation, t.getTournamentName().replaceAll(" ", "_")), String.format(name, logLocation, t.getTournamentId()), String.format(levels, logLocation, t.getTournamentName().replaceAll(" ", "_")), String.format(levels, logLocation, t.getTournamentId()) }; } else if (r != null) { String name = "%sround.%s.csv"; String games = "%sgames.%s.csv"; names = new String[] { String.format(name, logLocation, r.getRoundName().replaceAll(" ", "_")), String.format(name, logLocation, r.getRoundId()), String.format(games, logLocation, r.getRoundName().replaceAll(" ", "_")), String.format(games, logLocation, r.getRoundId()) }; } }
private void singleRound( BufferedWriter bw, String prefix, Round round, Map<Broker, double[]> resultMap) throws IOException { bw.write(prefix + "roundId;" + round.getRoundId() + separator); bw.write(prefix + "roundName;" + round.getRoundName() + separator); bw.write(prefix + "status;" + round.getState() + separator); bw.write(prefix + "StartTime;" + Utils.dateToStringFull(round.getStartTime()) + separator); bw.write(prefix + "Date from;" + Utils.dateToStringFull(round.getDateFrom()) + separator); bw.write(prefix + "Date to;" + Utils.dateToStringFull(round.getDateTo()) + separator); bw.write(prefix + "MaxBrokers;" + round.getMaxBrokers() + separator); bw.write(prefix + "Registered Brokers;" + round.getBrokerMap().size() + separator); // bw.write(prefix + "MaxAgents;" + round.getMaxAgents() + separator); bw.write(prefix + "size1;" + round.getSize1() + separator); bw.write(prefix + "multiplier1;" + round.getMultiplier1() + separator); bw.write(prefix + "size2;" + round.getSize2() + separator); bw.write(prefix + "multiplier2;" + round.getMultiplier2() + separator); bw.write(prefix + "size3;" + round.getSize3() + separator); bw.write(prefix + "multiplier3;" + round.getMultiplier3() + separator); bw.write(prefix + "pomId;" + round.getPomId() + separator); bw.write(prefix + "Locations;" + round.getLocations() + separator); double[] avgsAndSDs = round.getAvgsAndSDsArray(resultMap); if (resultMap == null || resultMap.size() == 0 || avgsAndSDs == null) { return; } bw.write(separator); bw.write(prefix + "Average type 1;" + avgsAndSDs[0] + separator); bw.write(prefix + "Average type 2;" + avgsAndSDs[1] + separator); bw.write(prefix + "Average type 3;" + avgsAndSDs[2] + separator); bw.write(prefix + "Standard deviation type 1;" + avgsAndSDs[3] + separator); bw.write(prefix + "Standard deviation type 2;" + avgsAndSDs[4] + separator); bw.write(prefix + "Standard deviation type 3;" + avgsAndSDs[5] + separator); bw.write(separator); bw.write( prefix + "brokerId;brokerName;Size 1;Size 2;Size 3;" + "Total (not normalized);Size 1;Size 2;Size3;Total (normalized)" + separator); for (Map.Entry<Broker, double[]> entry : resultMap.entrySet()) { double[] results = entry.getValue(); bw.write( String.format( "%s%s;%s;%f;%f;%f;%f;%f;%f;%f;%f%s", prefix, entry.getKey().getBrokerId(), entry.getKey().getBrokerName(), results[0], results[1], results[2], results[3], results[10], results[11], results[12], results[13], separator)); } }