Synth *SynthDef::build(){ Synth *s = new Synth(); // first make all the gens from the gendefs, and store // them in a map. std::map<std::string,Gen *> gens; // iterate through the list (which maintains the insert order) for(std::list<std::pair<std::string, GenDef *> >::iterator iter = gendefList.begin();iter!=gendefList.end();++iter){ GenDef *d = iter->second; Gen *g = d->build(); gens[iter->first]=g; g->setName(iter->first); // add to the synth, setting the output s->add(g,d->out); } // now wire them together for(std::map<std::pair<std::string,std::string>,std::string>:: iterator iter=links.begin();iter!=links.end();++iter){ std::pair<std::string,std::string> inspec = iter->first; Gen *outgen = findGenInMap(gens,iter->second); Gen *in = findGenInMap(gens,inspec.first); in->ins[in->getInputByName(inspec.second.c_str())] = outgen->out; } return s; }
int main(int argc, char* argv[]) { Gen gen; int l = 12; int t = 'a'; int c = 0; /* switch (t) { case 0: { gen.map if int pw = (i > 47 & i < 58); break; } case 'a': { int pw = (i > 47 & i < 58 or i > 96 & i < 123); break; } case 'A': { int pw = (i > 47 & i < 58 or i > 64 & i < 91 or i > 96 & i < 123); break; } }*/ for (int i = 0; i < 123 ; i++) { if (i > 47 & i < 58 or i > 64 & i < 91 or i > 96 & i < 123) { gen.map[c] = i ; c++; } } char* pswd = gen.getPsw(l,t); return 0; }
void FinishedSearch() { for (ChartCellLabelSet::iterator i(out_.mutable_begin()); i != out_.mutable_end(); ++i) { ChartCellLabel::Stack &stack = i->second.MutableStack(); Gen *gen = static_cast<Gen*>(stack.incr_generator); gen->FinishedSearch(); stack.incr = &gen->Generating(); } }
void NewHypothesis(search::PartialEdge partial) { // Get the LHS, look it up in the output ChartCellLabel, and upcast it. // It's not part of the union because it would have been ugly to expose template types in ChartCellLabel. ChartCellLabel::Stack &stack = out_.FindOrInsert(static_cast<const TargetPhrase *>(partial.GetNote().vp)->GetTargetLHS()); Gen *entry = static_cast<Gen*>(stack.incr_generator); if (!entry) { entry = generator_pool_.construct(context_, *vertex_pool_.construct(), best_); stack.incr_generator = entry; } entry->NewHypothesis(partial); }
void FinishedSearch() { for (ChartCellLabelSet::iterator i(out_.mutable_begin()); i != out_.mutable_end(); ++i) { if ((*i) == NULL) { continue; } ChartCellLabel::Stack &stack = (*i)->MutableStack(); Gen *gen = static_cast<Gen*>(stack.incr_generator); gen->FinishedSearch(); stack.incr = &gen->Generating(); } }
void Alg::init(const std::string & name, Gen gen) { std::vector<std::string> msgs; msgs.push_back("init"); msgs.push_back(name); msgs.push_back(gen.get_type()); std::vector<Number> l = gen.get_list(); msgs.push_back(to_str(l.size())); send_message_to_server(msgs, l); }
bool Testit<22>::Main() { Gen gen; for(ulen i=0; i<DimOf(Output) ; i++) { auto r=Range(Output[i]); for(; +r ; ++r) if( *r!=gen.next() ) { return false; } } return true; }
basic_type(Gen& r_gen, size_t max) { size_t rnd = r_gen.get_unsigned_long(0, static_cast<unsigned long>(max)); while (rnd > 0) { base_type::push_back('a' + static_cast<char>(rnd % distinct_chars)); rnd /= distinct_chars; } }
bool GenPrototype::restoreGene(FILE* f, RESTORE_GA_GENE* gene, std::vector<Gen*>& storage) { IValue* value = m_randomStrategy->getRandomValue(); Gen* gen; if(!value->restore(f)) return false; gen = new Gen(this,gene->ID); gen->setValue(value); //make sure that the genes are in the right order //SingletonGenEngine::getInstance()->addGen(gen); if(storage.size()<=(unsigned int)gene->ID) storage.resize(gene->ID+1); storage[gene->ID]=gen; return true; }
double EuclidicDistanceFitnessStrategy::getFitness(const Individual* individual) { double sum = 0.0; //the sum and later the result and so the fitness of the individual. int num = individual->getSize(); //number of gens inside the individual Gen* gen; //the actual used gen IValue* value; //the value of the gen TemplateValue<double>* tValue; //the casted value of the gen (double gen) // take all gens for(int x=0; x<num; x++) { gen = individual->getGen(x); //become gen from individual value = gen->getValue(); //become the value from the gen tValue = dynamic_cast<TemplateValue<double>* >(value); //cast the value to a double gen if(tValue == 0) { //UNKNOWN DATA TYP //test if it is really a double gen sum += STANDART_FACTOR_FOR_UNKNOWN_DATA_TYP; } else { sum += tValue->getValue() * tValue->getValue(); //euclid = sqrt(a²+b²+c²+...) so calculate first the sum of the ² } } return sqrt(sum); // as next calculate the sqrt from the sum an return }
/// add new synths to this function! Gen *GenDef::build(){ Gen *g; if(name == "sin") g = new SinOsc(); else if(name == "env") g = new Env(); else if(name == "noise") g = new Noise(); else if(name == "mix2") g = new ConstMix(); else if(name == "wave") g = new WaveTableOsc(); else if(name == "perlin") g = new Perlin(); else if(name == "lpf") g = new LPF(); else if(name == "add") g = new Add(); else if(name == "mul") g = new Mul(); else if(name == "const") g = new Const(); else throw BadSynthException(name); if(doneMon)g->isDoneMon=true; // now set the params for(std::map<std::string, std::string>::iterator iter = params.begin();iter!=params.end();++iter){ if(!g->setParam(iter->first.c_str(),iter->second.c_str())){ throw BadParamException(name.c_str(),iter->first.c_str()); } } return g; }