Пример #1
0
void SearchFilterByModuleList::Search(Searcher &searcher) {
  if (!m_target_sp)
    return;

  if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
    SymbolContext empty_sc;
    empty_sc.target_sp = m_target_sp;
    searcher.SearchCallback(*this, empty_sc, nullptr, false);
  }

  // If the module file spec is a full path, then we can just find the one
  // filespec that passes.  Otherwise, we need to go through all modules and
  // find the ones that match the file name.

  const ModuleList &target_modules = m_target_sp->GetImages();
  std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());

  const size_t num_modules = target_modules.GetSize();
  for (size_t i = 0; i < num_modules; i++) {
    Module *module = target_modules.GetModulePointerAtIndexUnlocked(i);
    if (m_module_spec_list.FindFileIndex(0, module->GetFileSpec(), false) !=
        UINT32_MAX) {
      SymbolContext matchingContext(m_target_sp, module->shared_from_this());
      Searcher::CallbackReturn shouldContinue;

      shouldContinue = DoModuleIteration(matchingContext, searcher);
      if (shouldContinue == Searcher::eCallbackReturnStop)
        return;
    }
  }
}
Пример #2
0
Searcher::CallbackReturn
SearchFilter::DoCUIteration(const ModuleSP &module_sp,
                            const SymbolContext &context, Searcher &searcher) {
  Searcher::CallbackReturn shouldContinue;
  if (context.comp_unit == nullptr) {
    const size_t num_comp_units = module_sp->GetNumCompileUnits();
    for (size_t i = 0; i < num_comp_units; i++) {
      CompUnitSP cu_sp(module_sp->GetCompileUnitAtIndex(i));
      if (cu_sp) {
        if (!CompUnitPasses(*(cu_sp.get())))
          continue;

        if (searcher.GetDepth() == Searcher::eDepthCompUnit) {
          SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get());

          shouldContinue =
              searcher.SearchCallback(*this, matchingContext, nullptr, false);

          if (shouldContinue == Searcher::eCallbackReturnPop)
            return Searcher::eCallbackReturnContinue;
          else if (shouldContinue == Searcher::eCallbackReturnStop)
            return shouldContinue;
        } else {
          // FIXME Descend to block.
        }
      }
    }
  } else {
    if (CompUnitPasses(*context.comp_unit)) {
      SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit);
      return searcher.SearchCallback(*this, matchingContext, nullptr, false);
    }
  }
  return Searcher::eCallbackReturnContinue;
}
Пример #3
0
void CustomTabWidget::clear_reserve_contragent(){
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        s->clear_reserve_contragent();
    }
}
Пример #4
0
void CustomTabWidget::refresh_white_searcher(){
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        s->refresh_white_table();
    }
}
Пример #5
0
void CustomTabWidget::switch_hidden(){
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        s->switch_hidden();
    }
}
Пример #6
0
void CustomTabWidget::set_reserve_contragent(int id, QString name){
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        s->set_reserve_contragent(id, name);
    }
}
Пример #7
0
int search(int argc, char *argv[])
{
	Searcher searcher;

	if (searcher.load(argv[2]) == false)
	{
		cout << "Unable to load index file - file does not exist or is corrupt.\n";
		return -1;
	}

	cout << "Successfully loaded index file.\n";
	std::string query;

	for (;;)
	{
		cout << "Enter your search terms: ";
		getline(cin, query);
		if (query.empty())
			break;

		auto results = searcher.search(query);
		if (results.size() == 0)
			cout << "No results found\n";
		else
		{
			cout << "\n" << results.size() << " matches found:\n";
			for (size_t i = 0; i<results.size(); i++)
				cout << results[i] << endl;
		}
		cout << endl;
	}

	return 0;
}
Пример #8
0
void
SearchFilterByModule::Search (Searcher &searcher)
{
    if (!m_target_sp)
        return;

    if (searcher.GetDepth() == Searcher::eDepthTarget)
    {
        SymbolContext empty_sc;
        empty_sc.target_sp = m_target_sp;
        searcher.SearchCallback (*this, empty_sc, NULL, false);
    }

    // If the module file spec is a full path, then we can just find the one
    // filespec that passes.  Otherwise, we need to go through all modules and
    // find the ones that match the file name.

    ModuleList matching_modules;
    const size_t num_modules = m_target_sp->GetImages().GetSize ();
    for (size_t i = 0; i < num_modules; i++)
    {
        Module* module = m_target_sp->GetImages().GetModulePointerAtIndex(i);
        if (FileSpec::Compare (m_module_spec, module->GetFileSpec(), false) == 0)
        {
            SymbolContext matchingContext(m_target_sp, module->GetSP());
            Searcher::CallbackReturn shouldContinue;

            shouldContinue = DoModuleIteration(matchingContext, searcher);
            if (shouldContinue == Searcher::eCallbackReturnStop)
                return;
        }
    }
}
Пример #9
0
void
SearchFilter::SearchInModuleList (Searcher &searcher, ModuleList &modules)
{
    SymbolContext empty_sc;

    if (m_target_sp == NULL)
        return;
    empty_sc.target_sp = m_target_sp;

    if (searcher.GetDepth() == Searcher::eDepthTarget)
        searcher.SearchCallback (*this, empty_sc, NULL, false);
    else
    {
        const size_t numModules = modules.GetSize();

        for (size_t i = 0; i < numModules; i++)
        {
            ModuleSP module_sp(modules.GetModuleAtIndex(i));
            if (ModulePasses(module_sp))
            {
                if (DoModuleIteration(module_sp, searcher) == Searcher::eCallbackReturnStop)
                    return;
            }
        }
    }
}
Пример #10
0
void nn_search(Searcher& searcher, double* const nn, double* const dists, const long R, const long N,
				const long dim, const double* p, const double* ref, const long NNR, const mmatrix& past, const double epsilon,
				const int ref_or_direct)
{	
	if (searcher.geterr()) {
		mexErrMsgTxt("Error preparing searcher, maybe wrong preprocessing data were given or the point set has changed");
	}	 
	
	double*	const coord = (double*) malloc(dim * sizeof(double)); 	
	
	for (long n=0; n < R; n++) { /* iterate over all reference points */ 
		vector<neighbor> v;
		
		if (ref_or_direct) {
			const long actual = int(ref[n])-1;		// Matlab to C means indices change from 1 to 0, 2 to 1, 3 to 2
			for (long k=0; k < dim; k++) 
				coord[k] = p[actual+k*N];

			searcher.search_k_neighbors(v, NNR, coord, (long) past(n+1,1)-1, (long) past(n+1,2)-1, epsilon);
		} else {
			for (long k=0; k < dim; k++) 
				coord[k] = ref[n+k*R];

			searcher.search_k_neighbors(v, NNR, coord, (long) past(n+1,1)-1, (long) past(n+1,2)-1, epsilon);
		}	
		
		for (long k = 0; k < v.size(); k++) { 	// v is the sorted vector of neighbors
				nn[n+k*R] = v[k].index() +1;	// convert indices back to Matlab (1..N) style 
				dists[n+k*R] = v[k].dist();
		}
	}
	
	free(coord);
}
Пример #11
0
void SearcherTest::testLocationToNodeReturnsCorrectNode(Searcher searcher) {
	int* location = new int[2];
	location[0] = 0; location[1] = 0;  assert(searcher.locationToNode(location) == 0);
	location[0] = 2; location[1] = 12; assert(searcher.locationToNode(location) == 38);
	location[0] = 3; location[1] = 0;  assert(searcher.locationToNode(location) == 39);
	location[0] = 4; location[1] = 7;  assert(searcher.locationToNode(location) == 59);
	location[0] = 7; location[1] = 12; assert(searcher.locationToNode(location) == 103);
}
Пример #12
0
void
SearchFilterByModuleListAndCU::Search (Searcher &searcher)
{
    if (!m_target_sp)
        return;

    if (searcher.GetDepth() == Searcher::eDepthTarget)
    {
        SymbolContext empty_sc;
        empty_sc.target_sp = m_target_sp;
        searcher.SearchCallback (*this, empty_sc, NULL, false);
    }

    // If the module file spec is a full path, then we can just find the one
    // filespec that passes.  Otherwise, we need to go through all modules and
    // find the ones that match the file name.

    ModuleList matching_modules;
    ModuleList &target_images = m_target_sp->GetImages();
    Mutex::Locker modules_locker(target_images.GetMutex());
    
    const size_t num_modules = target_images.GetSize ();
    bool no_modules_in_filter = m_module_spec_list.GetSize() == 0;
    for (size_t i = 0; i < num_modules; i++)
    {
        lldb::ModuleSP module_sp = target_images.GetModuleAtIndexUnlocked(i);
        if (no_modules_in_filter || m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) != UINT32_MAX)
        {
            SymbolContext matchingContext(m_target_sp, module_sp);
            Searcher::CallbackReturn shouldContinue;

            if (searcher.GetDepth() == Searcher::eDepthModule)
            {
                shouldContinue = DoModuleIteration(matchingContext, searcher);
                if (shouldContinue == Searcher::eCallbackReturnStop)
                    return;
            }
            else
            {
                const size_t num_cu = module_sp->GetNumCompileUnits();
                for (size_t cu_idx = 0; cu_idx < num_cu; cu_idx++)
                {
                    CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(cu_idx);
                    matchingContext.comp_unit = cu_sp.get();
                    if (matchingContext.comp_unit)
                    {
                        if (m_cu_spec_list.FindFileIndex(0, *matchingContext.comp_unit, false) != UINT32_MAX)
                        {
                            shouldContinue = DoCUIteration(module_sp, matchingContext, searcher);
                            if (shouldContinue == Searcher::eCallbackReturnStop)
                                return;
                        }
                    }
                }
            }
        }
    }
}
Пример #13
0
Searcher::CallbackReturn
SearchFilter::DoCUIteration(const ModuleSP &module_sp,
                            const SymbolContext &context, Searcher &searcher) {
  Searcher::CallbackReturn shouldContinue;
  if (context.comp_unit == nullptr) {
    const size_t num_comp_units = module_sp->GetNumCompileUnits();
    for (size_t i = 0; i < num_comp_units; i++) {
      CompUnitSP cu_sp(module_sp->GetCompileUnitAtIndex(i));
      if (cu_sp) {
        if (!CompUnitPasses(*(cu_sp.get())))
          continue;

        if (searcher.GetDepth() == lldb::eSearchDepthCompUnit) {
          SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get());

          shouldContinue =
              searcher.SearchCallback(*this, matchingContext, nullptr, false);

          if (shouldContinue == Searcher::eCallbackReturnPop)
            return Searcher::eCallbackReturnContinue;
          else if (shouldContinue == Searcher::eCallbackReturnStop)
            return shouldContinue;
        } else {
          // First make sure this compile unit's functions are parsed
          // since CompUnit::ForeachFunction only iterates over already
          // parsed functions.
          SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
          if (!sym_vendor)
            continue;
          if (!sym_vendor->ParseFunctions(*cu_sp))
            continue;
          // If we got any functions, use ForeachFunction to do the iteration.
          cu_sp->ForeachFunction([&](const FunctionSP &func_sp) {
            if (!FunctionPasses(*func_sp.get()))
              return false; // Didn't pass the filter, just keep going.
            if (searcher.GetDepth() == lldb::eSearchDepthFunction) {
              SymbolContext matchingContext(m_target_sp, module_sp, 
                                            cu_sp.get(), func_sp.get());
              shouldContinue = searcher.SearchCallback(*this, 
                                                       matchingContext, 
                                                       nullptr, false);
            } else {
              shouldContinue = DoFunctionIteration(func_sp.get(), context, 
                                                   searcher);
            }
            return shouldContinue != Searcher::eCallbackReturnContinue;
          });
        }
      }
    }
  } else {
    if (CompUnitPasses(*context.comp_unit)) {
      SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit);
      return searcher.SearchCallback(*this, matchingContext, nullptr, false);
    }
  }
  return Searcher::eCallbackReturnContinue;
}
Пример #14
0
Searcher::CallbackReturn
SearchFilter::DoModuleIteration (const SymbolContext &context, Searcher &searcher)
{
    Searcher::CallbackReturn shouldContinue;

    if (searcher.GetDepth () >= Searcher::eDepthModule)
    {
        if (!context.module_sp)
        {
            ModuleList &target_images = m_target_sp->GetImages();
            Mutex::Locker modules_locker(target_images.GetMutex());
            
            size_t n_modules = target_images.GetSize();
            for (size_t i = 0; i < n_modules; i++)
            {
                // If this is the last level supplied, then call the callback directly,
                // otherwise descend.
                ModuleSP module_sp(target_images.GetModuleAtIndexUnlocked (i));
                if (!ModulePasses (module_sp))
                    continue;

                if (searcher.GetDepth () == Searcher::eDepthModule)
                {
                    SymbolContext matchingContext(m_target_sp, module_sp);

                    shouldContinue = searcher.SearchCallback (*this, matchingContext, NULL, false);
                    if (shouldContinue == Searcher::eCallbackReturnStop
                        || shouldContinue == Searcher::eCallbackReturnPop)
                        return shouldContinue;
                }
                else
                {
                    shouldContinue = DoCUIteration(module_sp, context, searcher);
                    if (shouldContinue == Searcher::eCallbackReturnStop)
                        return shouldContinue;
                    else if (shouldContinue == Searcher::eCallbackReturnPop)
                        continue;
                }
            }
        }
        else
        {
            if (searcher.GetDepth () == Searcher::eDepthModule)
            {
                SymbolContext matchingContext(context.module_sp.get());

                shouldContinue = searcher.SearchCallback (*this, matchingContext, NULL, false);
            }
            else
            {
                return DoCUIteration(context.module_sp, context, searcher);
            }
        }

    }
    return Searcher::eCallbackReturnContinue;
}
Пример #15
0
void CustomTabWidget::save_searcher_order(int mode, int logical, int newvisual){
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        if(mode == 0) s->restore_white_order(logical, newvisual);
        else if(mode == 1) s->restore_grey_order(logical, newvisual);
        else if(mode == 2) s->restore_manager_reserve_order(logical, newvisual);
    }
}
Пример #16
0
void CustomTabWidget::save_searcher_width(int mode, int index, int width){
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        if(mode == 0) s->restore_white_width(index, width);
        else if(mode == 1) s->restore_grey_width(index, width);
        else if(mode == 2) s->restore_manager_reserve_width(index, width);
    }
}
Пример #17
0
void CustomTabWidget::switch_reserves(){
    searcher_show_reserve = !searcher_show_reserve;
    //qDebug() << searcher_show_reserve;
    Searcher *s;
    for(int i = 0; i < this->count(); i++){
        s = static_cast<Searcher*>(this->widget(i));
        s->switch_reserves();
    }
}
Пример #18
0
void SearchFilter::Search(Searcher &searcher) {
  SymbolContext empty_sc;

  if (!m_target_sp)
    return;
  empty_sc.target_sp = m_target_sp;

  if (searcher.GetDepth() == lldb::eSearchDepthTarget)
    searcher.SearchCallback(*this, empty_sc, nullptr, false);
  else
    DoModuleIteration(empty_sc, searcher);
}
Пример #19
0
    void search(const Rect& rect, Searcher& search) const
    {
        /*if (rect.contains(bounds) && childrenPoints.size() >= search.searchSize()) {
        pushChildrenPointsUnchecked(rect, search);
        return;
        }*/

        for (auto p = points, end = points + pointCount; p < end; p++) {
            if (p->rank > search.maxAcceptedRank())
                break; // nothing to do here anymore
            if (rect.contains(p))
                search.pushResult(p);
        }

        if (others[0] != others[1])
        {
            if (level & 1)
            {
                if (others[0]->minRank <= others[1]->minRank)
                {
                    if (rect.lx <= middle && others[0]->minRank < search.maxAcceptedRank())
                        others[0]->search(rect, search);
                    if (rect.hx >= middle && others[1]->minRank < search.maxAcceptedRank())
                        others[1]->search(rect, search);
                }
                else
                {
                    if (rect.hx >= middle && others[1]->minRank < search.maxAcceptedRank())
                        others[1]->search(rect, search);
                    if (rect.lx <= middle && others[0]->minRank < search.maxAcceptedRank())
                        others[0]->search(rect, search);
                }
            }
            else
            {
                if (others[0]->minRank <= others[1]->minRank)
                {
                    if (rect.ly <= middle && others[0]->minRank < search.maxAcceptedRank())
                        others[0]->search(rect, search);
                    if (rect.hy >= middle && others[1]->minRank < search.maxAcceptedRank())
                        others[1]->search(rect, search);
                }
                else
                {
                    if (rect.hy >= middle && others[1]->minRank < search.maxAcceptedRank())
                        others[1]->search(rect, search);
                    if (rect.ly <= middle && others[0]->minRank < search.maxAcceptedRank())
                        others[0]->search(rect, search);
                }
            }
        }
    }
Пример #20
0
void
SearchFilter::Search (Searcher &searcher)
{
    SymbolContext empty_sc;

    if (m_target_sp == NULL)
        return;
    empty_sc.target_sp = m_target_sp;

    if (searcher.GetDepth() == Searcher::eDepthTarget)
        searcher.SearchCallback (*this, empty_sc, NULL, false);
    else
        DoModuleIteration(empty_sc, searcher);
}
Пример #21
0
void SearcherTest::run() {
	Searcher searcher = Searcher(mapSize, mapData);
	std::string algorithm = "Dijkstra's algorithm";
	for (int i = 0; i < 2; i++) {
		if (i == 1) searcher = Searcher(mapSize, mapData);
		searcher.setStartNode(startLocation);
		searcher.setEndNode(endLocation);
		if (i == 1) algorithm = "A*";
		testSearchLeadsToCorrectSolution(searcher, algorithm);
	}
	testLocationToNodeReturnsCorrectNode(searcher);
	testNodeToLocationReturnsCorrectLocation(searcher);
	testInitializeSingleSourceSetsDistanceAndPathRight(searcher);
}
Пример #22
0
void SearcherTest::testNodeToLocationReturnsCorrectLocation(Searcher searcher) {
	assert(searcher.nodeToLocation(0)[0] == 0   && searcher.nodeToLocation(0)[1] == 0);
	assert(searcher.nodeToLocation(15)[0] == 1  && searcher.nodeToLocation(15)[1] == 2);
	assert(searcher.nodeToLocation(42)[0] == 3  && searcher.nodeToLocation(42)[1] == 3);
	assert(searcher.nodeToLocation(71)[0] == 5  && searcher.nodeToLocation(71)[1] == 6);
	assert(searcher.nodeToLocation(101)[0] == 7 && searcher.nodeToLocation(101)[1] == 10);
}
Пример #23
0
void SearcherTest::testInitializeSingleSourceSetsDistanceAndPathRight(Searcher searcher) {
	searcher.initializeSingleSource();
	int* path = searcher.getPath();
	int* distance = searcher.getDistance();
	int inf = infinity;
	for (int row = 0; row < 8; row++) {
		for (int col = 0; col < 13; col++) {
			int location[2] = {row, col};
			int node = searcher.locationToNode(location);
			assert(path[node] == -1);
			if (row == startLocation[0] && col == startLocation[1]) assert(distance[node] == 0);
			else assert(distance[node] == inf);
		}
	}
}
Пример #24
0
Searcher *klee::constructUserSearcher(Executor &executor) {

  // default values
  if (CoreSearch.size() == 0) {
    CoreSearch.push_back(Searcher::RandomPath);
    CoreSearch.push_back(Searcher::NURS_CovNew);
  }

  Searcher *searcher = getNewSearcher(CoreSearch[0], executor);
  
  if (CoreSearch.size() > 1) {
    std::vector<Searcher *> s;
    s.push_back(searcher);

    for (unsigned i=1; i<CoreSearch.size(); i++)
      s.push_back(getNewSearcher(CoreSearch[i], executor));
    
    searcher = new InterleavedSearcher(s);
  }

  if (UseBatchingSearch) {
    searcher = new BatchingSearcher(searcher, BatchTime, BatchInstructions);
  }

  // merge support is experimental
  if (UseMerge) {
    assert(!UseBumpMerge);
    assert(std::find(CoreSearch.begin(), CoreSearch.end(), Searcher::RandomPath) == CoreSearch.end()); // XXX: needs further debugging: test/Features/Searchers.c fails with this searcher
    searcher = new MergingSearcher(executor, searcher);
  } else if (UseBumpMerge) {
    searcher = new BumpMergingSearcher(executor, searcher);
  }
  
  if (UseIterativeDeepeningTimeSearch) {
    searcher = new IterativeDeepeningTimeSearcher(searcher);
  }

  llvm::raw_ostream &os = executor.getHandler().getInfoStream();

  os << "BEGIN searcher description\n";
  searcher->printName(os);
  os << "END searcher description\n";

  return searcher;
}
Пример #25
0
int main()
{
    std::vector <Pair> ghostery_mock = {{0, "doubleclick.com"}, {1, "advertising.com"}, {2, "valueclick.com"}};
    Searcher mysearcher = Searcher(ghostery_mock);
    std::vector <int> res;
    res = mysearcher.search("doubleclick.com/blah?click=advertising.com");

  std::vector <Pair> bigtest_mock;

  std::string line;
  std::ifstream fp ("/usr/share/dict/words");
  int cnt = 0;
  if (fp.is_open())
  {
    while ( fp.good() )
    {
      getline (fp,line);
      Pair line_pair = Pair(cnt, line);

      bigtest_mock.push_back(line_pair);
      cnt+=1;
    }
    fp.close();
  }else{
   std::cout << "Unable to open file"; 
  }

  mysearcher = Searcher(bigtest_mock);
  #define MAX_RUNS 1000

  clock_t start_time = clock();

  fp.seekg(0);
  for(int i = 0; i < MAX_RUNS; i++)
  {
    std::string word;
    getline (fp,word);
    mysearcher.search(word);
  }
  clock_t end_time = clock();
  std::cout <<  "Searching inside of the dictionary took: " << (end_time- start_time)/float(CLOCKS_PER_SEC) << std::endl;

  return 0;
}
Пример #26
0
int main(int argc, char *argv[]) {
	// Main application entry point
	
	// Possible configurations to combine are listed here
	// maybe in future it'll change to some arrays or preprocessor operations...
	Input testPhotoInput("E:\\samoloty\\HappyFish.jpg", Input::Type::Photo);

	Searcher standardSearcher(100, 200);

	Recognizer handRecognizer;

	Player pianoPlayer(Player::Tone::Piano);

	// Run combination - choose one from possibilities of each part of processing chain
	// Input->Search->Recognize->Play
	Input *mainInput = &testPhotoInput;
	Searcher *mainSearcher = &standardSearcher;
	Recognizer *mainRecognizer = &handRecognizer;
	Player *mainPlayer = &pianoPlayer;

	// Needed variables and buffers
	Image *currentImage;
	Object *objects = new Object();
	Object *recognizedObjects;

	// Some handy variables
	int count;

	while (true) {
		currentImage = mainInput->getCurrentImage();
		count = mainSearcher->search(currentImage, objects);
		//count = mainRecognizer->recognize(objects, count, recognizedObjects);
		for (; count >= 0; --count) {
			mainPlayer->play();
		}
		delete /*recognizedObjects*/ /*objects*/ currentImage;
	}

	delete mainPlayer, mainRecognizer, mainSearcher, mainInput;
	
	return 0;
}
Пример #27
0
void SearchFilter::SearchInModuleList(Searcher &searcher, ModuleList &modules) {
  SymbolContext empty_sc;

  if (!m_target_sp)
    return;
  empty_sc.target_sp = m_target_sp;

  if (searcher.GetDepth() == lldb::eSearchDepthTarget)
    searcher.SearchCallback(*this, empty_sc, nullptr, false);
  else {
    std::lock_guard<std::recursive_mutex> guard(modules.GetMutex());
    const size_t numModules = modules.GetSize();

    for (size_t i = 0; i < numModules; i++) {
      ModuleSP module_sp(modules.GetModuleAtIndexUnlocked(i));
      if (ModulePasses(module_sp)) {
        if (DoModuleIteration(module_sp, searcher) ==
            Searcher::eCallbackReturnStop)
          return;
      }
    }
  }
}
Пример #28
0
TestSuite *ts_filter(TestSuite *suite)
{
    Store *store;
    IndexReader *ir;
    Searcher *searcher;

    suite = ADD_SUITE(suite);

    store = open_ram_store();
    prepare_filter_index(store);
    ir = ir_open(store);
    searcher = isea_new(ir);

    tst_run_test(suite, test_range_filter, (void *)searcher);
    tst_run_test(suite, test_range_filter_hash, NULL);
    tst_run_test(suite, test_query_filter, (void *)searcher);
    tst_run_test(suite, test_query_filter_hash, NULL);
    tst_run_test(suite, test_filter_func, searcher);
    tst_run_test(suite, test_score_altering_filter_func, searcher);

    store_deref(store);
    searcher->close(searcher);
    return suite;
}
Пример #29
0
void UsiClient::onUpdatePV(const Searcher& searcher, const PV& pv, float elapsed, int depth, Score score) {
  if (pv.size() == 0) {
    LOG(warning) << "PV is empty.";
    return;
  }

  auto& info = searcher.getInfo();

  auto timeMs = static_cast<uint32_t>(elapsed * 1e3);
  auto realDepth = depth / Searcher::Depth1Ply;
  auto totalNodes = info.nodes + info.quiesNodes;
  auto nps = static_cast<uint32_t>(totalNodes / elapsed);
  auto hashfull = static_cast<int>(searcher_->ttUsageRates() * 1000);

  const char* scoreKey;
  int scoreValue;
  if (score > -Score::mate() && score < Score::mate()) {
    scoreKey = "cp";
    scoreValue = score.raw() * 100.0 / material::Pawn;
  } else {
    scoreKey = "mate";
    if (score >= 0) {
      scoreValue = (Score::infinity() - score).raw();
    } else {
      scoreValue = -(Score::infinity() + score).raw();
    }
  }

  OUT(info) << std::setw(2) << realDepth << ": "
            << std::setw(10) << (info.nodes + info.quiesNodes) << ": "
            << std::setw(7) << timeMs << ' '
            << pv.toString() << ": "
            << score;

  if (!inPonder_) {
    send("info",
         "time", timeMs,
         "depth", realDepth,
         "nodes", totalNodes,
         "nps", nps,
         "currmove", pv.getMove(0).toStringSFEN(),
         "score", scoreKey, scoreValue,
         "pv", pv.toStringSFEN(),
         "hashfull", hashfull);
  }
}
Пример #30
0
void SearcherTest::testSearchLeadsToCorrectSolution(Searcher searcher, std::string algorithm) {
	searcher.setAlgorithm(algorithm);
	searcher.initializeSingleSource();
	searcher.heapInsertAll();
	searcher.search();
	int* path = searcher.getPath();
	int* distance = searcher.getDistance();
	assert(path[16] == 3  && distance[16] == 1);
	assert(path[20] == 19 && distance[20] == 5);
	assert(path[62] == 49 && distance[62] == 11);
	assert(path[69] == 70 && distance[69] == 18);
	assert(path[95] == 82 && distance[95] == 20);
}