From 50dfec343f49026dbcae96f095593a747a094f55 Mon Sep 17 00:00:00 2001 From: Marcel Kronfeld Date: Tue, 3 Feb 2009 08:36:09 +0000 Subject: [PATCH] Minor JEInterface changes. --- .../MatlabInterface/@JEInterface/runEvalLoopJE.m | 9 ++++++--- src/eva2/server/go/problems/MatlabEvalMediator.java | 2 +- src/eva2/server/go/problems/MatlabProblem.java | 11 +++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/resources/MatlabInterface/@JEInterface/runEvalLoopJE.m b/resources/MatlabInterface/@JEInterface/runEvalLoopJE.m index d1cd82bf..753dc8f6 100644 --- a/resources/MatlabInterface/@JEInterface/runEvalLoopJE.m +++ b/resources/MatlabInterface/@JEInterface/runEvalLoopJE.m @@ -42,11 +42,14 @@ end if isempty(stopOptimization), % set switch to 0 now stopOptimization = 0; - + startTime=clock; + timeStr=sprintf('%d.%d. %d:%0.2d:%0.2d',startTime(3), startTime(2), startTime(4), startTime(5), round(startTime(6))); + disp(sprintf('Starting optimization at %s', timeStr)); % create a cancel button box (case without SBtoolbox) - boxHandle=figure('Position',[100 600 250 80], 'MenuBar', 'none', 'Name', 'EvA2 optimization running...', 'NumberTitle','off'); + stopText=sprintf('%s (%s)', stopText, timeStr); + boxHandle=figure('Position',[100 600 250 80], 'MenuBar', 'none', 'Name', 'EvA2 optimization...', 'NumberTitle','off'); uicontrol(boxHandle,'Style', 'pushbutton', 'String', 'Cancel', 'Position', [25 25 60 30], 'Callback', 'global stopOptimization; stopOptimization=1;'); - uicontrol(boxHandle,'Style', 'text', 'String', stopText, 'Position', [100 25 120 30]); + uicontrol(boxHandle,'Style', 'text', 'String', stopText, 'Position', [100 15 130 50]); drawnow; % set flag for non toolbox optimization nontoolboxopt = 1; diff --git a/src/eva2/server/go/problems/MatlabEvalMediator.java b/src/eva2/server/go/problems/MatlabEvalMediator.java index 5494150d..62c87a90 100644 --- a/src/eva2/server/go/problems/MatlabEvalMediator.java +++ b/src/eva2/server/go/problems/MatlabEvalMediator.java @@ -33,7 +33,7 @@ public class MatlabEvalMediator implements Runnable { volatile Object[] optSolSet = null; MatlabProblem mp = null; // no good: even when waiting for only 1 ms the Matlab execution time increases by a factor of 5-10 - final static int sleepTime = 0; + final static int sleepTime = 5; /** * Request evaluation from Matlab for the given params. diff --git a/src/eva2/server/go/problems/MatlabProblem.java b/src/eva2/server/go/problems/MatlabProblem.java index 2a85ddb2..2957e064 100644 --- a/src/eva2/server/go/problems/MatlabProblem.java +++ b/src/eva2/server/go/problems/MatlabProblem.java @@ -37,6 +37,8 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf transient PrintStream dos = null; private double range[][] = null; private static String defTestOut = "matlabproblem-debug.log"; + private static String resOutFile = "matlabproblem-output.txt"; + transient PrintStream resOutStream = null; int verbosityLevel = 0; private MatlabEvalMediator handler = null; private boolean isDouble = true; @@ -225,6 +227,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf // runnable.getGOParams().setPostProcessParams(new PostProcessParams(0, 0.01, 5)); runnable.setTextListener(this); runnable.setVerbosityLevel(verbosityLevel); + runnable.setOutputAdditionalInfo(true); if ((specParams != null) && (specParams.length > 0)) { if ((specValues == null) || (specValues.length != specParams.length)) { @@ -386,9 +389,17 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf } public void print(String str) { + if (resOutStream==null) { + try { + resOutStream = new PrintStream(new FileOutputStream(resOutFile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } if (verbosityLevel > 0) { // matlab displays sysout output in the command window, so we simply use this channel System.out.print(str); + if (resOutStream != null) resOutStream.print(str); } log(str); }