package net.woodyfolsom.msproj.ann2;

/**
 * Based on sample code from http://neuroph.sourceforge.net
 * 
 * @author Woody
 * 
 */
public class XORFilter extends AbstractNeuralNetFilter implements
		NeuralNetFilter {
	
	private static final int INPUT_SIZE = 2;
	private static final int OUTPUT_SIZE = 1;
	
	public XORFilter() {
		this(0.8,0.7);
	}
	
	public XORFilter(double learningRate, double momentum) {
		super( new MultiLayerPerceptron(true, INPUT_SIZE, 2, OUTPUT_SIZE),
				new BackPropagation(learningRate, momentum), 1000, 0.01);
		super.getNeuralNetwork().setName("XORFilter");
		
		//TODO remove
		//getNeuralNetwork().setWeights(new double[] {
		//		0.341232, 0.129952, -0.923123,	//hidden neuron 1 from input0, input1, bias 
		//		-0.115223, 0.570345, -0.328932, //hidden neuron 2 from input0, input1, bias
		//		-0.993423, 0.164732, 0.752621}); //output
	}

	public double compute(double x, double y) {
		return getNeuralNetwork().compute(new double[]{x,y})[0];
	}
	
	@Override
	public int getInputSize() {
		return INPUT_SIZE;
	}

	@Override
	public int getOutputSize() {
		return OUTPUT_SIZE;
	}
}