Rename EvA* classes to Optimization*
This commit is contained in:
parent
a57c4f6504
commit
4bbcf937dc
@ -11,12 +11,11 @@ package eva2.gui;
|
||||
*/
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
import eva2.optimization.stat.EvAJob;
|
||||
import eva2.optimization.stat.OptimizationJob;
|
||||
import eva2.tools.ToolBoxGui;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JButton;
|
||||
@ -120,7 +119,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
EvAJob job = moduleAdapter.scheduleJob();
|
||||
OptimizationJob job = moduleAdapter.scheduleJob();
|
||||
if (job == null) {
|
||||
LOGGER.log(Level.WARNING, "There was an error on scheduling your job");
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ package eva2.gui;
|
||||
*/
|
||||
|
||||
import eva2.gui.editor.GenericObjectEditor;
|
||||
import eva2.optimization.stat.EvAJobList;
|
||||
import eva2.optimization.stat.OptimizationJobList;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
import java.beans.PropertyEditorManager;
|
||||
import java.io.Serializable;
|
||||
@ -44,9 +45,9 @@ public class JParaPanel implements Serializable, PanelMaker {
|
||||
public JComponent makePanel() {
|
||||
PropertyEditorProvider.installEditors();
|
||||
|
||||
if (localParameter instanceof EvAJobList) {
|
||||
if (localParameter instanceof OptimizationJobList) {
|
||||
/* ToDo: First parameter is useless and should be removed */
|
||||
propertyEditor = EvAJobList.makeEditor(tempPanel, (EvAJobList) localParameter);
|
||||
propertyEditor = OptimizationJobList.makeEditor(tempPanel, (OptimizationJobList) localParameter);
|
||||
} else {
|
||||
propertyEditor = new GenericObjectEditor();
|
||||
((GenericObjectEditor) (propertyEditor)).setClassType(localParameter.getClass());
|
||||
|
@ -6,18 +6,15 @@ import eva2.gui.EvATabbedFrameMaker;
|
||||
import eva2.gui.editor.GenericObjectEditor;
|
||||
import eva2.gui.JParaPanel;
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
import eva2.optimization.stat.AbstractStatistics;
|
||||
import eva2.optimization.stat.EvAJob;
|
||||
import eva2.optimization.stat.EvAJobList;
|
||||
import eva2.optimization.stat.InterfaceStatisticsParameter;
|
||||
import eva2.optimization.stat.StatisticsStandalone;
|
||||
import eva2.optimization.stat.StatisticsWithGUI;
|
||||
import eva2.optimization.stat.*;
|
||||
import eva2.optimization.stat.OptimizationJob;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GenericModuleAdapter extends AbstractModuleAdapter implements Serializable {
|
||||
|
||||
private AbstractStatistics statisticsModule;
|
||||
private EvAJobList jobList = null;
|
||||
private OptimizationJobList jobList = null;
|
||||
public String helperFilename;
|
||||
JParaPanel jobPanel = null, paramPanel = null;
|
||||
|
||||
@ -97,7 +94,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
|
||||
frmMkr.addPanelMaker(new JParaPanel(Stat, Stat.getName()));
|
||||
|
||||
jobList = new EvAJobList(new EvAJob[]{});
|
||||
jobList = new OptimizationJobList(new OptimizationJob[]{});
|
||||
jobList.setModule(this);
|
||||
jobList.addTextListener((AbstractStatistics) ((Processor) processor).getStatistics());
|
||||
|
||||
@ -113,7 +110,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
@Override
|
||||
public void performedStart(String infoString) {
|
||||
super.performedStart(infoString);
|
||||
EvAJob job = scheduleJob();
|
||||
OptimizationJob job = scheduleJob();
|
||||
((AbstractStatistics) (((Processor) processor).getStatistics())).addDataListener(job);
|
||||
}
|
||||
|
||||
@ -136,8 +133,8 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
}
|
||||
|
||||
@Override
|
||||
public EvAJob scheduleJob() {
|
||||
EvAJob job = jobList.addJob(((Processor) processor).getGOParams(), (AbstractStatistics) (((Processor) processor).getStatistics()));
|
||||
public OptimizationJob scheduleJob() {
|
||||
OptimizationJob job = jobList.addJob(((Processor) processor).getGOParams(), (AbstractStatistics) (((Processor) processor).getStatistics()));
|
||||
jobPanel.getEditor().setValue(jobList);
|
||||
return job;
|
||||
}
|
||||
|
@ -11,7 +11,8 @@ package eva2.optimization.modules;
|
||||
*/
|
||||
import eva2.gui.EvATabbedFrameMaker;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.optimization.stat.EvAJob;
|
||||
import eva2.optimization.stat.OptimizationJob;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -26,7 +27,7 @@ public interface ModuleAdapter extends OptimizationStateListener {
|
||||
*
|
||||
* @return A new Job
|
||||
*/
|
||||
EvAJob scheduleJob();
|
||||
OptimizationJob scheduleJob();
|
||||
|
||||
void restartOpt();
|
||||
|
||||
|
@ -3,6 +3,7 @@ package eva2.optimization.stat;
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.tools.ReflectPackage;
|
||||
import eva2.tools.math.Mathematics;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
@ -11,21 +12,18 @@ import java.util.List;
|
||||
/**
|
||||
* Do some statistical tests on a set of job results. Note that the plausibility (comparability of the
|
||||
* jobs) is not tested here.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
* @author mkron
|
||||
*/
|
||||
public class EvAStatisticalEvaluation {
|
||||
public static final boolean TRACE=false;
|
||||
// public static final String[] order = {"Mean" , "Median", "Variance", "Std. Deviation"};
|
||||
|
||||
public static EvAStatisticalEvaluationParams statsParams = new EvAStatisticalEvaluationParams();
|
||||
|
||||
// public static void evaluate(EvAJob[] jobList, int[] selectedIndices) {
|
||||
public class EvAStatisticalEvaluation {
|
||||
|
||||
public static EvAStatisticalEvaluationParams statsParams = new EvAStatisticalEvaluationParams();
|
||||
|
||||
// public static void evaluate(OptimizationJob[] jobList, int[] selectedIndices) {
|
||||
// if (TRACE) System.out.println("Job list: " + BeanInspector.toString(jobList));
|
||||
// JTextoutputFrame textout = new JTextoutputFrame("Statistics");
|
||||
// textout.setShow(true);
|
||||
// ArrayList<EvAJob> jobsToWorkWith = new ArrayList<EvAJob>();
|
||||
// ArrayList<OptimizationJob> jobsToWorkWith = new ArrayList<OptimizationJob>();
|
||||
// for (int i=0; i<jobList.length; i++) {
|
||||
// // remove jobs which are not finished or not selected
|
||||
// if (jobList[i]!=null && (Mathematics.contains(selectedIndices, i)) && (jobList[i].isFinishedAndComplete())) jobsToWorkWith.add(jobList[i]);
|
||||
@ -44,307 +42,304 @@ public class EvAStatisticalEvaluation {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void evaluate(InterfaceTextListener textout, EvAJob[] jobList, int[] selectedIndices,
|
||||
StatsOnSingleDataSetEnum[] singleStats,
|
||||
StatsOnTwoSampledDataEnum[] twoSampledStats ) {
|
||||
if (TRACE) {
|
||||
System.out.println("Job list: " + BeanInspector.toString(jobList));
|
||||
}
|
||||
// JTextoutputFrame textout = new JTextoutputFrame("Statistics");
|
||||
// textout.setShow(true);
|
||||
ArrayList<EvAJob> jobsToWorkWith = new ArrayList<EvAJob>();
|
||||
for (int i=0; i<jobList.length; i++) {
|
||||
// remove jobs which are not finished or not selected
|
||||
if (jobList[i]!=null && (Mathematics.contains(selectedIndices, i)) && (jobList[i].isFinishedAndComplete())) {
|
||||
jobsToWorkWith.add(jobList[i]);
|
||||
|
||||
public static void evaluate(InterfaceTextListener textout, OptimizationJob[] jobList, int[] selectedIndices,
|
||||
StatsOnSingleDataSetEnum[] singleStats,
|
||||
StatsOnTwoSampledDataEnum[] twoSampledStats) {
|
||||
ArrayList<OptimizationJob> jobsToWorkWith = new ArrayList<OptimizationJob>();
|
||||
for (int i = 0; i < jobList.length; i++) {
|
||||
// remove jobs which are not finished or not selected
|
||||
if (jobList[i] != null && (Mathematics.contains(selectedIndices, i)) && (jobList[i].isFinishedAndComplete())) {
|
||||
jobsToWorkWith.add(jobList[i]);
|
||||
}
|
||||
}
|
||||
List<String> commonFields = getCommonFields(jobsToWorkWith);
|
||||
if (commonFields != null && !commonFields.isEmpty()) {
|
||||
for (String field : commonFields) {
|
||||
textout.println("###\t" + field + " statistical evaluation");
|
||||
|
||||
if (singleStats.length > 0) {
|
||||
textout.println("one-sampled statistics");
|
||||
for (int j = -1; j < singleStats.length; j++) {
|
||||
if (j < 0) {
|
||||
textout.print("method");
|
||||
} else {
|
||||
textout.print("\t" + singleStats[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> commonFields = getCommonFields(jobsToWorkWith);
|
||||
if (commonFields!=null && !commonFields.isEmpty()) {
|
||||
for (String field : commonFields) {
|
||||
textout.println("###\t"+ field + " statistical evaluation");
|
||||
textout.println("");
|
||||
for (int i = 0; i < jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j = 0; j < singleStats.length; j++) {
|
||||
switch (singleStats[j]) {
|
||||
case mean:
|
||||
textout.print("\t" + calculateMean(field, jobsToWorkWith.get(i)));
|
||||
break;
|
||||
case median:
|
||||
textout.print("\t" + calculateMedian(field, jobsToWorkWith.get(i)));
|
||||
break;
|
||||
case variance:
|
||||
textout.print("\t" + calculateVariance(field, jobsToWorkWith.get(i)));
|
||||
break;
|
||||
case stdDev:
|
||||
textout.print("\t" + calculateStdDev(field, jobsToWorkWith.get(i)));
|
||||
break;
|
||||
default:
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
if (twoSampledStats.length > 0) {
|
||||
textout.println("two-sampled stats:");
|
||||
for (int i = 0; i < twoSampledStats.length; i++) {
|
||||
switch (twoSampledStats[i]) {
|
||||
case tTestEqLenEqVar:
|
||||
textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeTTestEqSizeEqVar(textout, jobsToWorkWith, field);
|
||||
break;
|
||||
case tTestUneqLenEqVar:
|
||||
textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeUnEqSizeEqVar(textout, jobsToWorkWith, field);
|
||||
break;
|
||||
case tTestUneqLenUneqVar:
|
||||
textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeTTestUnEqSizeUnEqVar(textout, jobsToWorkWith, field);
|
||||
break;
|
||||
case mannWhitney:
|
||||
textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeMannWhitney(textout, jobsToWorkWith, field);
|
||||
default:
|
||||
textout.println("");
|
||||
break;
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(singleStats.length > 0){
|
||||
textout.println("one-sampled statistics");
|
||||
for (int j=-1; j<singleStats.length; j++) {
|
||||
if(j<0){
|
||||
textout.print("method");
|
||||
}else{
|
||||
textout.print("\t" + singleStats[j]);
|
||||
}
|
||||
}
|
||||
textout.println("");
|
||||
for(int i=0; i<jobsToWorkWith.size(); i++){
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for(int j=0; j<singleStats.length; j++){
|
||||
switch(singleStats[j]){
|
||||
case mean: textout.print("\t" + calculateMean(field, jobsToWorkWith.get(i))); break;
|
||||
case median: textout.print("\t" + calculateMedian(field, jobsToWorkWith.get(i))); break;
|
||||
case variance: textout.print("\t" + calculateVariance(field, jobsToWorkWith.get(i))); break;
|
||||
case stdDev: textout.print("\t" + calculateStdDev(field, jobsToWorkWith.get(i))); break;
|
||||
default: textout.println("");
|
||||
}
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
if(twoSampledStats.length > 0){
|
||||
textout.println("two-sampled stats:");
|
||||
for(int i=0; i<twoSampledStats.length; i++){
|
||||
switch(twoSampledStats[i]){
|
||||
case tTestEqLenEqVar: textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeTTestEqSizeEqVar(textout, jobsToWorkWith, field);
|
||||
break;
|
||||
case tTestUneqLenEqVar: textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeUnEqSizeEqVar(textout, jobsToWorkWith, field);
|
||||
break;
|
||||
case tTestUneqLenUneqVar: textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeTTestUnEqSizeUnEqVar(textout, jobsToWorkWith, field);
|
||||
break;
|
||||
case mannWhitney: textout.println(StatsOnTwoSampledDataEnum.getInfoStrings()[twoSampledStats[i].ordinal()]);
|
||||
writeTwoSampleFirstLine(textout, jobsToWorkWith);
|
||||
writeMannWhitney(textout, jobsToWorkWith, field);
|
||||
default: textout.println("");
|
||||
break;
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
* @param field
|
||||
*/
|
||||
private static void writeTTestUnEqSizeUnEqVar(
|
||||
InterfaceTextListener textout, ArrayList<OptimizationJob> jobsToWorkWith,
|
||||
String field) {
|
||||
for (int i = 0; i < jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j = 0; j < jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateTTestUnEqSizeUnEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
* @param field
|
||||
*/
|
||||
private static void writeTTestUnEqSizeUnEqVar(
|
||||
InterfaceTextListener textout, ArrayList<EvAJob> jobsToWorkWith,
|
||||
String field) {
|
||||
for (int i=0; i<jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j=0; j<jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateTTestUnEqSizeUnEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
* @param field
|
||||
*/
|
||||
private static void writeUnEqSizeEqVar(InterfaceTextListener textout,
|
||||
ArrayList<OptimizationJob> jobsToWorkWith, String field) {
|
||||
for (int i = 0; i < jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j = 0; j < jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateTTestUnEqSizeEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
* @param field
|
||||
*/
|
||||
private static void writeUnEqSizeEqVar(InterfaceTextListener textout,
|
||||
ArrayList<EvAJob> jobsToWorkWith, String field) {
|
||||
for (int i=0; i<jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j=0; j<jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateTTestUnEqSizeEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
* @param field
|
||||
*/
|
||||
private static void writeTTestEqSizeEqVar(InterfaceTextListener textout,
|
||||
ArrayList<OptimizationJob> jobsToWorkWith, String field) {
|
||||
for (int i = 0; i < jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j = 0; j < jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateTTestEqSizeEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
* @param field
|
||||
*/
|
||||
private static void writeTTestEqSizeEqVar(InterfaceTextListener textout,
|
||||
ArrayList<EvAJob> jobsToWorkWith, String field) {
|
||||
for (int i=0; i<jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j=0; j<jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateTTestEqSizeEqVar(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeMannWhitney(InterfaceTextListener textout,
|
||||
ArrayList<EvAJob> jobsToWorkWith, String field) {
|
||||
for (int i=0; i<jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j=0; j<jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateMannWhintey(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
private static void writeMannWhitney(InterfaceTextListener textout,
|
||||
ArrayList<OptimizationJob> jobsToWorkWith, String field) {
|
||||
for (int i = 0; i < jobsToWorkWith.size(); i++) {
|
||||
textout.print(jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
for (int j = 0; j < jobsToWorkWith.size(); j++) {
|
||||
textout.print("\t" + calculateMannWhintey(field, jobsToWorkWith.get(i), jobsToWorkWith.get(j)));
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
*/
|
||||
private static void writeTwoSampleFirstLine(InterfaceTextListener textout,
|
||||
ArrayList<EvAJob> jobsToWorkWith) {
|
||||
for(int i=0; i<jobsToWorkWith.size(); i++){
|
||||
textout.print("\t" + jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
|
||||
public static double roundTo2DecimalPlaces(double value){
|
||||
DecimalFormat twoDForm = new DecimalFormat("#.##");
|
||||
String b = twoDForm.format(value);
|
||||
b = b.replace(',', '.');
|
||||
Double c = Double.valueOf(b);
|
||||
return c;
|
||||
}
|
||||
|
||||
private static String calculateMean(String field, EvAJob job1){
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double mean = Double.NaN;
|
||||
if (dat!=null) {
|
||||
mean = Mathematics.mean(dat);
|
||||
mean = EvAStatisticalEvaluation.roundTo2DecimalPlaces(mean);
|
||||
}
|
||||
return ""+mean;
|
||||
}
|
||||
|
||||
private static String calculateMedian(String field, EvAJob job1){
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double median = Double.NaN;
|
||||
if (dat!=null) {
|
||||
median = Mathematics.median2(dat, true);
|
||||
median = EvAStatisticalEvaluation.roundTo2DecimalPlaces(median);
|
||||
}
|
||||
|
||||
return ""+median;
|
||||
}
|
||||
|
||||
private static String calculateVariance(String field, EvAJob job1){
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double variance = Double.NaN;
|
||||
if (dat!=null) {
|
||||
variance = Mathematics.variance(dat);
|
||||
variance = EvAStatisticalEvaluation.roundTo2DecimalPlaces(variance);
|
||||
}
|
||||
return ""+variance;
|
||||
}
|
||||
|
||||
private static String calculateStdDev(String field, EvAJob job1){
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double stdDev = Double.NaN;
|
||||
if (dat!=null) {
|
||||
stdDev = Mathematics.stdDev(dat);
|
||||
stdDev = EvAStatisticalEvaluation.roundTo2DecimalPlaces(stdDev);
|
||||
}
|
||||
return ""+stdDev;
|
||||
}
|
||||
|
||||
private static String calculateTTestEqSizeEqVar(String field, EvAJob job1, EvAJob job2){
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t=Double.NaN;
|
||||
if (dat1!=null && dat2!=null) {
|
||||
t = Mathematics.tTestEqSizeEqVar(dat1, dat2);
|
||||
}
|
||||
/**
|
||||
* @param textout
|
||||
* @param jobsToWorkWith
|
||||
*/
|
||||
private static void writeTwoSampleFirstLine(InterfaceTextListener textout,
|
||||
ArrayList<OptimizationJob> jobsToWorkWith) {
|
||||
for (int i = 0; i < jobsToWorkWith.size(); i++) {
|
||||
textout.print("\t" + jobsToWorkWith.get(i).getParams().getOptimizer().getName());
|
||||
}
|
||||
textout.println("");
|
||||
}
|
||||
|
||||
public static double roundTo2DecimalPlaces(double value) {
|
||||
DecimalFormat twoDForm = new DecimalFormat("#.##");
|
||||
String b = twoDForm.format(value);
|
||||
b = b.replace(',', '.');
|
||||
Double c = Double.valueOf(b);
|
||||
return c;
|
||||
}
|
||||
|
||||
private static String calculateMean(String field, OptimizationJob job1) {
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double mean = Double.NaN;
|
||||
if (dat != null) {
|
||||
mean = Mathematics.mean(dat);
|
||||
mean = EvAStatisticalEvaluation.roundTo2DecimalPlaces(mean);
|
||||
}
|
||||
return "" + mean;
|
||||
}
|
||||
|
||||
private static String calculateMedian(String field, OptimizationJob job1) {
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double median = Double.NaN;
|
||||
if (dat != null) {
|
||||
median = Mathematics.median2(dat, true);
|
||||
median = EvAStatisticalEvaluation.roundTo2DecimalPlaces(median);
|
||||
}
|
||||
|
||||
return "" + median;
|
||||
}
|
||||
|
||||
private static String calculateVariance(String field, OptimizationJob job1) {
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double variance = Double.NaN;
|
||||
if (dat != null) {
|
||||
variance = Mathematics.variance(dat);
|
||||
variance = EvAStatisticalEvaluation.roundTo2DecimalPlaces(variance);
|
||||
}
|
||||
return "" + variance;
|
||||
}
|
||||
|
||||
private static String calculateStdDev(String field, OptimizationJob job1) {
|
||||
double[] dat = job1.getDoubleDataColumn(field);
|
||||
double stdDev = Double.NaN;
|
||||
if (dat != null) {
|
||||
stdDev = Mathematics.stdDev(dat);
|
||||
stdDev = EvAStatisticalEvaluation.roundTo2DecimalPlaces(stdDev);
|
||||
}
|
||||
return "" + stdDev;
|
||||
}
|
||||
|
||||
private static String calculateTTestEqSizeEqVar(String field, OptimizationJob job1, OptimizationJob job2) {
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t = Double.NaN;
|
||||
if (dat1 != null && dat2 != null) {
|
||||
t = Mathematics.tTestEqSizeEqVar(dat1, dat2);
|
||||
}
|
||||
// MannWhitneyTest mwt = new MannWhitneyTest(job1.getDoubleDataColumn(field), job2.getDoubleDataColumn(field));
|
||||
// double t = mwt.getSP();
|
||||
// t = roundTo2DecimalPlaces(t);
|
||||
return ""+t;
|
||||
}
|
||||
|
||||
private static String calculateTTestUnEqSizeEqVar(String field, EvAJob job1, EvAJob job2){
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t=Double.NaN;
|
||||
if (dat1!=null && dat2!=null) {
|
||||
t = Mathematics.tTestUnEqSizeEqVar(dat1, dat2);
|
||||
}
|
||||
return "" + t;
|
||||
}
|
||||
|
||||
private static String calculateTTestUnEqSizeEqVar(String field, OptimizationJob job1, OptimizationJob job2) {
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t = Double.NaN;
|
||||
if (dat1 != null && dat2 != null) {
|
||||
t = Mathematics.tTestUnEqSizeEqVar(dat1, dat2);
|
||||
}
|
||||
// t = roundTo2DecimalPlaces(t);
|
||||
return ""+t;
|
||||
}
|
||||
|
||||
private static String calculateTTestUnEqSizeUnEqVar(String field, EvAJob job1, EvAJob job2){
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t=Double.NaN;
|
||||
if (dat1!=null && dat2!=null) {
|
||||
t = Mathematics.tTestUnEqSizeUnEqVar(dat1, dat2);
|
||||
}
|
||||
return "" + t;
|
||||
}
|
||||
|
||||
private static String calculateTTestUnEqSizeUnEqVar(String field, OptimizationJob job1, OptimizationJob job2) {
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t = Double.NaN;
|
||||
if (dat1 != null && dat2 != null) {
|
||||
t = Mathematics.tTestUnEqSizeUnEqVar(dat1, dat2);
|
||||
}
|
||||
// t = roundTo2DecimalPlaces(t);
|
||||
return ""+t;
|
||||
}
|
||||
|
||||
private static String calculateMannWhintey(String field, EvAJob job1, EvAJob job2){
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t=Double.NaN;
|
||||
if (dat1!=null && dat2!=null) {
|
||||
Object obj = ReflectPackage.instantiateWithParams("jsc.independentsamples.MannWhitneyTest", new Object[]{dat1,dat2}, null);
|
||||
if (obj!=null) {
|
||||
Object sp = BeanInspector.callIfAvailable(obj, "getSP", new Object[]{});
|
||||
return "" + t;
|
||||
}
|
||||
|
||||
private static String calculateMannWhintey(String field, OptimizationJob job1, OptimizationJob job2) {
|
||||
double[] dat1 = job1.getDoubleDataColumn(field);
|
||||
double[] dat2 = job2.getDoubleDataColumn(field);
|
||||
double t = Double.NaN;
|
||||
if (dat1 != null && dat2 != null) {
|
||||
Object obj = ReflectPackage.instantiateWithParams("jsc.independentsamples.MannWhitneyTest", new Object[]{dat1, dat2}, null);
|
||||
if (obj != null) {
|
||||
Object sp = BeanInspector.callIfAvailable(obj, "getSP", new Object[]{});
|
||||
// System.out.println(BeanInspector.niceToString(obj));
|
||||
// System.out.println("SP val is " + sp);
|
||||
t = (Double) sp;
|
||||
} else {
|
||||
System.err.println("For the MannWhitney test, the JSC package is required on the class path!");
|
||||
}
|
||||
}
|
||||
return ""+t;
|
||||
}
|
||||
t = (Double) sp;
|
||||
} else {
|
||||
System.err.println("For the MannWhitney test, the JSC package is required on the class path!");
|
||||
}
|
||||
}
|
||||
return "" + t;
|
||||
}
|
||||
|
||||
private static String compare(String field, EvAJob job1, EvAJob job2) {
|
||||
private static String compare(String field, OptimizationJob job1, OptimizationJob job2) {
|
||||
// TODO do some statistical test
|
||||
int numRuns1 = job1.getNumRuns();
|
||||
int numRuns2 = job2.getNumRuns();
|
||||
if (TRACE) {
|
||||
System.out.println("Run 1: " + numRuns1 + " runs, Run 2: " + numRuns2);
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println("Data of run 1: " + BeanInspector.toString(job1.getDataColumn(field)));
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println("Data of run 2: " + BeanInspector.toString(job2.getDataColumn(field)));
|
||||
}
|
||||
double avg1=Mathematics.mean(job1.getDoubleDataColumn(field));
|
||||
double avg2=Mathematics.mean(job2.getDoubleDataColumn(field));
|
||||
|
||||
if (avg1<avg2) {
|
||||
return "-1";
|
||||
}
|
||||
else if (avg1>avg2) {
|
||||
return "1";
|
||||
}
|
||||
else {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
int numRuns1 = job1.getNumRuns();
|
||||
int numRuns2 = job2.getNumRuns();
|
||||
double avg1 = Mathematics.mean(job1.getDoubleDataColumn(field));
|
||||
double avg2 = Mathematics.mean(job2.getDoubleDataColumn(field));
|
||||
|
||||
/**
|
||||
* Return a list of field names which occur in all jobs.
|
||||
* @param jobList
|
||||
* @return
|
||||
*/
|
||||
private static List<String> getCommonFields(List<EvAJob> jobList) {
|
||||
List<String> lSoFar=null, tmpL = new LinkedList<String>();
|
||||
for (EvAJob j:jobList) {
|
||||
if (lSoFar==null) {
|
||||
lSoFar = new LinkedList<String>();
|
||||
for (String f : j.getFieldHeaders()) {
|
||||
if (avg1 < avg2) {
|
||||
return "-1";
|
||||
} else if (avg1 > avg2) {
|
||||
return "1";
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of field names which occur in all jobs.
|
||||
*
|
||||
* @param jobList
|
||||
* @return
|
||||
*/
|
||||
private static List<String> getCommonFields(List<OptimizationJob> jobList) {
|
||||
List<String> lSoFar = null, tmpL = new LinkedList<String>();
|
||||
for (OptimizationJob j : jobList) {
|
||||
if (lSoFar == null) {
|
||||
lSoFar = new LinkedList<String>();
|
||||
for (String f : j.getFieldHeaders()) {
|
||||
lSoFar.add(f);
|
||||
}
|
||||
} else {
|
||||
for (String f : lSoFar) {
|
||||
if (j.getFieldIndex(f)>=0) {
|
||||
tmpL.add(f);
|
||||
}
|
||||
}
|
||||
lSoFar=tmpL;
|
||||
tmpL = new LinkedList<String>();
|
||||
}
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println("Common fields are " + BeanInspector.toString(lSoFar));
|
||||
} else {
|
||||
for (String f : lSoFar) {
|
||||
if (j.getFieldIndex(f) >= 0) {
|
||||
tmpL.add(f);
|
||||
}
|
||||
}
|
||||
lSoFar = tmpL;
|
||||
tmpL = new LinkedList<String>();
|
||||
}
|
||||
return lSoFar;
|
||||
}
|
||||
}
|
||||
return lSoFar;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An EvAJob is a set of optimization parameters and potential results from the statistics class.
|
||||
* An OptimizationJob is a set of optimization parameters and potential results from the statistics class.
|
||||
* Each job has a unique ID and may have been completely finished or not. Once finished, the
|
||||
* framework should guarantee that the job is removed as a statistics listener.
|
||||
*
|
||||
@ -16,7 +16,7 @@ import java.util.List;
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
public class EvAJob implements Serializable, InterfaceStatisticsListener {
|
||||
public class OptimizationJob implements Serializable, InterfaceStatisticsListener {
|
||||
private static final boolean TRACE = false;
|
||||
|
||||
private InterfaceOptimizationParameters params = null;
|
||||
@ -31,12 +31,12 @@ public class EvAJob implements Serializable, InterfaceStatisticsListener {
|
||||
|
||||
private enum StateEnum { running, idle, complete, incomplete};
|
||||
|
||||
public EvAJob() {
|
||||
public OptimizationJob() {
|
||||
jobID=jobIDCounter;
|
||||
jobIDCounter++;
|
||||
}
|
||||
|
||||
public EvAJob(InterfaceOptimizationParameters params, InterfaceStatistics sts) {
|
||||
public OptimizationJob(InterfaceOptimizationParameters params, InterfaceStatistics sts) {
|
||||
this();
|
||||
this.params = params;
|
||||
if (sts instanceof AbstractStatistics) {
|
||||
@ -169,7 +169,7 @@ public class EvAJob implements Serializable, InterfaceStatisticsListener {
|
||||
numRuns=runsPerformed;
|
||||
lastRunIncompl = !completedLastRun;
|
||||
if (TRACE) {
|
||||
System.out.println("EvAJob.notifyRunStopped, " + runsPerformed + " " + completedLastRun);
|
||||
System.out.println("OptimizationJob.notifyRunStopped, " + runsPerformed + " " + completedLastRun);
|
||||
}
|
||||
}
|
||||
|
@ -30,12 +30,12 @@ import javax.swing.JOptionPane;
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
public class EvAJobList extends PropertySelectableList<EvAJob> implements Serializable, InterfaceTextListener {
|
||||
public class OptimizationJobList extends PropertySelectableList<OptimizationJob> implements Serializable, InterfaceTextListener {
|
||||
|
||||
List<InterfaceTextListener> listeners = null;
|
||||
private ModuleAdapter module = null;
|
||||
|
||||
public EvAJobList(EvAJob[] initial) {
|
||||
public OptimizationJobList(OptimizationJob[] initial) {
|
||||
super(initial);
|
||||
}
|
||||
|
||||
@ -53,24 +53,24 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
* @param params
|
||||
* @param stats
|
||||
*/
|
||||
public EvAJob addJob(InterfaceOptimizationParameters params, AbstractStatistics stats) {
|
||||
EvAJob job = new EvAJob((InterfaceOptimizationParameters) Serializer.deepClone(params), stats);
|
||||
public OptimizationJob addJob(InterfaceOptimizationParameters params, AbstractStatistics stats) {
|
||||
OptimizationJob job = new OptimizationJob((InterfaceOptimizationParameters) Serializer.deepClone(params), stats);
|
||||
stats.addDataListener(job);
|
||||
addJob(job, true);
|
||||
return job;
|
||||
}
|
||||
|
||||
private void addJob(EvAJob j, boolean selected) {
|
||||
EvAJob[] curArr = getObjects();
|
||||
EvAJob[] newArr = null;
|
||||
private void addJob(OptimizationJob j, boolean selected) {
|
||||
OptimizationJob[] curArr = getObjects();
|
||||
OptimizationJob[] newArr = null;
|
||||
boolean[] newSelection = null;
|
||||
if (curArr != null && curArr.length > 0) {
|
||||
newArr = new EvAJob[curArr.length + 1];
|
||||
newArr = new OptimizationJob[curArr.length + 1];
|
||||
newSelection = new boolean[newArr.length];
|
||||
System.arraycopy(curArr, 0, newArr, 0, curArr.length);
|
||||
System.arraycopy(m_Selection, 0, newSelection, 0, curArr.length);
|
||||
} else {
|
||||
newArr = new EvAJob[1];
|
||||
newArr = new OptimizationJob[1];
|
||||
newSelection = new boolean[1];
|
||||
}
|
||||
newSelection[newArr.length - 1] = selected;
|
||||
@ -83,8 +83,8 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EvAJob lastJob() {
|
||||
EvAJob[] curArr = getObjects();
|
||||
public OptimizationJob lastJob() {
|
||||
OptimizationJob[] curArr = getObjects();
|
||||
if (curArr != null && curArr.length > 0) {
|
||||
return curArr[curArr.length - 1];
|
||||
} else {
|
||||
@ -97,10 +97,10 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<EvAJob> getSelectedJobs() {
|
||||
EvAJob[] selected = getSelectedObjects();
|
||||
ArrayList<EvAJob> l = new ArrayList<EvAJob>();
|
||||
for (EvAJob j : selected) {
|
||||
public ArrayList<OptimizationJob> getSelectedJobs() {
|
||||
OptimizationJob[] selected = getSelectedObjects();
|
||||
ArrayList<OptimizationJob> l = new ArrayList<OptimizationJob>();
|
||||
for (OptimizationJob j : selected) {
|
||||
if (j != null) {
|
||||
l.add(j);
|
||||
}
|
||||
@ -109,7 +109,7 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
}
|
||||
|
||||
public boolean saveSelectedJobs(Component parentComponent) {
|
||||
EvAJob[] selected = getSelectedObjects();
|
||||
OptimizationJob[] selected = getSelectedObjects();
|
||||
if (selected != null && (selected.length > 0)) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setName("Select a directory to save jobs to...");
|
||||
@ -118,7 +118,7 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File sFile = fc.getSelectedFile();
|
||||
if (sFile.exists()) {
|
||||
for (EvAJob job : selected) {
|
||||
for (OptimizationJob job : selected) {
|
||||
if (job != null) {
|
||||
if (!FileTools.saveObjectToFolder(job, sFile, false, parentComponent)) {
|
||||
System.err.println("Error on saving jobs...");
|
||||
@ -144,8 +144,8 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public EvAJob getJobOf(InterfaceOptimizationParameters params) {
|
||||
for (EvAJob job : getObjects()) {
|
||||
public OptimizationJob getJobOf(InterfaceOptimizationParameters params) {
|
||||
for (OptimizationJob job : getObjects()) {
|
||||
if (job.getGOParams() == params) {
|
||||
return job;
|
||||
}
|
||||
@ -159,7 +159,7 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
* @param jobList
|
||||
* @return
|
||||
*/
|
||||
public static PropertyEditor makeEditor(final Component parent, final EvAJobList jobList) {
|
||||
public static PropertyEditor makeEditor(final Component parent, final OptimizationJobList jobList) {
|
||||
final GenericArrayEditor genericArrayEditor = new GenericArrayEditor();
|
||||
genericArrayEditor.setWithAddButton(false);
|
||||
genericArrayEditor.setWithSetButton(false);
|
||||
@ -198,20 +198,20 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
return genericArrayEditor;
|
||||
}
|
||||
|
||||
private static JComponent createStatsPanel(final EvAJobList jobList, final GenericArrayEditor edi) {
|
||||
private static JComponent createStatsPanel(final OptimizationJobList jobList, final GenericArrayEditor edi) {
|
||||
JParaPanel pan = new JParaPanel(EvAStatisticalEvaluation.statsParams, "Statistics");
|
||||
JComponent paraPan = pan.makePanel();
|
||||
return paraPan;
|
||||
}
|
||||
|
||||
private static ActionListener getReuseActionListener(final Component parent, final EvAJobList jobList) {
|
||||
private static ActionListener getReuseActionListener(final Component parent, final OptimizationJobList jobList) {
|
||||
ActionListener al = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<EvAJob> jobs = jobList.getSelectedJobs();
|
||||
List<OptimizationJob> jobs = jobList.getSelectedJobs();
|
||||
if (jobs.size() == 1) {
|
||||
EvAJob job = jobs.get(0);
|
||||
OptimizationJob job = jobs.get(0);
|
||||
AbstractOptimizationParameters curParams = (AbstractOptimizationParameters) ((AbstractModuleAdapter) jobList.module).getGOParameters();
|
||||
curParams.setSameParams((AbstractOptimizationParameters) job.getGOParams());
|
||||
((GenericModuleAdapter) jobList.module).setGOParameters(curParams);
|
||||
@ -225,13 +225,13 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
|
||||
return al;
|
||||
}
|
||||
|
||||
private static ActionListener getClearSelectedActionListener(final Component parent, final EvAJobList jobList) {
|
||||
private static ActionListener getClearSelectedActionListener(final Component parent, final OptimizationJobList jobList) {
|
||||
ActionListener al = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<EvAJob> jobs = jobList.getSelectedJobs();
|
||||
for (EvAJob j : jobs) {
|
||||
List<OptimizationJob> jobs = jobList.getSelectedJobs();
|
||||
for (OptimizationJob j : jobs) {
|
||||
j.resetJob();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user