Пример #1
0
int main(int argc, char** argv)
{
	int ret = EXIT_SUCCESS;

	// Setup default error handling strategy.
	// ...

	// Setup the default log stream.
	Log logger;
	LogSetDefault(&logger);

	// Setup the command line handling.
	AnyOption options;

	// Use this to active debug mode.
	options.setFlag("debug", 'd');

	options.setVerbose();
	options.autoUsagePrint(true);

	// Process the command line arguments.
	options.processCommandArgs(argc, argv);

	String file;
	ret = ValidateOptions(options, file);

	if( ret != EXIT_SUCCESS )
	{
		options.printUsage();
		return ret;
	}

	Runtime runtime;
	runtime.init();
	runtime.shutdown();

	return ret;
}
Пример #2
0
Файл: main.cpp Проект: jksr/xu
int process_option(int argc, char* argv[]){
	AnyOption *opt = new AnyOption();
	opt->setVerbose();
	opt->addUsage( "" );
	opt->addUsage( "Usage: " );
	opt->addUsage( "" );
	opt->addUsage( "--S0" );
	opt->addUsage( "--G0" );
	opt->addUsage( "--RhoGEF0" );
	opt->addUsage( "--RhoA0" );
	opt->addUsage( "--Inhibitor0" );
	opt->addUsage( "--kg1" );
	opt->addUsage( "--kg2" );
	opt->addUsage( "--kf1" );
	opt->addUsage( "--kfd" );
	opt->addUsage( "--kg3" );
	opt->addUsage( "--kgd" );
	opt->addUsage( "--kf2" );
	opt->addUsage( "--ka1" );
	opt->addUsage( "--ka2" );
	opt->addUsage( "--ki1" );
	opt->addUsage( "--kid" );
	opt->addUsage( "" );

	opt->setOption( "S0" );
	opt->setOption( "G0" );
	opt->setOption( "RhoGEF0" );
	opt->setOption( "RhoA0" );
	opt->setOption( "Inhibitor0" );
	opt->setOption( "kg1" );
	opt->setOption( "kg2" );
	opt->setOption( "kf1" );
	opt->setOption( "kfd" );
	opt->setOption( "kg3" );
	opt->setOption( "kgd" );
	opt->setOption( "kf2" );
	opt->setOption( "ka1" );
	opt->setOption( "ka2" );
	opt->setOption( "ki1" );
	opt->setOption( "kid" );
	

	opt->processCommandArgs( argc, argv );
	if( opt->getValue( "S0" ) != NULL  ){
		S0 = atof(opt->getValue( "S0" ));
	}
	if( opt->getValue( "G0" ) != NULL  ){
		G0 = atof(opt->getValue( "G0" ));
	}
	if( opt->getValue( "RhoGEF0" ) != NULL  ){
		RhoGEF0 = atof(opt->getValue( "RhoGEF0" ));
	}
	if( opt->getValue( "RhoA0" ) != NULL  ){
		RhoA0 = atof(opt->getValue( "RhoA0" ));
	}
	if( opt->getValue( "Inhibitor0" ) != NULL  ){
		Inhibitor0 = atof(opt->getValue( "Inhibitor0" ));
	}
	if( opt->getValue( "kg1" ) != NULL  ){
		kg1 = atof(opt->getValue( "kg1" ));
	}
	if( opt->getValue( "kg2" ) != NULL  ){
		kg2 = atof(opt->getValue( "kg2" ));
	}
	if( opt->getValue( "kf1" ) != NULL  ){
		kf1 = atof(opt->getValue( "kf1" ));
	}
	if( opt->getValue( "kfd" ) != NULL  ){
		kfd = atof(opt->getValue( "kfd" ));
	}
	if( opt->getValue( "kg3" ) != NULL  ){
		kg3 = atof(opt->getValue( "kg3" ));
	}
	if( opt->getValue( "kgd" ) != NULL  ){
		kgd = atof(opt->getValue( "kgd" ));
	}
	if( opt->getValue( "kf2" ) != NULL  ){
		kf2 = atof(opt->getValue( "kf2" ));
	}
	if( opt->getValue( "ka1" ) != NULL  ){
		ka1 = atof(opt->getValue( "ka1" ));
	}
	if( opt->getValue( "ka2" ) != NULL  ){
		ka2 = atof(opt->getValue( "ka2" ));
	}
	if( opt->getValue( "ki1" ) != NULL  ){
		ki1 = atof(opt->getValue( "ki1" ));
	}
	if( opt->getValue( "kid" ) != NULL  ){
		kid = atof(opt->getValue( "kid" ));
	}
	return 0;
}
Пример #3
0
int main(int argc, char **argv){
	// nekonstantni nastaveni generatoru nahodnych cisel
	srand((unsigned int)time(0));
	// server cast
	clock_t t1, t2;
	t1 = clock();	

	int NP = 50;
	double F = 0.7; 
	double CR = 0.6; 
	int Generations = 10; 
	int pocet_neuronu = 5; 
	char *nejlepsi_jedinec = "nejlepsi_jedinec.txt";
	char *data = "data.txt";
	int tichy = 0;

	// parsovani parametru
	AnyOption *opt = new AnyOption();
	opt->setVerbose(); /* print warnings about unknown options */
    opt->autoUsagePrint(true); /* print usage for bad options */

	opt->addUsage( "" );
	opt->addUsage( "NNSA (Neural Network Space Arcade) - Testovani rekuretni neuronove site na jednoduche arkade" );
    opt->addUsage( "" );
	opt->addUsage( "Pouziti: " );
    opt->addUsage( "" );
    opt->addUsage( " -h   --help		Zobrazi tuto napovedu " );    
	opt->addUsage( " -n jedinec.txt	Nejlepsi jedinec " ); 
	opt->addUsage( " -d data.txt		Udaje o jednotlivych generacich " ); 
	opt->addUsage( " " );
	opt->addUsage( "      --NP 60	Velikost populace " );
	opt->addUsage( "      --F 0.7	Mutacni konstanta " );
	opt->addUsage( "      --CR 0.8	Prah krizeni " );
	opt->addUsage( "      --generations 100	Pocet kol slechteni populace " );
	opt->addUsage( "      --neurons 4	Pocet neuronu v neuronove siti " );
	opt->addUsage( "      --quiet 1		Neukecany rezim " );
    opt->addUsage( "" );

	opt->setFlag( "help", 'h');   /* a flag (takes no argument), supporting long and short form */
	opt->setOption('n');
	opt->setOption('d');
	opt->setOption("NP");
	opt->setOption("F");
	opt->setOption("CR");
	opt->setOption("generations");
	opt->setOption("neurons");
	opt->setOption("quiet");
	
	opt->processCommandArgs(argc, argv);

	NP = atoi(opt->getValue("NP"));
	F = atof(opt->getValue("F"));
	CR = atof(opt->getValue("CR")); 
	Generations = atoi(opt->getValue("generations"));
	pocet_neuronu = atoi(opt->getValue("neurons"));
	nejlepsi_jedinec = opt->getValue('n');
	data = opt->getValue('d');
	tichy = atoi(opt->getValue("quiet"));

	cout << "Parametry diferencialni evoluce:" << endl;
	cout << " -> Velikost populace NP = " << NP << endl;
	cout << " -> Mutacni konstanta F = " << F  << endl;
	cout << " -> Prah krizeni CR = " << CR << endl;
	cout << " -> Pocet generaci = " << Generations << endl;
	cout << " -> Pocet neuronu = " << pocet_neuronu << endl;

	DiferencialniEvoluce *d1 = new DiferencialniEvoluce(NP, F, CR, Generations, pocet_neuronu, &ohodnoceni, tichy, data);
	d1->UlozNejlepsiJedinec(nejlepsi_jedinec);
	

	// 32bit - pretece cca po 36 minutach
	t2 = clock();
	cout << "Doba behu programu: " << ((double) (t2 - t1))/CLOCKS_PER_SEC << endl;


	return 0;
}