// Worker thread
		private void SearchSolution( )
		{
            _resource = new MinutieResource();
            NetworkHelper networkHelper;
		    if (MinutieResource.IsAlreadyTaughtAndSaved(_SOMParams))
		    {
                networkHelper = new NetworkHelper(_resource.LoadTaughtPeople(_SOMParams), _SOMParams);
                networkHelper.Teach(iterations, iterations-1);
                SetText(currentIterationBox, _SOMParams.Iterations.ToString());
		    }
		    else
		    {
                networkHelper = new NetworkHelper(_resource.GetAllFeatures(), _SOMParams);

                var iter = 0;
                while (!needToStop)
                {
                    networkHelper.Teach(iterations, iter);

                    iter++;

                    SetText(currentIterationBox, iter.ToString());

                    if (iter >= iterations-1)
                        needToStop = true;
                }

                //_resource.SaveTaughtPeople(networkHelper._inputs, _SOMParams);

                networkHelper.Teach(iterations, iter);
		        iter++;
                SetText(currentIterationBox, iter.ToString());
		    }

            // create map
            map = new int[networkHelper._networkSize[0], networkHelper._networkSize[1], 3];

            UpdateMap(networkHelper);
            FindPerson();

			// enable settings controls
			EnableControls( true );            
		}
        public void StartTesting()
        {
            var inputImage = ImageLoader.LoadImage(AppDomain.CurrentDomain.BaseDirectory + _fileName);
            Parallel.ForEach(_somParamses, new ParallelOptions { MaxDegreeOfParallelism = 4 }, (currentParams) =>
            {
                object clonedImage;
                try
                {
                    clonedImage = inputImage.Clone();
                }
                catch (InvalidOperationException ioe)
                {
                    const string winnerException = "000";
                    var formattedWinnerWithParamsException = string.Format(@"{0};{1};{2};{3};{4};{5};{6};{7}", winnerException,
                        currentParams.LearningRadius, currentParams.LearningRate, currentParams.Iterations,
                        currentParams.AngleMultiplier,
                        currentParams.TypeMultiplier, currentParams.CoordsMultiplier,
                        currentParams.HashCodeMultiplier);

                    _winnersList.TryAdd(formattedWinnerWithParamsException);
                    return;
                }
                
                var queryFeaturesSet = NetworkHelper.GetQueryFeaturesSet((Bitmap)clonedImage, currentParams);

                var resource = new MinutieResource();
                NetworkHelper networkHelper;
                if (MinutieResource.IsAlreadyTaughtAndSaved(currentParams))
                {
                    networkHelper = new NetworkHelper(resource.LoadTaughtPeople(currentParams), currentParams);
                    networkHelper.Teach(currentParams.Iterations, currentParams.Iterations - 1);
                }
                else
                {
                    networkHelper = new NetworkHelper(resource.GetAllFeatures(), currentParams);

                    var iter = 0;
                    while (!(iter >= currentParams.Iterations - 1))
                    {
                        networkHelper.Teach(currentParams.Iterations, iter);
                        iter++;
                    }

                    resource.SaveTaughtPeople(networkHelper._inputs, currentParams);

                    networkHelper.Teach(currentParams.Iterations, iter);
                }

                var winners = new List<int>();
                foreach (var queryFeature in queryFeaturesSet)
                {
                    networkHelper._som.Compute(queryFeature);
                    var w = networkHelper._som.GetWinner();
                    winners.Add(w);
                }

                var winner = resource.GetWinningPerson(winners);
                var formattedWinnerWithParams = string.Format(@"{0};{1};{2};{3};{4};{5};{6};{7}", winner,
                    currentParams.LearningRadius, currentParams.LearningRate, currentParams.Iterations,
                    currentParams.AngleMultiplier,
                    currentParams.TypeMultiplier, currentParams.CoordsMultiplier,
                    currentParams.HashCodeMultiplier);

                _winnersList.TryAdd(formattedWinnerWithParams);
            });

            SaveResults();
        }