Skip to content

Commit

Permalink
added outpaths option, to print the paths computed by TE algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanovis committed Jul 9, 2018
1 parent ed6f40e commit 45e889a
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 275 deletions.
12 changes: 12 additions & 0 deletions src/main/java/edu/repetita/io/RepetitaWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

public class RepetitaWriter {
private static String outputFilename = null;
private static String outpathsFilename = null;
private static int verbose = 0;

public static void setOutputFilename (String filename){
outputFilename = filename;
}

public static void setOutpathsFilename (String filename){
outpathsFilename = filename;
}

public static void setVerbose(int verboseLevel) {
verbose = verboseLevel;
}
Expand Down Expand Up @@ -60,6 +65,12 @@ private static void writeToFile (String content, FileOutputStream outFile){
}
}

public static void writeToPathFile (String paths) {
if (outpathsFilename != null) {
writeToFile(paths, outpathsFilename);
}
}

public static String formatAsListOneColumn(List<String> listOfStrings){
StringBuilder formatted = new StringBuilder();
for(String s: listOfStrings){
Expand Down Expand Up @@ -100,4 +111,5 @@ public static String formatAsDocumentation(String content) {
}
return commented.toString();
}

}
14 changes: 10 additions & 4 deletions src/main/java/edu/repetita/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ public class Main {
/* Private print methods */
private static String getUsage(){
return "Typical usage: repetita " +
"-graph topology_file -demands demands_filename -solver algorithm_id -scenario scenario_id " +
"-t max_execution_time\n";
"-graph topology_file -demands demands_filename -demandchanges list_demands_filename " +
"-solver algorithm_id -scenario scenario_id -t max_execution_time -outpaths path_filename " +
"-out output_filename -verbose debugging_level\n";
}

private static String getUsageOptions(){
ArrayList<String> options = new ArrayList<>();
ArrayList<String> descriptions = new ArrayList<>();

options.addAll(Arrays.asList("h","doc","graph","demands","demandchanges","solver",
"scenario","t","out","verbose"));
"scenario","t","outpaths","out","verbose"));

descriptions.addAll(Arrays.asList(
"only prints this help message",
Expand All @@ -43,7 +44,8 @@ private static String getUsageOptions(){
"identifier of the algorithm to run, to be chosen among " + storage.getSolverIDs().toString(),
"identifier of the scenario to simulate, to be chosen among " + storage.getScenarioIDs().toString(),
"maximum time in seconds allowed to the solver",
"name of the file collecting all the output (stdout by default)",
"name of the file collecting information of paths",
"name of the file collecting all the information (standard output by default)",
"level of debugging (default 0, only results reported)"
));

Expand Down Expand Up @@ -163,6 +165,10 @@ public static void main(String[] args) throws Exception {
timeLimit = Double.parseDouble(args[++i]);
break;

case "-outpaths":
RepetitaWriter.setOutpathsFilename(args[++i]);
break;

case "-out":
RepetitaWriter.setOutputFilename(args[++i]);
break;
Expand Down
Loading

0 comments on commit 45e889a

Please sign in to comment.