Minor JEInterface changes.

This commit is contained in:
Marcel Kronfeld 2009-02-03 08:36:09 +00:00
parent 2cb9db4a9d
commit 50dfec343f
3 changed files with 18 additions and 4 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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);
}