double time_gpu_multiply() { mean_delta_time = 0; cv::randu(a, cv::Scalar(0), cv::Scalar(100)); cv::randu(b, cv::Scalar(0), cv::Scalar(100)); cv::cuda::GpuMat ga(2048, 2048, CV_32F); cv::cuda::GpuMat gb(2048, 2048, CV_32F); ga.upload(a); gb.upload(b); // transfer both the gpu for (int i=0; i < N; i++) { gettimeofday(&start_time, NULL); cv::cuda::multiply(ga, gb, gb); gettimeofday(&end_time, NULL); timersub(&end_time, &start_time, &delta_times[i]); std::cout << "gpu: multiply took: " << (delta_times[i].tv_usec + 1000000 * delta_times[i].tv_sec) / 1000. << std::endl; mean_delta_time += (delta_times[i].tv_usec + 1000000 * delta_times[i].tv_sec) / 1000.; } mean_delta_time /= N; std::cout << "gpu: mean time: " << mean_delta_time << std::endl; return mean_delta_time; }
int main(int argc, char** argv) { cout << "This program tries to fill a 1DBinaryStringGenome with\n"; cout << "alternating 1s and 0s using a simple genetic algorithm. It runs\n"; cout << "in parallel using PVM and a population on each process.\n\n"; cout.flush(); GA1DBinaryStringGenome genome(GENOME_LENGTH); PVMDemeGA ga(genome); ga.parameters(argc, argv); ga.parameters("settings.txt"); if(ga.spawn("slave") < 0) exit(1); cout << "initializing..." << endl; ga.initialize(); cout << ga.statistics().bestIndividual() << endl; cout << "evolving..." << endl; while(!ga.done()){ ga.step(); cout << ga.statistics().bestIndividual() << endl; } ga.flushScores(); cout << "\nThe GA found an individual with a score of "; cout << ga.statistics().bestIndividual().score() << endl; return 0; }
int main(void){ const int vecSize = 1280; #define TILE 128 // Alloc & init input data Concurrency::extent<1> e(vecSize); Concurrency::tiled_extent<TILE> et(e); Concurrency::tiled_extent<TILE> et2 = e.tile<TILE>(); assert(et.tile_dim0 == TILE); assert(et2.tile_dim0 == TILE); Concurrency::array<int, 1> a(vecSize); Concurrency::array<int, 1> b(vecSize); Concurrency::array<int, 1> c(vecSize); int sum = 0; Concurrency::array_view<int> ga(a); Concurrency::array_view<int> gb(b); Concurrency::array_view<int> gc(c); for (Concurrency::index<1> i(0); i[0] < vecSize; i++) { ga[i] = 100.0f * rand() / RAND_MAX; gb[i] = 100.0f * rand() / RAND_MAX; sum += a[i] + b[i]; } Concurrency::parallel_for_each( et, [=](Concurrency::tiled_index<TILE> idx) restrict(amp) { tile_static int shm[TILE]; shm[idx.local[0]] = ga[idx]; idx.barrier.wait(); gc[idx] = shm[(TILE-1)-idx.local[0]]+gb[idx]; });
int main(void){ const int vecSize = 128; // Alloc & init input data Concurrency::extent<1> e(vecSize); Concurrency::tiled_extent<16> et(e); Concurrency::tiled_extent<16> et2 = e.tile<16>(); assert(et.tile_dim0 == 16); assert(et2.tile_dim0 == 16); Concurrency::array<int, 1> a(vecSize); Concurrency::array<int, 1> b(vecSize); Concurrency::array<int, 1> c(vecSize); int sum = 0; for (Concurrency::index<1> i(0); i[0] < vecSize; i++) { a[i] = 100.0f * rand() / RAND_MAX; b[i] = 100.0f * rand() / RAND_MAX; sum += a[i] + b[i]; } Concurrency::array_view<int> ga(a); Concurrency::array_view<int> gb(b); Concurrency::array_view<int> gc(c); Concurrency::parallel_for_each( et, [=](Concurrency::tiled_index<16> idx) restrict(amp) { gc[idx] = ga[idx]+gb[idx]; });
bool SemanticRelationData::addRelations(AnalysisContent& analysis) { #ifdef DEBUG_LP SEMANTICANALYSISLOGINIT; #endif auto annotationData = static_cast< AnnotationData* >( analysis.getData("AnnotationData")); if (annotationData->dumpFunction("SemanticRelation") == 0) { annotationData->dumpFunction("SemanticRelation", new DumpSemanticRelation()); } auto recoData=static_cast<RecognizerData*>( analysis.getData("RecognizerData")); for (auto i = m_relations.begin(); i != m_relations.end(); i++) { LinguisticGraphVertex vertex1 = i->get<0>(); LinguisticGraphVertex vertex2 = i->get<1>(); auto matchesVtx1 = annotationData->matches(recoData->getGraphId(), vertex1, "annot"); auto matchesVtx2 = annotationData->matches(recoData->getGraphId(), vertex2, "annot"); if (!annotationData->hasAnnotation(*(matchesVtx1.begin()), *(matchesVtx2.begin()), "SemanticRelation")) { SemanticRelationAnnotation annot(i->get<2>()); GenericAnnotation ga(annot); annotationData->annotate(*(matchesVtx1.begin()), *(matchesVtx2.begin()), "SemanticRelation", ga); } else { auto annot = annotationData->annotation(*(matchesVtx1.begin()), *(matchesVtx2.begin()), "SemanticRelation").pointerValue<SemanticRelationAnnotation>(); SEMANTICANALYSISLOGINIT; LWARN << "SemanticRelationData::addRelations There is already a SemanticRelation between" << *(matchesVtx1.begin()) << "and" << *(matchesVtx2.begin()) << annot->type(); LWARN << "Adding new type" << i->get<2>(); QString type = QString::fromUtf8(annot->type().c_str()); QStringList typeList = type.split(','); typeList << i->get<2>().c_str(); typeList.sort(); typeList.removeDuplicates(); annot->type(typeList.join(',').toUtf8().constData()); LWARN << "Adding type is now" << annot->type(); } } m_relations.clear(); return true; }
int main(int argc, char* argv[]) { try { parse_arguments(argc, argv); FLM_Conf flm_conf(flmparamfile); GA_Conf ga_conf(flm_conf, gaparamfile, seedfile); GA ga(ga_conf, flm_conf); // TODO: set a fixed random seed with a command-line argument for reproducibility unsigned random_seed = chrono::system_clock::now().time_since_epoch().count(); GA_Operator::set_random_seed(random_seed); float best_fitness, best_perplexity; Chromosome best = ga.search(best_fitness, best_perplexity); cerr << "Best fitness: " << best_fitness << endl; cerr << "Best best_perplexity: " << best_perplexity << endl; // backup_best(ga_conf.ga_path, to_string(best)); } catch (char const* s) { cerr << "ERROR: " << s << endl; return 1; } catch (string s) { cerr << "ERROR: " << s << endl; return 1; } return 0; }
Z I td(A a,A w,I i) { A z; ND2 I0 { I wt=w->t,wr=w->r,*wd=w->d; I j= *wd,k,m=*a->p; if(!wr) j=1,++wr; if(i==26) m=m>0?(m>j?0:m-j):m<-j?0:m+j; k=tr(wr-1,wd+1); u=v=0; t=wt; if(m<0) if(m= -m,m>j) u=(j-m)*k; else v=(j-m)*k; else if(m>j) u=(m-j)*k; else if(wt<Ct&&w->c==1&&m) R g=(PFI)k1,w->n=(*w->d=m)*k,ic(w); W(ga(wt,wr,m*k,wd))*z->d=m; C2(k1) } }
Z I dr(A a,I f) { XA; A z,*ap=(A*)a->p,w; if(!an||at!=Et||fsy(a))R ic(a); /* ic_or_copy(a) */ w=*ap; Q(QF(w),9); if(!ar)R ic(w); /* ic_or_copy(w) */ { XW; I i=an,n=0,t; C *p; if(f){Q(ar>1,7)V0 n=*wd;} else{Q(ar+wr>MAXR,13)mv(ad+ar,wd,wr);} for(;--i;) { Q(!QA(a=ap[i])||(t=a->t)>Et,9); if(wt!=t&&a->n) if(f&&!n)wt=t; else{Q(wt>Ft||t>Ft,6)wt=Ft;} if(wr!=a->r){Q(!f||wr>1||a->r,7)*a->d=1;} Q(cm(wd+f,a->d+f,wr-f),11); if(f)n+=*a->d; } W(ga(wt,f?wr:ar+wr,f?n*tr(wr-1,wd+1):an*wn,f?wd:ad)); if(f)*z->d=n; p=(C*)z->p; DO(an,a=ap[i]; p=(*(a->t==wt?(C *(*)(I,F *,I *,I))tmv:i2f))(wt,(F *)p,a->p,a->n)); R(I)z; } }
int main(int argc, const char * argv[]) { // insert code here... std::vector<int> kickPattern = {1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0}; std::vector<int> snarePattern = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}; std::vector<int> closeHatPattern = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}; std::vector<int> openHatPattern = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; std::vector<int> fullPattern; fullPattern.insert(fullPattern.begin(), kickPattern.begin(), kickPattern.end()); fullPattern.insert(fullPattern.begin(), snarePattern.begin(), snarePattern.end()); fullPattern.insert(fullPattern.begin(), closeHatPattern.begin(), closeHatPattern.end()); fullPattern.insert(fullPattern.begin(), openHatPattern.begin(), openHatPattern.end()); for(int i=0; i<64; i++) fullPattern[i] = 1; GeneticAlgorithm ga(fullPattern, GeneticAlgorithm::GATYPE::NUMERICAL, GeneticAlgorithm::MEASURE::SWAP, 40, 0.1, 0, 1); int i = 0; std::vector<int> best; while(ga.bestFitness < 0.95) { best = ga.evolve(); i++; std::cout << "bestFitness: " << ga.bestFitness << "\n"; } std::cout << "Generations: " << i << "\n"; return 0; }
void top(){ glPushMatrix(); ga(); apa(); glPopMatrix(); }
void gen_ASSIGNMENT_STATEMENT ( node_t *root, int scopedepth ) { tracePrint ( "Starting ASSIGNMENT_STATEMENT\n"); //Generating the code for the expression part of the assignment. The result is //placed on the top of the stack root->children[1]->generate(root->children[1], scopedepth); // Left hand side may be a class field, which should be handled in this assignment if(root->children[0]->expression_type.index == CLASS_FIELD_E){ // Fetching address value from child 1, pushing to top of stack: root->children[0]->children[0]->generate(root->children[0]->children[0], scopedepth); // Now popping THIS (a.k.a. the objects address value) from stack into r2: instruction_add(POP, r2, NULL, 0,0); // Now popping result from expression into r1: instruction_add(POP, r1, NULL, 0,0); // Now storing to the address on the heap, based on address from child 1 and offset from child 2: instruction_add(STORE, r1, r2, 0, root->children[0]->children[1]->entry->stack_offset); } // or a variable, handled in previous assignment else{ ga(root,scopedepth); } tracePrint ( "End ASSIGNMENT_STATEMENT\n"); }
Z I f_cl(A a,A w,I i){A z;ND2 X2{I ar=a->r,an=a->n,*ad=a->d;XW;I r,n,d[9];i=!ar&&!wr||i==23; if(ar&&wr)if(ar==wr)Q(cm(ad+!i,wd+!i,ar-!i),8)else{ Q(i||wr-ar!=1&&ar-wr!=1,7)n=wr<ar;Q(cm(ad+n,wd+!n,ar-n),8)} if(wr<ar)n=1,mv(d+i,ad,r=ar);else mv(d+i,wd,r=wr),n=i||ar<wr?1:*ad; if(i)++r,*d=1;*d+=n;Q(MAXR<r,13) u=!ar?(an=tr(r-1,d+1),1):!wr?(wn=tr(r-1,d+1),2):0; W(ga(t=wt,r,an+wn,d))v=an;C2(m2)}}
bool Thermal::apply(SpinSystem* ss, RNG* useThisRNG) { int slot = markSlotUsed(ss); RNG* rand = myRNG; if(useThisRNG) rand = useThisRNG; if(rand == 0) { errormsg = "Missing RNG"; return false; } const double alpha = ss->alpha; const double dt = ss->dt; const double gamma = ss->gamma; double* hx = ss->hx[slot]->data(); double* hy = ss->hy[slot]->data(); double* hz = ss->hz[slot]->data(); const double* ms = ss->ms->data(); gamma_alpha ga(ss); for(int i=0; i<ss->nxyz; i++) { if(ms[i] != 0 && temperature != 0) { const double alpha = ga.alpha(i); const double gamma = ga.gamma(i); if(gamma > 0) { const double stddev = sqrt((2.0 * alpha * global_scale * temperature * (*scale)[i]) / (ms[i] * dt * gamma)); hx[i] = stddev * rand->randNorm(0, 1); hy[i] = stddev * rand->randNorm(0, 1); hz[i] = stddev * rand->randNorm(0, 1); } else { hx[i] = 0; hy[i] = 0; hz[i] = 0; } } else { hx[i] = 0; hy[i] = 0; hz[i] = 0; } } return true; }
int main() { XY xy; ga(xy); xy.print(); }
int main(int argc, char **argv) { cout << "Example 4\n\n"; cout << "This program tries to fill a 3DBinaryStringGenome with\n"; cout << "alternating 1s and 0s using a SteadyStateGA\n\n"; cout.flush(); // See if we've been given a seed to use (for testing purposes). When you // specify a random seed, the evolution will be exactly the same each time // you use that seed number. for(int ii=1; ii<argc; ii++) { if(strcmp(argv[ii++],"seed") == 0) { GARandomSeed((unsigned int)atoi(argv[ii])); } } int depth = 3; int width = 10; int height = 5; // Now create the GA and run it. First we create a genome of the type that // we want to use in the GA. The ga doesn't use this genome in the // optimization - it just uses it to clone a population of genomes. GA3DBinaryStringGenome genome(width, height, depth, objective); // Now that we have the genome, we create the genetic algorithm and set // its parameters - number of generations, mutation probability, and crossover // probability. By default the GA keeps track of the best of generation scores // and also keeps one genome as the 'best of all' - the best genome // that it encounters from all of the generations. Here we tell the GA to // keep track of all scores, not just the best-of-generation. GASteadyStateGA ga(genome); ga.populationSize(100); ga.pReplacement(0.50); // replace 50% of population each generation // ga.nReplacement(4); // number of individuals to replace each gen ga.nGenerations(200); ga.pMutation(0.001); ga.pCrossover(0.9); ga.scoreFilename("bog.dat"); // name of file for scores ga.scoreFrequency(10); // keep the scores of every 10th generation ga.flushFrequency(50); // specify how often to write the score to disk ga.selectScores(GAStatistics::AllScores); ga.evolve(); // Now we print out the best genome. cout << "the ga generated:\n" << ga.statistics().bestIndividual() << "\n"; cout << "best of generation data are in 'bog.dat'\n"; // That's it! return 0; }
float_t OperationEvalModWavelet::eval(const DataVector& alpha, const DataVector& point) { typedef std::vector<std::pair<size_t, float_t> > IndexValVector; IndexValVector vec; WaveletModifiedBasis<unsigned int, unsigned int> base; GetAffectedBasisFunctions < WaveletModifiedBasis<unsigned int, unsigned int> > ga(storage); ga(base, point, vec); float_t result = 0.0; for (IndexValVector::iterator iter = vec.begin(); iter != vec.end(); iter++) { result += iter->second * alpha[iter->first]; } return result; }
A gtest_array(I n, ...) { va_list ap; A z = ga(BOX,1,n+5,NULL), *zv = AAV(z); *zv++ = mark; va_start(ap, n); DO(n, zv[i] = va_arg(ap, A)); DO(4, zv[n+i] = mark); va_end(ap); R z; }
int SRCPDeviceMaster::setGA( int addr, int port, int value, int delay ) { int rc = 200; Enumeration<SRCPGenericAccessoire> ga( addr, firstGAElement() ); while ( ga.hasMoreElements() ) { SRCPGenericAccessoire* pa = ga.nextElement(); rc = pa->set( addr, port, value, delay ); } return ( rc ); }
float_t test_dataset(base::GridStorage* storage, BASIS& basis, base::DataVector& alpha, base::DataMatrix& data, base::DataVector& classes) { typedef std::vector<std::pair<size_t, float_t> > IndexValVector; float_t correct = 0; #pragma omp parallel shared(correct) { size_t size = data.getNrows(); base::DataVector point(data.getNcols()); base::GetAffectedBasisFunctions<BASIS> ga(storage); #pragma omp for schedule(static) for (size_t i = 0; i < size; i++) { IndexValVector vec; float_t result = 0; data.getRow(i, point); ga(basis, point, vec); for (IndexValVector::iterator iter = vec.begin(); iter != vec.end(); iter++) { result += iter->second * alpha[iter->first]; } if ( (result >= 0 && classes[i] >= 0) || (result < 0 && classes[i] < 0) ) { #pragma omp critical { correct++; } } } } return correct; }
float_t test_dataset_mse(base::GridStorage* storage, BASIS& basis, base::DataVector& alpha, base::DataMatrix& data, base::DataVector& refValues) { typedef std::vector<std::pair<size_t, float_t> > IndexValVector; base::DataVector result(refValues.getSize()); float_t mse = 0; #pragma omp parallel shared(result) { size_t size = data.getNrows(); base::DataVector point(data.getNcols()); base::GetAffectedBasisFunctions<BASIS> ga(storage); #pragma omp for schedule(static) for (size_t i = 0; i < size; i++) { IndexValVector vec; float_t res = 0; data.getRow(i, point); ga(basis, point, vec); for (IndexValVector::iterator iter = vec.begin(); iter != vec.end(); iter++) { res += iter->second * alpha[iter->first]; } result[i] = res; } } result.sub(refValues); result.sqr(); mse = result.sum(); mse /= static_cast<float_t>(result.getSize()); return mse; }
int main(int argc, char **argv) { // a seed to use (for testing purposes). When you // specify a random seed, the evolution will be exactly the same each time // you use that seed number. for(int ii=1; ii<argc; ii++) { if(strcmp(argv[ii++],"seed") == 0) { GARandomSeed((unsigned int)atoi(argv[ii])); } } // Declare variables for the GA parameters and set them to some default values. //int width = 50; //int height = 41; int length=730; int popsize = 100; int ngen = 4000; float pmut = 0.001; float pcross = 0.9; // Now create the GA and run it. Fist we create a genome of the type that // we want to use in the GA. The ga doesn't operate on this genome in the // optimization - it just uses it to clone a population of genomes. GA1DBinaryStringGenome genome(length, Objective); // Now that we have the genome, we create the genetic algorithm and set // its parameters - number of generations, mutation probability, and crossover // probability. And finally we tell it to evolve itself. GASteadyStateGA ga(genome); ga.populationSize(popsize); ga.nGenerations(ngen); ga.pMutation(pmut); ga.pCrossover(pcross); ga.nBestGenomes(90); ga.evolve(); // Now we print out the best genome that the GA found. cout << "The GA found:\n" << ga.statistics().bestPopulation() << "\n"; // That's it! fclose(fp); return 0; }
int main(int argc, char *argv[]) { cout << "Example 6\n\n"; cout << "This example uses a SteadyState GA and Tree<int> genome. It\n"; cout << "tries to maximize the size of the tree genomes that it\n"; cout << "contains. The genomes contain ints in its nodes.\n\n"; cout.flush(); // See if we've been given a seed to use (for testing purposes). When you // specify a random seed, the evolution will be exactly the same each time // you use that seed number. unsigned int seed = 0; for (int i = 1; i < argc; i++) { if (strcmp(argv[i++], "seed") == 0) { seed = atoi(argv[i]); } } // Set the default values of the parameters. GAParameterList params; GASteadyStateGA::registerDefaultParameters(params); params.set(gaNpopulationSize, 30); params.set(gaNpCrossover, 0.7); params.set(gaNpMutation, 0.01); params.set(gaNnGenerations, 100); params.set(gaNscoreFilename, "bog.dat"); params.set(gaNscoreFrequency, 10); // record score every 10th generation params.set(gaNflushFrequency, 10); // dump scores every 10th recorded score params.parse(argc, argv, gaFalse); // Parse the command line for GAlib args. // Now create the GA and run it. We first create a chromsome with the // operators we want. Once we have the genome set up, create the genetic // algorithm, set the parameters, and let it go. GATreeGenome<int> genome(objective); genome.initializer(TreeInitializer); genome.mutator(GATreeGenome<int>::SwapSubtreeMutator); GASteadyStateGA ga(genome); ga.parameters(params); ga.evolve(seed); genome = ga.statistics().bestIndividual(); // cout << "the ga generated this tree:\n" << genome << "\n"; cout << genome.size() << " nodes, " << genome.depth() << " levels deep.\n"; cout << "best of generation data are in '" << ga.scoreFilename() << "'\n"; return 0; }
float Objective(GAGenome &); // This is the declaration of our obj function. // The definition comes later in the file. int main(int argc, char **argv) { cout << "Example 1\n\n"; cout << "This program tries to fill a 2DBinaryStringGenome with\n"; cout << "alternating 1s and 0s using a SimpleGA\n\n"; cout.flush(); // See if we've been given a seed to use (for testing purposes). When you // specify a random seed, the evolution will be exactly the same each time // you use that seed number. for (int ii = 1; ii < argc; ii++) { if (strcmp(argv[ii++], "seed") == 0) { GARandomSeed((unsigned int) atoi(argv[ii])); } } // Declare variables for the GA parameters and set them to some default values. int width = 10; int height = 5; int popsize = 30; int ngen = 400; float pmut = 0.001; float pcross = 0.9; // Now create the GA and run it. First we create a genome of the type that // we want to use in the GA. The ga doesn't operate on this genome in the // optimization - it just uses it to clone a population of genomes. GA2DBinaryStringGenome genome(width, height, Objective); // Now that we have the genome, we create the genetic algorithm and set // its parameters - number of generations, mutation probability, and crossover // probability. And finally we tell it to evolve itself. GASimpleGA ga(genome); ga.populationSize(popsize); ga.nGenerations(ngen); ga.pMutation(pmut); ga.pCrossover(pcross); ga.evolve(); // Now we print out the best genome that the GA found. cout << "The GA found:\n" << ga.statistics().bestIndividual() << "\n";
genetic_population procreator::next_generation( genetic_population const& existing ) { crossover_t cx_ftr = [this](std::vector< genome const* >::const_iterator parents, std::vector< genome >::iterator offspring) { auto p1 = *(parents + 0); auto p2 = *(parents + 1); *offspring = m_cx_fn(*p1, *p2, m_rgen); }; mutation_t mut_ftr = [this](genome& child, double rate) { m_mut_fn.op(child, rate, m_rgen); }; m_mut_fn.update(op_update_context{ m_generation }); proc_sel_t proc_sel{ m_rgen }; rate_context rate_ctx; rate_ctx.generation = m_generation; ga_t ga(proc_sel, cx_ftr, m_cx_rate_fn, mut_ftr, m_mut_rate_fn, m_rect_fn, rate_ctx, m_rgen); ga.init_params(0 /* unused */, 1 /* TODO: ? */); ga.generation = m_generation;// TODO: still used? auto const pop_size = existing.size(); ga.population.resize(pop_size); // Produce next generation for(size_t idv = 0; idv < pop_size; ++idv) { ga.population[idv].genome = existing[idv].gn; ga.population[idv].fitness = existing[idv].fitness; } ga.epoch(); genetic_population next; next.resize(pop_size); for(size_t idv = 0; idv < pop_size; ++idv) { next[idv].gn = std::move(ga.population[idv].genome); } ++m_generation; return std::move(next); }
void gen_ASSIGNMENT_STATEMENT ( node_t *root, int scopedepth ) { tracePrint ( "Starting ASSIGNMENT_STATEMENT\n"); //Generating the code for the expression part of the assignment. The result is //placed on the top of the stack root->children[1]->generate(root->children[1], scopedepth); // Left hand side may be a class field, which should be handled in this assignment if(root->children[0]->expression_type.index == CLASS_FIELD_E){ } // or a variable, handled in previous assignment else{ ga(root,scopedepth); } tracePrint ( "End ASSIGNMENT_STATEMENT\n"); }
void ReadGrassCoord(plantVec& pv, waterVec& wv){ ifstream myfile("EcosystemFile.txt"); int waterLines = ReadWaterAreas(); int grassLines = ReadGrassAreas(); string line; vector <int> values(5); if (myfile.is_open()){ for (int i = 0; i < waterLines + grassLines + 4; i++){ getline(myfile, line); if (i > waterLines + 3){ for (int k = 0; k < line.size(); k++){ if (line[k] == ',') line[k] = ' '; } istringstream iss(line); for (int j = 0; j < 5; j++){ int val; iss >> val; values[j] = val; } shared_ptr<GrassArea> ga (new GrassArea(values[0], values[1], values[2], values[3],values[4])); bool overlap = false; try { if (ga->HasRightInput()){ for (int l = 0; l < wv.size(); l++){ if (ga->OverlapWithWater(*wv[l])){ overlap = true; break; } } if (!overlap) pv.push_back(ga); } } catch (AreaException& e){ cout<<e.what()<<endl; } catch (GrassException& ge){ cout<<ge.what()<<endl; } } } } }
Z H2(xpn){ A z; ND2 I1; {I ar=a->r,an=a->n;XW; I bn=b0(a->p,an),wl=wr?*wd:1; aw=0; Q(bn<0,9) Q(ar>1,7) if(!wr) wl=wr=1; if(wn==1) aw=2; else Q(wl!=bn,8) if(wr==1&&wt!=Et){ W(gv(wt,an)) C2((I(*)())(!wt?(I(*)())x0:wt==Ft?(I(*)())x1:(I(*)())x2)) } v=tr(wr-1,wd+1); u=wn; W(ga(t=wt,wr,an*v,wd))*z->d=an; C2(x3) }}
void trial(int cnt, _Bool train, double *err) { // get problem function state and solution double *state = func_state(train); double answer = func_answer(train); // create match set NODE *mset = NULL, *kset = NULL; int msize = 0, mnum = 0; set_match(&mset, &msize, &mnum, state, cnt, &kset); // calculate system prediction and track performance double pre = set_pred(&mset, msize, state); err[cnt%PERF_AVG_TRIALS] = fabs(answer - pre); if(train) { // provide reinforcement to the set set_update(&mset, &msize, &mnum, answer, &kset, state); // run the genetic algorithm ga(&mset, msize, mnum, cnt, &kset); } // clean up set_kill(&kset); // kills deleted classifiers set_free(&mset); // frees the match set list }
Z H2(cmp){ A z;ND2 I1; {I ar=a->r,an=a->n;XW; I bn=b0(a->p,an),wl=wr?*wd:1; Q(bn==-1,9) aw=0; u=an==1; if((u)&&bn==1&&wr) R ic_or_copy(w); Q(ar>1,7) if(!wr) wl=wr=1; if(u) bn*=wl; else if(wn==1) aw=2; else Q(wl!=an,8) if(wr==1&&wt!=Et&&bn>=0){ W(gv(wt,bn)) C2((!wt?(I(*)())c0:wt==Ft?(I(*)())c1:(I(*)())c2)) } if(bn<0) bn=-bn; v=tr(wr-1,wd+1); W(ga(t=wt,wr,bn*v,wd))*z->d=bn; C2(c3) }}
void reFBXAsset::import() { FbxImporter* importer = FbxImporter::Create(sdk,""); meshes = new reFileAsset(this); meshes->setPath("meshes"); children.push_back(meshes); if(!importer->Initialize(path().toUtf8().constData(), -1, sdk->GetIOSettings())) { printf("Call to FbxImporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", importer->GetLastErrorString()); return; } FbxScene* lScene = FbxScene::Create(sdk, "myScene"); FbxAxisSystem ga(FbxAxisSystem::OpenGL); ga.ConvertScene(lScene); importer->Import(lScene); FbxNode* lRootNode = lScene->GetRootNode(); if(lRootNode) { reNode* node = importNode(lRootNode, NULL); node->name(info.baseName().toStdString()); QString path = dataDir() + QDir::separator() + node->name().c_str() + ".json"; node->save(path.toStdString()); } importer->Destroy(); }