void ICircuit::setGACallbacks(GAGenome * g) { g->initializer(getInitializer()); g->evaluator(getEvaluator()); g->mutator(getMutator()); g->comparator(getComparator()); if (getSexualCrossover() != NULL) { g->crossover(getSexualCrossover()); } else { g->crossover(getAsexualCrossover()); } }
pair<uint, uint> match_polish_rot(Image& pattern, Image& scene, double (*f)(Image&, uint, uint, Image&, uint)){ polish(pattern, 0, 0, pattern.getWidth(), pattern); map<uint, vector< pix > > comps; for(uint i=0;i<360;i+=90){ vector< pix > vec = getComparator( pattern.getHeight(), i ); sort( vec.begin(), vec.end(), comp ); comps.insert(make_pair(i,vec)); } const uint dimension = pattern.getHeight(); const uint G = (uint)getGradient( pattern, 0, 0, pattern.getHeight() ); vector< pix > patorder = comps[G]; pair<uint, uint> minPoint(-1,-1); double min = INF; double ang = 0; vector< pix > sceorder; for(uint i = 0; i < scene.getHeight(); i++){ for(uint j = 0; j < scene.getWidth(); j++){ if( scene.valid( i + dimension - 1, j + dimension - 1 ) ){ uint sceg = (uint)getGradient( scene, i, j, dimension ); sceorder = comps[sceg]; double m = f(scene, i, j, pattern, dimension); if( m <= min ){ min = m; minPoint = make_pair( i, j ); ang = sceg; } } } } cout<<"G = "<<G<<endl; cout<<"distance = "<<min<<endl; cout<<"angle = "<<ang<<endl; return minPoint; }
bool IndexDefinition::isCompatibleIndexDefinition(EnIndexKind enIxKind, TyFSType tyType, vector<uima::lowlevel::TyFSFeature> const & crKeyFeatures, vector<uima::lowlevel::IndexComparator::EnKeyFeatureComp> const & crComparators, IndexDefinition::TyIndexID const & crID, bool ) const { assert(isValidIndexId(crID)); if (getIndexKind(crID) != enIxKind) { UIMA_TPRINT("Wrong index kind!"); return false; } if (getTypeForIndex(crID) != tyType) { UIMA_TPRINT("Wrong index type!"); return false; } uima::lowlevel::IndexComparator const * cpComp = getComparator(crID); if (cpComp != NULL) { assert( (enIxKind == enOrdered) || (enIxKind == enSet) ); assert( cpComp->getType() == tyType ); if (crKeyFeatures.size() != cpComp->getKeyFeatures().size()) { UIMA_TPRINT("key feature length different, number of key features: " << crKeyFeatures.size() << ", existing key feature length: " << cpComp->getKeyFeatures().size()); return false; } if (crKeyFeatures != cpComp->getKeyFeatures()) { UIMA_TPRINT("Wrong key features!"); return false; } if (crComparators != cpComp->getComparisonOps() ) { UIMA_TPRINT("Wrong comparison ops!"); return false; } } else { assert( enIxKind == enFIFO ); } return true; }