Skip to content

Commit

Permalink
Add resultsPath field to GridSearchModel
Browse files Browse the repository at this point in the history
A new field, resultsPath, has been added to the GridSearchModel class, along with its setter and getter methods. This field represents the path to the result folder. This is set after a comparison has been run, and used to add additional contents like simulation, algorithm, table columns, and verbose output to the comparison results.
  • Loading branch information
jdramsey committed Jun 12, 2024
1 parent 7cda6c2 commit 9e1f267
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
import javax.swing.table.TableRowSorter;
import javax.swing.text.BadLocationException;
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
Expand Down Expand Up @@ -1425,6 +1422,41 @@ public void watch() {

try {
model.runComparison(ps);

String resultsPath = model.getResultsPath();

if (resultsPath != null && simulationChoiceTextArea != null) {
// Write contents of simulation text area to a file at resultsPath + "/simulation.txt"
try (PrintWriter writer = new PrintWriter(resultsPath + "/simulation.txt")) {
writer.println(simulationChoiceTextArea.getText());
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}

// Write contents of algorithm text area to a file at resultsPath + "/algorithm.txt"
try (PrintWriter writer = new PrintWriter(resultsPath + "/algorithm.txt")) {
writer.println(algorithmChoiceTextArea.getText());
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}

// Write contents of table columns text area to a file at resultsPath + "/tableColumns.txt"
try (PrintWriter writer = new PrintWriter(resultsPath + "/tableColumns.txt")) {
writer.println(tableColumnsChoiceTextArea.getText());
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}

// Write contents of verbose output text area to a file at resultsPath + "/verboseOutput.txt"
try (PrintWriter writer = new PrintWriter(resultsPath + "/verboseOutput.txt")) {
writer.println(verboseOutputTextArea.getText());
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}


}

} catch (Exception ex) {
throw new RuntimeException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public class GridSearchModel implements SessionModel {
* The name of the GridSearchModel.
*/
private String name = "Grid Search";
/**
* The variable resultsPath represents the path to the result folder. This is set after a comparison has been run
* and can be used to add additional files to the comparison results.
*/
private String resultsPath = null;

/**
* Constructs a new GridSearchModel with the specified parameters.
Expand Down Expand Up @@ -453,6 +458,9 @@ public void runComparison(java.io.PrintStream localOut) {
String outputFileName = "Comparison.txt";
comparison.compareFromSimulations(resultsPath, simulations, outputFileName, localOut,
algorithms, getSelectedStatistics(), new Parameters(parameters));

this.resultsPath = resultsPath;

}

private LinkedList<AlgorithmSpec> getSelectedAlgorithmSpecs() {
Expand Down Expand Up @@ -1090,6 +1098,18 @@ public DataSet getSuppliedData() {
return suppliedData;
}

public void setResultsPath(String resultsPath) {
this.resultsPath = resultsPath;
}

/**
* The variable resultsPath represents the path to the result folder. This is set after a comparison has been run
* and can be used to add additional files to the comparison results.
*/
public String getResultsPath() {
return resultsPath;
}

/**
* This class represents the comparison graph type for graph-based comparison algorithms. ComparisonGraphType is an
* enumeration type that represents different types of comparison graphs. The available types are DAG (Directed
Expand Down

0 comments on commit 9e1f267

Please sign in to comment.