public double AskNeuralNetwork(double[] input)
 {
     Network.Network network = new Network.Network(_inputData[0].Length, _numberOfHiddenLayers, _networkTopology);
     network.InitializeNetwork();
     network.SetWeights(_archive[0]);
     return network.CalculateOutputForOneExample(input);
 }
        private void ComputeFitness()
        {
            //for (int i = 0; i < _2archiveSize; i++)
            //{
            //    Network.Network network = new Network.Network(_inputData[0].Length, _numberOfHiddenLayers, _networkTopology);
            //    network.InitializeNetwork();
            //    network.SetWeights(_archive[i]);

            //    _fitnessVector[i] = calculateMAEForAllExamples(network);
            //}

            Parallel.For(0, _2archiveSize, i =>
            {
                Network.Network network = new Network.Network(_inputData[0].Length, _numberOfHiddenLayers, _networkTopology);
                network.InitializeNetwork();
                network.SetWeights(_archive[i]);

                _fitnessVector[i] = CalculateMaeForAllExamples(network);
            });
        }
 private void SetTotalNumberOfWeights()
 {
     Network.Network network = new Network.Network(_inputData[0].Length, _numberOfHiddenLayers, _networkTopology);
     _totalNumberOfWeights = network.TotalNumberOfWeights;
 }
 double CalculateMaeForAllExamples(Network.Network network)
 {
     //double error = _inputData.Select((t, i) => Math.Abs(_desiredOutput[i] - network.CalculateOutputForOneExample(t))).Sum();
     double error = 0.0;
     for (int i = 0; i < _desiredOutput.Length; i++)
     {
         double networkOutput = network.CalculateOutputForOneExample(_inputData[i]);
         double absError = Math.Abs(_desiredOutput[i] - networkOutput);
         if ((_desiredOutput[i] > 0 && networkOutput > 0) || (_desiredOutput[i] < 0 && networkOutput < 0))
         {
             error += absError;
         }
         else
         {
             error += 10*absError;
         }
     }
     return error / _inputData.Length;
 }