Minor addition to MatlabInterface (flag to deactivate output of all statistic fields which is time-consuming for large populations)
This commit is contained in:
parent
f7917e62c2
commit
510add738e
@ -58,6 +58,7 @@ int.optParams = [];
|
|||||||
int.optParamValues = [];
|
int.optParamValues = [];
|
||||||
int.hexMask=hex2dec('ffffffff');
|
int.hexMask=hex2dec('ffffffff');
|
||||||
int.dataType=''; % to be set later!
|
int.dataType=''; % to be set later!
|
||||||
|
int.outputAllStatsFields=1;
|
||||||
|
|
||||||
if (isa(fhandle, 'function_handle'))
|
if (isa(fhandle, 'function_handle'))
|
||||||
int.f = fhandle;
|
int.f = fhandle;
|
||||||
|
@ -77,6 +77,7 @@ if ((nargin == 2) || (nargin == 3))
|
|||||||
eva2.OptimizerFactory.addTerminator(EvaluationTerminator(maxEvals), 0);
|
eva2.OptimizerFactory.addTerminator(EvaluationTerminator(maxEvals), 0);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
int.mp.setOutputAllStatFields(int.outputAllStatsFields==1);
|
||||||
|
|
||||||
% set display
|
% set display
|
||||||
if (strcmp(int.opts.Display,'off') || isempty(int.opts.Display))
|
if (strcmp(int.opts.Display,'off') || isempty(int.opts.Display))
|
||||||
|
@ -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;
|
@ -177,12 +177,12 @@ public class MatlabEvalMediator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Object getQuestion() {
|
public Object getQuestion() {
|
||||||
logMP("-- Question: " + BeanInspector.toString(question) + "\n");
|
if (mp!=null) logMP("-- Question: " + BeanInspector.toString(question) + "\n");
|
||||||
return question;
|
return question;
|
||||||
}
|
}
|
||||||
|
|
||||||
double[] getAnswer() {
|
double[] getAnswer() {
|
||||||
logMP("-- mediator delivering " + BeanInspector.toString(answer) + "\n");
|
if (mp!=null) logMP("-- mediator delivering " + BeanInspector.toString(answer) + "\n");
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
|||||||
// private static String resOutFile = "matlabproblem-output.txt";
|
// private static String resOutFile = "matlabproblem-output.txt";
|
||||||
// transient PrintStream resOutStream = null;
|
// transient PrintStream resOutStream = null;
|
||||||
int verbosityLevel = 0;
|
int verbosityLevel = 0;
|
||||||
|
boolean outputAllStatsField = true;
|
||||||
private MatlabEvalMediator handler = null;
|
private MatlabEvalMediator handler = null;
|
||||||
// private boolean isDouble = true;
|
// private boolean isDouble = true;
|
||||||
private MatlabProblemDataTypeEnum dataType = MatlabProblemDataTypeEnum.typeDouble;
|
private MatlabProblemDataTypeEnum dataType = MatlabProblemDataTypeEnum.typeDouble;
|
||||||
@ -345,7 +346,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
|||||||
runnable.setVerbosityLevel(verbosityLevel);
|
runnable.setVerbosityLevel(verbosityLevel);
|
||||||
if (verbosityLevel>0) runnable.setOutputTo(2); // both file + window
|
if (verbosityLevel>0) runnable.setOutputTo(2); // both file + window
|
||||||
else runnable.setOutputTo(1); // only window
|
else runnable.setOutputTo(1); // only window
|
||||||
runnable.setOutputFullStatsToText(true);
|
runnable.setOutputFullStatsToText(outputAllStatsField);
|
||||||
|
|
||||||
// log("in MP optimize C\n");
|
// log("in MP optimize C\n");
|
||||||
if ((specParams != null) && (specParams.length > 0)) {
|
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) {
|
public void startPostProcess(InterfacePostProcessParams ppp) {
|
||||||
if (ppp.isDoPostProcessing()) {
|
if (ppp.isDoPostProcessing()) {
|
||||||
if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) {
|
if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) {
|
||||||
|
@ -1028,29 +1028,40 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
public synchronized void createNextGenerationPerformed(PopulationInterface
|
public synchronized void createNextGenerationPerformed(PopulationInterface
|
||||||
pop, InterfaceOptimizer opt, List<InterfaceAdditionalPopulationInformer> informerList) {
|
pop, InterfaceOptimizer opt, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||||
lastInformerList = informerList;
|
lastInformerList = informerList;
|
||||||
|
if (TRACE) printToTextListener(".. in createNextGenPerformed after " + pop.getFunctionCalls() + " evals.\n");
|
||||||
|
if (resultOut != null) resultOut.flush();
|
||||||
if (firstPlot) {
|
if (firstPlot) {
|
||||||
initPlots(pop, informerList);
|
initPlots(pop, informerList);
|
||||||
// if (doTextOutput()) printToTextListener(getOutputHeader(informer, pop)+'\n');
|
// if (doTextOutput()) printToTextListener(getOutputHeader(informer, pop)+'\n');
|
||||||
firstPlot = false;
|
firstPlot = false;
|
||||||
currentBestFeasibleFit=null;
|
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
|
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);
|
plotSpecificData(pop, informerList);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TRACE) printToTextListener("A2\n");
|
||||||
collectPopData(pop);
|
collectPopData(pop);
|
||||||
|
if (TRACE) printToTextListener("A3\n");
|
||||||
|
|
||||||
if (iterationCounter==0) {
|
if (iterationCounter==0) {
|
||||||
|
if (TRACE) printToTextListener("A3.1 " + currentStatHeader.length + "\n");
|
||||||
|
|
||||||
String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter);
|
String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter);
|
||||||
|
if (TRACE) printToTextListener("A3.2\n");
|
||||||
if (printHeaderByVerbosity()) printToTextListener(headerLine+'\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;
|
lastSols = (opt!=null) ? new Population(opt.getAllSolutions().getSolutions()) : pop;
|
||||||
// Pair<String,Double[]> addData = getOutputData(informerList, lastSols);
|
// Pair<String,Double[]> addData = getOutputData(informerList, lastSols);
|
||||||
// System.out.println("lastSols size: " + 500*PSymbolicRegression.getAvgIndySize(lastSols));
|
// System.out.println("lastSols size: " + 500*PSymbolicRegression.getAvgIndySize(lastSols));
|
||||||
// System.out.println("Mem use: " + getMemoryUse());
|
// System.out.println("Mem use: " + getMemoryUse());
|
||||||
|
if (TRACE) printToTextListener("A5\n");
|
||||||
|
|
||||||
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)) {
|
||||||
@ -1058,6 +1069,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
printToTextListener(addData.head()+'\n');
|
printToTextListener(addData.head()+'\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TRACE) printToTextListener("A6\n");
|
||||||
|
|
||||||
currentStatObjectData = addData.tail();
|
currentStatObjectData = addData.tail();
|
||||||
currentStatDoubleData = ToolBox.parseDoubles(currentStatObjectData);
|
currentStatDoubleData = ToolBox.parseDoubles(currentStatObjectData);
|
||||||
if (currentStatObjectData!=null) {
|
if (currentStatObjectData!=null) {
|
||||||
@ -1065,6 +1078,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
} else {
|
} else {
|
||||||
System.err.println("Warning in AbstractStatistics!");
|
System.err.println("Warning in AbstractStatistics!");
|
||||||
}
|
}
|
||||||
|
if (TRACE) printToTextListener("A7\n");
|
||||||
|
|
||||||
if (sumDataCollection != null) {
|
if (sumDataCollection != null) {
|
||||||
// Collect average data
|
// 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 (sumDataEntry != null) updateSum(sumDataEntry, currentStatDoubleData); // this adds up data of a single iteration across multiple runs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TRACE) printToTextListener("A8\n");
|
||||||
|
|
||||||
// if (doTextOutput()) {
|
// if (doTextOutput()) {
|
||||||
// Pair<String,Double[]> addInfo = getOutputLine(informerList, lastSols);
|
// Pair<String,Double[]> addInfo = getOutputLine(informerList, lastSols);
|
||||||
//
|
//
|
||||||
@ -1099,7 +1114,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
// }
|
// }
|
||||||
plotCurrentResults();
|
plotCurrentResults();
|
||||||
fireDataListeners();
|
fireDataListeners();
|
||||||
|
if (TRACE) printToTextListener(".. done createNextGenPerformed after " + pop.getFunctionCalls() + " evals.\n");
|
||||||
|
if (resultOut != null) resultOut.flush();
|
||||||
iterationCounter++;
|
iterationCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user