.getMainWindow());
if (mlMethod != null)
dialog.setMethod(mlMethod);
if (dialog.process()) {
MLMethod method = dialog.getNetwork();
MLDataSet trainingData = dialog.getTrainingSet();
if (method == null) {
EncogWorkBench.displayError("Error",
"Machine language method is required to train.");
return;
}
if (method instanceof ART1) {
EncogWorkBench
.displayError("Error",
"ART1 Networks are not trained, they learn as they are queried.");
return;
}
if (trainingData == null) {
EncogWorkBench.displayError("Error",
"Training set is required to train.");
return;
}
if (method instanceof HopfieldNetwork) {
HopfieldNetwork hp = (HopfieldNetwork) method;
ProjectEGFile file = (ProjectEGFile) dialog.getComboNetwork()
.getSelectedValue();
for (MLDataPair pair : trainingData) {
hp.addPattern(pair.getInput());
}
if (EncogWorkBench.askQuestion("Hopfield",
"Training done, save?")) {
file.save();
}
} else if (method instanceof SOM) {
ProjectEGFile file = (ProjectEGFile) dialog.getComboNetwork()
.getSelectedValue();
performSOM(file, trainingData);
} else if (method instanceof SVM) {
ProjectEGFile file = (ProjectEGFile) dialog.getComboNetwork()
.getSelectedValue();
performSVM(file, trainingData);
} else if (method instanceof CPN) {
ProjectEGFile file = (ProjectEGFile) dialog.getComboNetwork()
.getSelectedValue();
performCPN(file, trainingData);
} else if (method instanceof BasicNetwork || method instanceof RBFNetwork ) {
ChooseBasicNetworkTrainingMethod choose = new ChooseBasicNetworkTrainingMethod(
EncogWorkBench.getInstance().getMainWindow(),method);
if (choose.process()) {
ProjectEGFile file = (ProjectEGFile) dialog
.getComboNetwork().getSelectedValue();
switch (choose.getType()) {
case SCG:
performSCG(file, trainingData);
break;
case PropagationResilient:
performRPROP(file, trainingData);
break;
case PropagationBack:
performBPROP(file, trainingData);
break;
case PropagationManhattan:
performManhattan(file, trainingData);
break;
case LevenbergMarquardt:
performLMA(file, trainingData);
break;
case Genetic:
performGenetic(file, trainingData);
break;
case Annealing:
performAnnealing(file, trainingData);
break;
case ADALINE:
performADALINE(file, trainingData);
break;
case PropagationQuick:
performQPROP(file, trainingData);
break;
}
}
} else {
EncogWorkBench.displayError("Unknown Method",
"No training method is available for: "
+ method.getClass().getName());
}
}
}