Skip to content
Snippets Groups Projects
Commit 65b0896d authored by s2010720's avatar s2010720
Browse files

Run all trees, BDD fields set to oome in case of OutOfMemoryError

parent 2f25d624
No related branches found
No related tags found
No related merge requests found
...@@ -14,22 +14,24 @@ import java.nio.file.Path; ...@@ -14,22 +14,24 @@ import java.nio.file.Path;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Stream; import java.util.stream.Stream;
public class Main { public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Stream<Path> treeFiles = Files.find(Path.of(args[0]), 5, (p, attr) -> attr.isRegularFile() && p.getFileName().toString().endsWith(".json")); Stream<Path> treeFiles = Files.find(Path.of(args[0]), 5, (p, attr) -> attr.isRegularFile() && p.getFileName().toString().endsWith(".json"));
Path csv = Path.of(args[0]).resolve("results.csv"); Path csv = Path.of(args[0]).resolve("results.csv");
BufferedWriter csvWriter = new BufferedWriter(new FileWriter(csv.toFile())); try (BufferedWriter csvWriter = new BufferedWriter(new FileWriter(csv.toFile()))) {
csvWriter.write("tree,heuristic,bdd_size,bdd_paths,ft_events,ft_basic_events"); csvWriter.write("tree,heuristic,bdd_size,bdd_paths,ft_events,ft_basic_events");
csvWriter.newLine(); csvWriter.newLine();
treeFiles treeFiles
.map(path -> { .map(path -> {
TreeWrapper tw = Parser.parseFile(path.toString()); TreeWrapper tw = Parser.parseFile(path.toString());
FaultTree ft = tw.getRoot(); FaultTree ft = tw.getRoot();
return new HashMap.SimpleEntry<Path, FaultTree>(path, ft); return new HashMap.SimpleEntry<Path, FaultTree>(path, ft);
}) })
.filter(e -> e.getValue().basicEventCount() < 50)
.flatMap(e -> evaluateTree(e.getValue(), e.getKey().toString()).entrySet().stream()) .flatMap(e -> evaluateTree(e.getValue(), e.getKey().toString()).entrySet().stream())
.forEach(res -> { .forEach(res -> {
try { try {
...@@ -37,11 +39,12 @@ public class Main { ...@@ -37,11 +39,12 @@ public class Main {
csvWriter.write(','); csvWriter.write(',');
csvWriter.write(res.getValue()); csvWriter.write(res.getValue());
csvWriter.newLine(); csvWriter.newLine();
csvWriter.flush();
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
}); });
csvWriter.close(); }
// CSVStore.storeCSV( // CSVStore.storeCSV(
// Path.of(args[0]).resolve("results.csv").toString(), // Path.of(args[0]).resolve("results.csv").toString(),
// List.of("tree,heuristic", "bdd_size", "bdd_paths", "ft_events", "ft_basic_events"), // List.of("tree,heuristic", "bdd_size", "bdd_paths", "ft_events", "ft_basic_events"),
...@@ -66,8 +69,14 @@ public class Main { ...@@ -66,8 +69,14 @@ public class Main {
} }
private static String evaluateTree(Heuristic heuristic, FaultTree ft) { private static String evaluateTree(Heuristic heuristic, FaultTree ft) {
String ftInfo = "," + ft.eventCount() + "," + ft.basicEventCount();
System.out.println(String.format("- Evaluating %s", heuristic.getName())); System.out.println(String.format("- Evaluating %s", heuristic.getName()));
ITE bdd = FaultTreeToITE.createITE(ft, heuristic.getOrder(ft)); try {
return bdd.size() + "," + bdd.paths() + "," + ft.eventCount() + "," + ft.basicEventCount(); ITE bdd = FaultTreeToITE.createITE(ft, heuristic.getOrder(ft));
return bdd.size() + "," + bdd.paths() + ftInfo;
} catch (OutOfMemoryError err) {
System.out.println(" -> Out of memory");
return "oome,oome" + ftInfo;
}
} }
} }
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment