public double[] MakeStep(double[] inputs) { isIterationsFinished = false; isWaveCameToOutputNeuron = false; double[] outputs = new double[output_neurons.Length]; for (int i = 0; i < output_neurons.Length; i++) { outputs[i] = output_neurons[i].OutputValue; } for (int i = 0; i < input_neurons.Length; i++) { input_neurons[i].InputValue = inputs[i]; } addInputNeuronsToFirstPool(); while (true) { if (evaluation_machine.Count > 0) { Queue <Neuron> pool = evaluation_machine.Dequeue(); Queue <Neuron> next_pool = new Queue <Neuron>(); bool isStop = false; Queue <Neuron> poolCopy = new Queue <Neuron>(pool); while (pool.Count > 0) { Neuron cur_evaluating_neuron = pool.Dequeue(); cur_evaluating_neuron.CalculateOutputValue(); int indexCurNeuron = -1; for (int i = 0; i < NeuronsCount; i++) { if (cur_evaluating_neuron == neurons[i]) { indexCurNeuron = i; break; } } for (int i = 0; i < NeuronsCount; i++) { if (topology[indexCurNeuron, i] == true) { Neuron neu = neurons[i]; if (next_pool.Contains(neu) == false) { next_pool.Enqueue(neu); } if (input_neurons.Contains(neu) == true) { isStop = true; } } } if (isWaveCameToOutputNeuron == false) { isWaveCameToOutputNeuron = output_neurons.Contains(cur_evaluating_neuron); } if (output_neurons.Contains(cur_evaluating_neuron) == true && (evaluation_machine.Count > 0 || next_pool.Count > 0)) { isStop = true; int index = -1; for (int i = 0; i < output_neurons.Length; i++) { if (output_neurons[i] == cur_evaluating_neuron) { index = i; break; } } outputs[index] = cur_evaluating_neuron.OutputValue; } } while (poolCopy.Count > 0) { Neuron curNeuron = poolCopy.Dequeue(); int indexCurNeuron = -1; for (int i = 0; i < NeuronsCount; i++) { if (curNeuron == neurons[i]) { indexCurNeuron = i; break; } } for (int i = 0; i < NeuronsCount; i++) { if (topology[indexCurNeuron, i] == true) { neurons[i].SetInputValue(neurons[indexCurNeuron].OutputValue, indexCurNeuron); } } } if (next_pool.Count > 0) { evaluation_machine.Enqueue(next_pool); } if (isStop == true) { if (pool.Count > 0) { evaluation_machine.Enqueue(pool); } return(outputs); } } else { break; } } isIterationsFinished = true; for (int i = 0; i < output_neurons.Length; i++) { outputs[i] = output_neurons[i].OutputValue; } return(outputs); }