diff --git a/resources/MatlabInterface/@JEInterface/JEInterface.m b/resources/MatlabInterface/@JEInterface/JEInterface.m index bbd1da31..46f454e9 100644 --- a/resources/MatlabInterface/@JEInterface/JEInterface.m +++ b/resources/MatlabInterface/@JEInterface/JEInterface.m @@ -58,6 +58,7 @@ int.optParams = []; int.optParamValues = []; int.hexMask=hex2dec('ffffffff'); int.dataType=''; % to be set later! +int.outputAllStatsFields=1; if (isa(fhandle, 'function_handle')) int.f = fhandle; diff --git a/resources/MatlabInterface/@JEInterface/optimize.m b/resources/MatlabInterface/@JEInterface/optimize.m index 1346c4a8..eb176c33 100644 --- a/resources/MatlabInterface/@JEInterface/optimize.m +++ b/resources/MatlabInterface/@JEInterface/optimize.m @@ -77,6 +77,7 @@ if ((nargin == 2) || (nargin == 3)) eva2.OptimizerFactory.addTerminator(EvaluationTerminator(maxEvals), 0); end end + int.mp.setOutputAllStatFields(int.outputAllStatsFields==1); % set display if (strcmp(int.opts.Display,'off') || isempty(int.opts.Display)) diff --git a/resources/MatlabInterface/@JEInterface/setOutputAllStatsFields.m b/resources/MatlabInterface/@JEInterface/setOutputAllStatsFields.m new file mode 100644 index 00000000..49c9062f --- /dev/null +++ b/resources/MatlabInterface/@JEInterface/setOutputAllStatsFields.m @@ -0,0 +1,8 @@ +function int = setOutputAllStatsFields(int, doOutputAllFields) +% (De-)Activate printing all available statistic data to the text log. Deactivation may +% improve performance for larger population sizes. +% int = setOutputAllStatsFields(int, doOutputAllFields) +% int: instance of JEInterface +% doOutputAllFields: 1 or 0 for activation or deactivation, respectively + +int.outputAllStatsFields=doOutputAllFields; diff --git a/src/eva2/server/go/problems/MatlabEvalMediator.java b/src/eva2/server/go/problems/MatlabEvalMediator.java index 80861664..b505ff98 100644 --- a/src/eva2/server/go/problems/MatlabEvalMediator.java +++ b/src/eva2/server/go/problems/MatlabEvalMediator.java @@ -177,12 +177,12 @@ public class MatlabEvalMediator { * @return */ public Object getQuestion() { - logMP("-- Question: " + BeanInspector.toString(question) + "\n"); + if (mp!=null) logMP("-- Question: " + BeanInspector.toString(question) + "\n"); return question; } double[] getAnswer() { - logMP("-- mediator delivering " + BeanInspector.toString(answer) + "\n"); + if (mp!=null) logMP("-- mediator delivering " + BeanInspector.toString(answer) + "\n"); return answer; } diff --git a/src/eva2/server/go/problems/MatlabProblem.java b/src/eva2/server/go/problems/MatlabProblem.java index 921de2c9..57aa494f 100644 --- a/src/eva2/server/go/problems/MatlabProblem.java +++ b/src/eva2/server/go/problems/MatlabProblem.java @@ -51,6 +51,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf // private static String resOutFile = "matlabproblem-output.txt"; // transient PrintStream resOutStream = null; int verbosityLevel = 0; + boolean outputAllStatsField = true; private MatlabEvalMediator handler = null; // private boolean isDouble = true; private MatlabProblemDataTypeEnum dataType = MatlabProblemDataTypeEnum.typeDouble; @@ -345,7 +346,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf runnable.setVerbosityLevel(verbosityLevel); if (verbosityLevel>0) runnable.setOutputTo(2); // both file + window else runnable.setOutputTo(1); // only window - runnable.setOutputFullStatsToText(true); + runnable.setOutputFullStatsToText(outputAllStatsField); // log("in MP optimize C\n"); if ((specParams != null) && (specParams.length > 0)) { @@ -383,6 +384,10 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf } } + public void setOutputAllStatFields(boolean showAll) { + outputAllStatsField=showAll; + } + public void startPostProcess(InterfacePostProcessParams ppp) { if (ppp.isDoPostProcessing()) { if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) { diff --git a/src/eva2/server/stat/AbstractStatistics.java b/src/eva2/server/stat/AbstractStatistics.java index aaa1400d..3a5010f1 100644 --- a/src/eva2/server/stat/AbstractStatistics.java +++ b/src/eva2/server/stat/AbstractStatistics.java @@ -1028,29 +1028,40 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter public synchronized void createNextGenerationPerformed(PopulationInterface pop, InterfaceOptimizer opt, List informerList) { lastInformerList = informerList; + if (TRACE) printToTextListener(".. in createNextGenPerformed after " + pop.getFunctionCalls() + " evals.\n"); + if (resultOut != null) resultOut.flush(); if (firstPlot) { initPlots(pop, informerList); // if (doTextOutput()) printToTextListener(getOutputHeader(informer, pop)+'\n'); firstPlot = false; currentBestFeasibleFit=null; } - + if (TRACE) printToTextListener("A1\n"); if (pop.getSpecificData() != null) { // this is more or less deprecated. the standard population implementation will always return null. However the ES module wont plotSpecificData(pop, informerList); return; } + if (TRACE) printToTextListener("A2\n"); collectPopData(pop); + if (TRACE) printToTextListener("A3\n"); if (iterationCounter==0) { + if (TRACE) printToTextListener("A3.1 " + currentStatHeader.length + "\n"); + String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter); + if (TRACE) printToTextListener("A3.2\n"); if (printHeaderByVerbosity()) printToTextListener(headerLine+'\n'); + if (TRACE) printToTextListener("A3.3\n"); } - + if (TRACE) printToTextListener("A4\n"); + lastSols = (opt!=null) ? new Population(opt.getAllSolutions().getSolutions()) : pop; // Pair addData = getOutputData(informerList, lastSols); // System.out.println("lastSols size: " + 500*PSymbolicRegression.getAvgIndySize(lastSols)); // System.out.println("Mem use: " + getMemoryUse()); + if (TRACE) printToTextListener("A5\n"); + Pair addData = getOutputData(informerList, lastSols); if (doTextOutput()) { // this is where the text output is actually written if (printLineByVerbosity(iterationCounter)) { @@ -1058,6 +1069,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter printToTextListener(addData.head()+'\n'); } } + if (TRACE) printToTextListener("A6\n"); + currentStatObjectData = addData.tail(); currentStatDoubleData = ToolBox.parseDoubles(currentStatObjectData); if (currentStatObjectData!=null) { @@ -1065,6 +1078,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter } else { System.err.println("Warning in AbstractStatistics!"); } + if (TRACE) printToTextListener("A7\n"); if (sumDataCollection != null) { // Collect average data @@ -1085,7 +1099,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter if (sumDataEntry != null) updateSum(sumDataEntry, currentStatDoubleData); // this adds up data of a single iteration across multiple runs } } - + if (TRACE) printToTextListener("A8\n"); + // if (doTextOutput()) { // Pair addInfo = getOutputLine(informerList, lastSols); // @@ -1099,7 +1114,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter // } plotCurrentResults(); fireDataListeners(); - + if (TRACE) printToTextListener(".. done createNextGenPerformed after " + pop.getFunctionCalls() + " evals.\n"); + if (resultOut != null) resultOut.flush(); iterationCounter++; }