package net.woodyfolsom.msproj.ann;

import org.neuroph.core.NeuralNetwork;
import org.neuroph.core.learning.SupervisedTrainingElement;
import org.neuroph.core.learning.TrainingSet;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.util.TransferFunctionType;

/**
 * Based on sample code from http://neuroph.sourceforge.net
 * 
 * @author Woody
 * 
 */
public class XORLearner implements NeuralNetLearner {
	private NeuralNetwork neuralNetwork;

	public XORLearner() {
		reset();
	}

	@Override
	public NeuralNetwork getNeuralNetwork() {
		return neuralNetwork;
	}

	@Override
	public void learn(TrainingSet<SupervisedTrainingElement> trainingSet) {
		this.neuralNetwork.learn(trainingSet);
	}

	@Override
	public void reset() {
		this.neuralNetwork = new MultiLayerPerceptron(
				TransferFunctionType.TANH, 2, 3, 1);
	}

	@Override
	public void setNeuralNetwork(NeuralNetwork neuralNetwork) {
		this.neuralNetwork = neuralNetwork;
	}
}