First attempt at Markdown-ifying the text output

This commit is contained in:
Fabian Becker 2015-12-02 13:17:22 +01:00
parent 41280c8d01
commit c28401e19d
8 changed files with 51 additions and 32 deletions

View File

@ -251,7 +251,7 @@ final class CommandLineStatistics implements InterfaceStatistics {
} }
@Override @Override
public void printToTextListener(String s) { public void printToTextListener(String... s) {
System.out.println(s); System.out.println(s);
} }

View File

@ -233,7 +233,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
* the number of multiple runs has been reached. * the number of multiple runs has been reached.
*/ */
while (isOptimizationRunning() && (runCounter < statistics.getStatisticsParameters().getMultiRuns())) { while (isOptimizationRunning() && (runCounter < statistics.getStatisticsParameters().getMultiRuns())) {
LOGGER.info(String.format("Starting Optimization %d/%d", runCounter + 1, statistics.getStatisticsParameters().getMultiRuns())); LOGGER.info(String.format("Starting Optimization %d/%d", runCounter, statistics.getStatisticsParameters().getMultiRuns()));
statistics.startOptimizationPerformed(getInfoString(), runCounter, optimizationParameters, getInformerList()); statistics.startOptimizationPerformed(getInfoString(), runCounter, optimizationParameters, getInformerList());
problem.initializeProblem(); problem.initializeProblem();

View File

@ -99,7 +99,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
private List<InterfaceAdditionalPopulationInformer> lastInformerList = null; private List<InterfaceAdditionalPopulationInformer> lastInformerList = null;
private PopulationInterface lastSols = null; private PopulationInterface lastSols = null;
private String textFieldDelimiter = "\t"; private String textFieldDelimiter = " | ";
private int defaultFitCriterion = 0; // ToDo this might be a user chosen int - or even more elegantly, a MOSOConverter private int defaultFitCriterion = 0; // ToDo this might be a user chosen int - or even more elegantly, a MOSOConverter
protected StringSelection lastFieldSelection = null; // store the graph selection at the beginning of a multi-run protected StringSelection lastFieldSelection = null; // store the graph selection at the beginning of a multi-run
@ -238,6 +238,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
@Override @Override
public void startOptimizationPerformed(String infoString, int runNumber, InterfaceOptimizationParameters params, List<InterfaceAdditionalPopulationInformer> informerList) { public void startOptimizationPerformed(String infoString, int runNumber, InterfaceOptimizationParameters params, List<InterfaceAdditionalPopulationInformer> informerList) {
if (printRunIntroVerbosity()) {
printToTextListener("# Optimization");
}
if (runNumber == 0) { if (runNumber == 0) {
// store the initial graph selection state, so that modifications during runtime cannot cause inconsistencies // store the initial graph selection state, so that modifications during runtime cannot cause inconsistencies
@ -275,7 +278,27 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
feasibleFoundAfterSum = -1; feasibleFoundAfterSum = -1;
numOfRunsFeasibleFound = 0; numOfRunsFeasibleFound = 0;
if (params != null) {
if (printRunIntroVerbosity()) {
printToTextListener("\n### Optimization parameters \n```\n");
printToTextListener(BeanSerializer.serializeObject(params));
printToTextListener("\n```\n\n");
}
}
/*
ToDo: Figure out if we need this. Right now it is just spamming the text output
if (printRunIntroVerbosity()) {
printToTextListener("\nStatistics parameters: ");
printToTextListener(BeanInspector.niceToString(getStatisticsParameters()) + '\n');
}
*/
} }
if (printRunIntroVerbosity()) {
printToTextListener("## Multirun " + (runNumber + 1) + "\n");
}
feasibleFoundAfter = -1; feasibleFoundAfter = -1;
bestCurrentIndy = null; bestCurrentIndy = null;
bestOfRunIndy = null; bestOfRunIndy = null;
@ -284,22 +307,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
lastInformerList = null; lastInformerList = null;
lastSols = null; lastSols = null;
iterationCounter = 0; iterationCounter = 0;
if (printRunIntroVerbosity()) {
printToTextListener("\n****** Multirun " + runNumber);
}
if (params != null) {
if (printRunIntroVerbosity()) {
printToTextListener("\nOptimization parameters: \n");
printToTextListener(BeanSerializer.serializeObject(params));
}
}
/*
ToDo: Figure out if we need this. Right now it is just spamming the text output
if (printRunIntroVerbosity()) {
printToTextListener("\nStatistics parameters: ");
printToTextListener(BeanInspector.niceToString(getStatisticsParameters()) + '\n');
}
*/
functionCalls = 0; functionCalls = 0;
fireDataListenersStartStop(runNumber, true, true); fireDataListenersStartStop(runNumber, true, true);
} }
@ -387,9 +394,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
} }
if (printRunStoppedVerbosity()) { if (printRunStoppedVerbosity()) {
if (resultPop != null && (resultPop.size() > 0)) { if (resultPop != null && (resultPop.size() > 0)) {
printToTextListener("Resulting population: \n"); printToTextListener("### Resulting population \n");
for (int i = 0; i < resultPop.size(); i++) { for (int i = 0; i < resultPop.size(); i++) {
printToTextListener(AbstractEAIndividual.getDefaultStringRepresentation(resultPop.getEAIndividual(i))); printToTextListener(AbstractEAIndividual.getDefaultStringRepresentation(resultPop.getEAIndividual(i)) + " ");
printToTextListener("\n"); printToTextListener("\n");
} }
} }
@ -612,13 +619,14 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
@Override @Override
public void printToTextListener(String s) { public void printToTextListener(String... s) {
String text = StringTools.concatFields(s, "");
if ((resultOut != null)) { if ((resultOut != null)) {
resultOut.print(s); resultOut.print(text);
} }
for (InterfaceTextListener l : textListeners) { for (InterfaceTextListener l : textListeners) {
if (statisticsParameter.getOutputTo() != InterfaceStatisticsParameters.OutputTo.FILE) { if (statisticsParameter.getOutputTo() != InterfaceStatisticsParameters.OutputTo.FILE) {
l.print(s); l.print(text);
} }
} }
} }
@ -1068,7 +1076,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
if (iterationCounter == 0) { if (iterationCounter == 0) {
String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter); String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter);
if (printHeaderByVerbosity()) { if (printHeaderByVerbosity()) {
printToTextListener(headerLine + '\n'); printToTextListener("| " + headerLine + " | \n");
String[] tableSeparator = new String[currentStatHeader.length];
Arrays.fill(tableSeparator, "---");
printToTextListener("| " + StringTools.concatFields(tableSeparator, textFieldDelimiter) + " | \n");
} }
} }
@ -1076,7 +1087,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
Pair<String, Object[]> addData = getOutputData(informerList, lastSols); Pair<String, Object[]> addData = getOutputData(informerList, lastSols);
if (doTextOutput()) { // this is where the text output is actually written if (doTextOutput()) { // this is where the text output is actually written
if (printLineByVerbosity(iterationCounter)) { if (printLineByVerbosity(iterationCounter)) {
printToTextListener(addData.head() + '\n'); printToTextListener("| " + addData.head() + " | \n");
} }
} }
currentStatObjectData = addData.tail(); currentStatObjectData = addData.tail();

View File

@ -31,7 +31,7 @@ public interface InterfaceStatistics {
boolean removeTextListener(InterfaceTextListener listener); boolean removeTextListener(InterfaceTextListener listener);
void printToTextListener(String s); void printToTextListener(String... s);
void createNextGenerationPerformed(PopulationInterface Pop, InterfaceOptimizer opt, List<InterfaceAdditionalPopulationInformer> informerList); void createNextGenerationPerformed(PopulationInterface Pop, InterfaceOptimizer opt, List<InterfaceAdditionalPopulationInformer> informerList);

View File

@ -174,6 +174,14 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
arrayEditor.selectDeselectAll(); arrayEditor.selectDeselectAll();
} }
}; };
ActionListener cliButtonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
System.out.println("Generating CLI call");
}
};
ActionListener sal = new ActionListener() { ActionListener sal = new ActionListener() {
@Override @Override
@ -181,8 +189,11 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
jobList.saveSelectedJobs(arrayEditor); jobList.saveSelectedJobs(arrayEditor);
} }
}; };
arrayEditor.addUpperActionButton("Get CLI", cliButtonListener);
arrayEditor.addUpperActionButton("(De-)Sel. all", sl); arrayEditor.addUpperActionButton("(De-)Sel. all", sl);
arrayEditor.addUpperActionButton("Test Stats", al); arrayEditor.addUpperActionButton("Test Stats", al);
arrayEditor.addLowerActionButton("Save selected", sal); arrayEditor.addLowerActionButton("Save selected", sal);
arrayEditor.addPopupItem("Reuse as current settings", getReuseActionListener(parent, jobList)); arrayEditor.addPopupItem("Reuse as current settings", getReuseActionListener(parent, jobList));

View File

@ -74,7 +74,7 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
} }
@Override @Override
public void printToTextListener(String s) { public void printToTextListener(String... s) {
if (consoleOut) { if (consoleOut) {
System.out.println(s); System.out.println(s);
} }

View File

@ -153,7 +153,7 @@ public class MultirunRefiner {
*/ */
public void loadFile() { public void loadFile() {
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Select an Multirun.TXT File"); fc.setDialogTitle("Select a Multirun.TXT File");
fc.setFileFilter(new TXTFileFilter()); fc.setFileFilter(new TXTFileFilter());
int returnVal = fc.showDialog(this.mainFrame, "Load Multirun.TXT"); int returnVal = fc.showDialog(this.mainFrame, "Load Multirun.TXT");
if (returnVal == 0) { if (returnVal == 0) {

View File

@ -7,9 +7,6 @@ public class Tag implements java.io.Serializable {
protected int id; protected int id;
protected String text; protected String text;
public Tag() {
}
/** /**
* *
*/ */