public IMovieList ChooseBest() { int exponent = _baselineMovies.Count(item => item.AdjustEarnings); int toRaise = (int)(EarningsAdjustmentMax / EarningsAdjustment) * 2 + 1; _elapsed.Max = Math.Pow(toRaise, exponent); var movieLists = GenerateMovieLists(new List <IMovie>(), _baselineMovies); _logMessagesCount = 0; TotalMovieLists = movieLists.Count; _elapsed.Current = 0; _elapsed.Max = TotalMovieLists; _elapsed.Start(); // Walk through the movie list adjusting the movies by the variant and then choose the best. foreach (var movieList in movieLists) { _moviePicker.AddMovies(movieList); if (CanLog) { // Only display this progress every LogMessagesMax time LogMovieList($"{nameof(ChooseBest)} - {_logMessagesCount}/{TotalMovieLists} - ", movieList); } _logMessagesCount++; _elapsed.Current = _logMessagesCount; var best = _moviePicker.ChooseBest(); var hashCode = best.GetHashCode(); int value; TotalComparisons += _moviePicker.TotalComparisons; TotalSubProblems += (_moviePicker.TotalSubProblems == 0) ? 1 : _moviePicker.TotalSubProblems; // Increment (or add to) the best list counts if (_bestListCounts.TryGetValue(hashCode, out value)) { _bestListCounts[hashCode] = value + 1; } else { _bestListCounts.Add(hashCode, 1); _bestLists.Add(hashCode, best); } } // Sort through the MOST times a list is counted. var bestHash = _bestListCounts.OrderByDescending(item => item.Value).First().Key; return(_bestLists[bestHash]); }
private void SetButton() { if (_isPlaying) { PlayBtn.Text = "||"; ElapsedTime.Start(); } else { PlayBtn.Text = ">"; ElapsedTime.Stop(); } }
public void StartAut() { Aut.Start(); ElapsedTime.Start(); if (SystemInfo.GetAffinity() != null) { Aut.ProcessorAffinity = SystemInfo.GetAffinity().Value; } Aut.PriorityClass = Enum.Parse <ProcessPriorityClass>(ArgumentParser.AutPriority); Aut.BeginOutputReadLine(); Aut.BeginErrorReadLine(); log.Info($"AUT has been started. Starting time: {Aut.StartTime}"); log.Info($"AUT Input arguments: {AutStartInfo.Arguments}"); log.Info($"AUT Main Thread ID: {Aut.Id}"); log.Info($"AUT Process priority: {Aut.PriorityClass}"); }