Commit c445c6d2 authored by Jonathan Shahen's avatar Jonathan Shahen
Browse files

Writes out some of the results from the tests that were run at the end of the test

parent 0238560b
......@@ -24,6 +24,7 @@ import vagabond.reduction.cnfsat.RunSolverCNFSAT;
import vagabond.reduction.ilp.*;
import vagabond.reduction.nomad.ReduceToNomad;
import vagabond.reduction.nomad.RunSolverNomad;
import vagabond.results.ResultsManager;
import vagabond.singleton.VagabondSettings;
import vagabond.testing.PlacementMapExamples;
import vagabond.timing.StatisticsManager;
......@@ -115,6 +116,11 @@ public class VagabondInstance {
+ epochHistory._sumOfInformationLeakage);
}
// Results Initial Placement
settings.results = new ResultsManager();
settings.results.initialPlacement = placementMap;
settings.results.initialCCIL = epochHistory.get(0);
// Reduce the PlacementMap
ReduceTo reduction = null;
RunSolver runSolver = null;
......@@ -138,6 +144,15 @@ public class VagabondInstance {
case REDUCTION_ILP:
reduction = new ReduceToILP();
runSolver = new RunSolverILP();
// TODO Remove me!
if (false) {
FileWriter fw = new FileWriter(settings.logFolder + "/ilpData.dat");
fw.write(WriteILPFile.toILPString(epochHistory));
fw.close();
throw new Exception("KILLING PROCESS! ILP wrote file out");
}
break;
case REDUCTION_NOMAD:
reduction = new ReduceToNomad();
......@@ -222,6 +237,10 @@ public class VagabondInstance {
/* Timing */timing.stopTimer("totalTime");
// Results Final Placement
settings.results.finalPlacement = epochHistory._latestPlacementMap;
settings.results.finalCCIL = epochHistory.get(0);
// Add a custom Stat event for the
timing.putRawTimeEvent("averageEpochTime", stats.getAvgEpochTimeEvent());
......@@ -229,6 +248,9 @@ public class VagabondInstance {
logger.info("Writing Timing Results to " + settings.getTimingFile().getAbsolutePath());
timing.writeOut(settings.getTimingFile(), true);
logger.info("Writing Results to " + settings.getResultsFile().getAbsolutePath());
settings.results.writeOut(settings.getResultsFile().getAbsolutePath());
} catch (Exception e) {
ErrorPrinter ep = new ErrorPrinter(e);
if (logger != null) {
......
......@@ -220,7 +220,7 @@ public class PlacementMap {
public String getFormatString(PlacementMapDisplayStyle displayStyle) {
StringBuilder sb = new StringBuilder();
if (displayStyle != PlacementMapDisplayStyle.CSV) {
if (displayStyle == PlacementMapDisplayStyle.CSV) {
sb.append(Machine.getCSVHeaderString()).append("\n");
}
......
package vagabond.results;
import java.io.FileWriter;
import java.io.IOException;
import vagabond.enums.PlacementMapDisplayStyle;
import vagabond.pieces.ClientToClientInformationLeakage;
import vagabond.pieces.PlacementMap;
import vagabond.singleton.VagabondSettings;
public class ResultsManager {
public static String separator = "\n\n###############################\n\n";
public PlacementMap initialPlacement = null;
public PlacementMap finalPlacement = null;
public ClientToClientInformationLeakage initialCCIL = null;
public ClientToClientInformationLeakage finalCCIL = null;
public boolean writeOut(String filePath) throws IOException {
boolean result = true;
VagabondSettings settings = VagabondSettings.getInstance();
FileWriter fw = new FileWriter(filePath);
fw.write("Settings:\n");
fw.write(settings.toString().replace(", ", "\n"));
fw.write(separator);
fw.write("Initial Placement:\n");
fw.write(initialPlacement.getFormatString(PlacementMapDisplayStyle.VAGABOND));
fw.write(separator);
fw.write("Initial Client-To-Client Information Leakage:\n");
fw.write(initialCCIL.getFormatString(PlacementMapDisplayStyle.VAGABOND, 0));
fw.write(separator);
fw.write("Final Placement:\n");
fw.write(finalPlacement.getFormatString(PlacementMapDisplayStyle.VAGABOND));
fw.write(separator);
fw.write("Final Client-To-Client Information Leakage:\n");
fw.write(finalCCIL.getFormatString(PlacementMapDisplayStyle.VAGABOND, 0));
fw.close();
return result;
}
}
......@@ -10,6 +10,7 @@ import vagabond.enums.PlacementMapDisplayStyle;
import vagabond.helper.ErrorPrinter;
import vagabond.logging.CSVFileFormatter;
import vagabond.logging.ConsoleFormatter;
import vagabond.results.ResultsManager;
import vagabond.testing.PlacementMapExamples;
import vagabond.timing.StatisticsManager;
import vagabond.timing.TimingManager;
......@@ -61,11 +62,6 @@ public class VagabondSettings {
*/
public Boolean displayPlacementMapEveryEpoch = true;
/**
* Filename of the results file (should be stored under the folder stored in {@link #logFolder}
*/
public String resultsFile = "vagabond.results.csv";
/**
* Stores the output filename of the PlacementMap if the PlacementMap needs to be printed out
* @see vagabond.pieces.PlacementMap
......@@ -85,6 +81,15 @@ public class VagabondSettings {
*/
public String timingFile = "vagabond.timing.csv";
/**
* The results manager that holds all of the raw results information for the instance.
*/
public ResultsManager results = new ResultsManager();
/**
* The file name of the results results file to write out; SHOULD be stored under the folder {@link #logFolder}.
*/
public String resultsFile = "vagabond.results.txt";
/**
* The statistics manager that calculates all of the stats that can be graphed later
*/
......@@ -308,6 +313,15 @@ public class VagabondSettings {
return new File(logFolder + File.separator + timingFile);
}
/**
* Function to return the file path of the results file. Used to write out the timing results.
* This should be considered a WRITE only file.
* @return File object to the results file; might not be created yet.
*/
public File getResultsFile() {
return new File(logFolder + File.separator + resultsFile);
}
/**
* Closes all of the open handles and removes all the locks from log files.
* If System.exit() needs to be called or the program exits normally,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment