public static SearchStatistics GetSearchStatistics(int clientId, string searchText, DateTime from, DateTime to, int currentSellerID) { var dataRecord = DB.GetSearchStatistics(clientId, searchText, from, to, currentSellerID); var searchStat = new SearchStatistics(dataRecord); return(searchStat); }
private void OnSearchUpdate(object sender, SearchStatistics stats) { var score = FormatScore(stats.Score); var principalVariation = FormatPrincipalVariation(stats.PrincipalVariation, stats.PrincipalVariationMovesCount); Send($"info depth {stats.Depth} seldepth {stats.SelectiveDepth} time {stats.SearchTime} " + $"score {score} nodes {stats.TotalNodes} nps {stats.TotalNodesPerSecond} pv {principalVariation}"); if (_debugMode) { var evaluationStatistics = new EvaluationStatistics(); var openingPhase = stats.Board.GetPhaseRatio(); var endingPhase = BoardConstants.PhaseResolution - openingPhase; var fieldsAttackedByWhite = 0ul; var fieldsAttackedByBlack = 0ul; var materialEvaluation = MaterialEvaluator.Evaluate(stats.Board); var castlingEvaluation = CastlingEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var positionEvaluation = PositionEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var pawnStructureEvaluation = PawnStructureEvaluator.Evaluate(stats.Board, evaluationStatistics, openingPhase, endingPhase); var mobility = MobilityEvaluator.Evaluate(stats.Board, openingPhase, endingPhase, ref fieldsAttackedByWhite, ref fieldsAttackedByBlack); var kingSafety = KingSafetyEvaluator.Evaluate(stats.Board, openingPhase, endingPhase, fieldsAttackedByWhite, fieldsAttackedByBlack); var pieces = PiecesEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var fianchetto = FianchettoEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var total = materialEvaluation + castlingEvaluation + positionEvaluation + pawnStructureEvaluation + mobility + kingSafety + pieces; Send($"info string evaluation {total} phase {openingPhase} material {materialEvaluation} castling {castlingEvaluation} " + $"position {positionEvaluation} pawns {pawnStructureEvaluation} mobility {mobility} ksafety {kingSafety} " + $"pieces {pieces} fianchetto {fianchetto} irrmoves {stats.Board.IrreversibleMovesCount}"); } }
public async Task AddSameTags_ValuesIncrementedProperly() { var db = new StatisticsDatabase(Settings); StatisticsService service = new StatisticsService(db, new Mapper(MappingConfigurationFactory.Create())); string organizationOne = Guid.NewGuid().ToString(); string repoOne = Guid.NewGuid().ToString(); var parameter = new RepositoryQueryParameter(organizationOne, repoOne); string[] words = new[] { "FirstTag", "SecondTag", "Third" }; SearchStatistics stats1 = await service.Update(parameter, words).ConfigureAwait(false); SearchStatistics stats2 = await service.Update(parameter, words).ConfigureAwait(false); stats1.RepositoryName.Should().Be(stats2.RepositoryName); stats1.SearchKeywordData.Count.Should().Be(3); foreach (SearchKeywordData searchKeywordData in stats1.SearchKeywordData) { Assert.AreEqual(1, searchKeywordData.SearchCount); } stats2.SearchKeywordData.Count.Should().Be(3); foreach (SearchKeywordData searchKeywordData in stats2.SearchKeywordData) { Assert.AreEqual(2, searchKeywordData.SearchCount); } }
private void IterativeDeepening_OnSearchUpdate(object sender, SearchStatistics statistics) { // Main search result _interactiveConsole.WriteLine($" === Depth: {statistics.Depth}, Score: {statistics.Score}, Best: {statistics.PrincipalVariation[0]}, " + $"Time: {((float) statistics.SearchTime / 1000):F} s"); // Normal search _interactiveConsole.WriteLine($" Normal search: Nodes: {statistics.Nodes}, Leafs: {statistics.Leafs}, " + $"Branching factor: {statistics.BranchingFactor:F}, Beta cutoffs: {statistics.BetaCutoffs}"); // Quiescence search _interactiveConsole.WriteLine($" Q search: Nodes: {statistics.QNodes}, Leafs: {statistics.QLeafs}, " + $"Branching factor: {statistics.QBranchingFactor:F}, Beta cutoffs: {statistics.QBetaCutoffs}"); // Total _interactiveConsole.WriteLine($" Total: Nodes: {statistics.TotalNodes} ({((float)statistics.TotalNodesPerSecond / 1000000):F} MN/s), " + $"Leafs: {statistics.TotalLeafs}, Branching factor: {statistics.TotalBranchingFactor:F}, " + $"Beta cutoffs: {statistics.TotalBetaCutoffs}"); #if DEBUG // Beta cutoffs at first move _interactiveConsole.WriteLine($" Beta cutoffs at first move: {statistics.BetaCutoffsAtFirstMove} ({statistics.BetaCutoffsAtFirstMovePercent:F} %), " + $"Q Beta cutoffs at first move: {statistics.QBetaCutoffsAtFirstMove} ({statistics.QBetaCutoffsAtFirstMovePercent:F} %)"); // Transposition statistics _interactiveConsole.WriteLine($" TT: " + $"Added: {statistics.TTAddedEntries}, " + $"Replacements: {statistics.TTReplacements} ({statistics.TTReplacesPercent:F} %), " + $"Hits: {statistics.TTHits} ({statistics.TTHitsPercent:F} %), " + $"Missed: {statistics.TTNonHits}, " + $"Filled: {TranspositionTable.GetFillLevel():F} %"); // Pawn hash table statistics _interactiveConsole.WriteLine($" PHT: " + $"Added: {statistics.EvaluationStatistics.PHTAddedEntries}, " + $"Replacements: {statistics.EvaluationStatistics.PHTReplacements} ({statistics.EvaluationStatistics.PHTReplacesPercent:F} %), " + $"Hits: {statistics.EvaluationStatistics.PHTHits} ({statistics.EvaluationStatistics.PHTHitsPercent:F} %), " + $"Missed: {statistics.EvaluationStatistics.PHTNonHits}, " + $"Filled: {PawnHashTable.GetFillLevel():F} %"); // Evaluation hash table statistics _interactiveConsole.WriteLine($" EHT: " + $"Added: {statistics.EvaluationStatistics.EHTAddedEntries}, " + $"Replacements: {statistics.EvaluationStatistics.EHTReplacements} ({statistics.EvaluationStatistics.EHTReplacesPercent:F} %), " + $"Hits: {statistics.EvaluationStatistics.EHTHits} ({statistics.EvaluationStatistics.EHTHitsPercent:F} %), " + $"Missed: {statistics.EvaluationStatistics.EHTNonHits}, " + $"Filled: {EvaluationHashTable.GetFillLevel():F} %"); _interactiveConsole.WriteLine($" Valid TT moves: {statistics.TTValidMoves}, Invalid TT moves: {statistics.TTInvalidMoves}, " + $"IID hits: {statistics.IIDHits}, Loud generations: {statistics.LoudMovesGenerated}, " + $"Quiet generations: {statistics.QuietMovesGenerated}"); #endif _interactiveConsole.WriteLine(); }
public ProbabilityLimitedExpectiMaxer(ISearchTree searchTree, double minProbability = 0.004, int maxSearchDepth = 6) { this.searchTree = searchTree; this.minProbability = minProbability; this.maxSearchDepth = maxSearchDepth; this.searchStatistics = new SearchStatistics { RootNodeGrandchildren = this.searchTree.RootNode.Children.Values.Sum(c => c.Children.Count()) }; }
public SearchStatistics WordCount(string wordToFind, string textFile) { var results = new SearchStatistics(); if (wordToFind != null && textFile != null) { var words = textFile.Split(' ', '.', ',', '(', ')', '"', '?', '!'); var find = words.Count(c => c == wordToFind.ToLower()); results.NumberOfMatches = find; results.TotalWords = words.Count(); } return(results); }
public async Task SaveSearchTerms(string searchParam) { var currentTimestamp = DateTime.Now; var rijeci = Regex.Matches(searchParam, @"[^\W\d][\w'-]*(?<=\w)").ToList(); foreach (var rijec in rijeci) { var searchStatistics = new SearchStatistics { Search = rijec.ToString(), Timestamp = currentTimestamp }; await applicationDbContext.SearchStatistics.AddAsync(searchStatistics); } await applicationDbContext.SaveChangesAsync(); }
public static string Search(string filePath, string word, out SearchStatistics stat) { stat = new SearchStatistics(); using (var tokenizer = new Tokenizer(filePath)) { while (true) { Tokenizer.Token key = tokenizer.GetNextToken(); stat.LogRecordRead(); Tokenizer.Token delimiter = tokenizer.GetNextToken(); if (delimiter.Type != Tokenizer.TokenType.Delimiter) { throw new Exception("Syntax error: required delimiter"); } Tokenizer.Token value = tokenizer.GetNextToken(); if (key.String.Equals(word, StringComparison.CurrentCultureIgnoreCase)) { return(value.String); } Tokenizer.Token nextToken = tokenizer.GetNextToken(); if (nextToken.Type == Tokenizer.TokenType.Eof) { break; } if (nextToken.Type != Tokenizer.TokenType.Comma) { throw new Exception("Syntax error: comma required"); } } } return(null); }
/// <summary> /// Update the stats for the searched domain /// </summary> /// <param name="domain"></param> public async void UpdateSearchStats(string LotteryId) { SearchStatistics statsToUpdate = null; IQueryable <SearchStatistics> query = null; try { if (LotteryId != null) { //Define the query to get the stats query = makeQuery(LotteryId); //Get the statistic for the domain statsToUpdate = query.FirstOrDefault(); //Increment the total times searched if there is history if (statsToUpdate != null) { statsToUpdate.TotalTimesSearched++; _context.SearchStatistics.Update(statsToUpdate); } else //This is a new domain { statsToUpdate = new SearchStatistics(); statsToUpdate.SearchStatisticId = Guid.NewGuid(); statsToUpdate.LotteryId = LotteryId; //Start the total searches at 1 since it was currently being searched statsToUpdate.TotalTimesSearched = 1; _context.SearchStatistics.Add(statsToUpdate); } //Save changes await _context.SaveChangesAsync(); } } catch (Exception ex) { Console.WriteLine(ex); } }
internal static ActionResult GetBasicSearchSettings(dynamic AvailableAnalyzers) { ActionResult actionResult = new ActionResult(); try { dynamic settings = new ExpandoObject(); settings.MinWordLength = HostController.Instance.GetInteger("Search_MinKeyWordLength", 3); settings.MaxWordLength = HostController.Instance.GetInteger("Search_MaxKeyWordLength", 255); settings.AllowLeadingWildcard = HostController.Instance.GetString("Search_AllowLeadingWildcard", "N") == "Y"; settings.SearchCustomAnalyzer = HostController.Instance.GetString("Search_CustomAnalyzer", string.Empty); settings.TitleBoost = HostController.Instance.GetInteger(SearchTitleBoostSetting, DefaultSearchTitleBoost); settings.TagBoost = HostController.Instance.GetInteger(SearchTagBoostSetting, DefaultSearchTagBoost); settings.ContentBoost = HostController.Instance.GetInteger(SearchContentBoostSetting, DefaultSearchContentBoost); settings.DescriptionBoost = HostController.Instance.GetInteger(SearchDescriptionBoostSetting, DefaultSearchDescriptionBoost); settings.AuthorBoost = HostController.Instance.GetInteger(SearchAuthorBoostSetting, DefaultSearchAuthorBoost); settings.SearchIndexPath = Path.Combine(Globals.ApplicationMapPath, HostController.Instance.GetString("SearchFolder", @"App_Data\Search")); SearchStatistics searchStatistics = GetSearchStatistics(); if (searchStatistics != null) { settings.SearchIndexDbSize = ((searchStatistics.IndexDbSize / 1024f) / 1024f).ToString("N") + " MB"; settings.SearchIndexLastModifedOn = DateUtils.CalculateDateForDisplay(searchStatistics.LastModifiedOn); settings.SearchIndexTotalActiveDocuments = searchStatistics.TotalActiveDocuments.ToString(CultureInfo.InvariantCulture); settings.SearchIndexTotalDeletedDocuments = searchStatistics.TotalDeletedDocuments.ToString(CultureInfo.InvariantCulture); } SiteSettingsController _controller = new SiteSettingsController(); var response = new { Success = true, Settings = settings, SearchCustomAnalyzers = AvailableAnalyzers }; actionResult.Data = settings; } catch (Exception exc) { actionResult.AddError("HttpStatusCode.InternalServerError", exc.Message); } return(actionResult); }
private void OnSearchUpdate(object sender, SearchStatistics stats) { var score = FormatScore(stats.Score); var principalVariation = FormatPrincipalVariation(stats.PrincipalVariation, stats.PrincipalVariationMovesCount); Send($"info depth {stats.Depth} seldepth {stats.SelectiveDepth} time {stats.SearchTime} " + $"score {score} nodes {stats.TotalNodes} nps {stats.TotalNodesPerSecond} pv {principalVariation}"); if (_debugMode && stats.PrincipalVariationMovesCount > 0 && stats.PrincipalVariation[0] != Move.Empty) { var sign = stats.Board.ColorToMove == Color.White ? 1 : -1; stats.Board.MakeMove(stats.PrincipalVariation[0]); var evaluationStatistics = new EvaluationStatistics(); var openingPhase = stats.Board.GetPhaseRatio(); var endingPhase = BoardConstants.PhaseResolution - openingPhase; var fieldsAttackedByWhite = 0ul; var fieldsAttackedByBlack = 0ul; var materialEvaluation = sign * MaterialEvaluator.Evaluate(stats.Board); var positionEvaluation = sign * PositionEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var pawnStructureEvaluation = sign * PawnStructureEvaluator.Evaluate(stats.Board, evaluationStatistics, openingPhase, endingPhase); var mobility = sign * MobilityEvaluator.Evaluate(stats.Board, openingPhase, endingPhase, ref fieldsAttackedByWhite, ref fieldsAttackedByBlack); var kingSafety = sign * KingSafetyEvaluator.Evaluate(stats.Board, openingPhase, endingPhase, fieldsAttackedByWhite, fieldsAttackedByBlack); var rooks = sign * RookEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var bishops = sign * BishopEvaluator.Evaluate(stats.Board, openingPhase, endingPhase); var total = materialEvaluation + positionEvaluation + pawnStructureEvaluation + mobility + kingSafety; Send($"info string evaluation {total} phase {openingPhase} material {materialEvaluation} " + $"position {positionEvaluation} pawns {pawnStructureEvaluation} mobility {mobility} ksafety {kingSafety} " + $"rooks {rooks} bishops {bishops} irrmoves {stats.Board.IrreversibleMovesCount}"); stats.Board.UndoMove(stats.PrincipalVariation[0]); } }