Esempio n. 1
0
void MonteCarlo::monteCarloAlgorithm() {
	logg("start monteCarlo algorithm...");
	Time st(boost::posix_time::microsec_clock::local_time());
	calculateEnergy();
	vector<cell*> listCells;
	for (int i = 0; i < 100; i++) {
		copySpaces(oldstate, cells);
		fillList(&listCells, cells);
		//cout<<listCells.size()<<endl;
		if(listCells.size()>0){
		executeList(&listCells,cells,oldstate);
		}
		manager->run();
		manager->join_all();
		listCells.clear();

	}

	Time end(boost::posix_time::microsec_clock::local_time());
	TimeDuraction d = end - st;
	duraction = d.total_milliseconds();
	loggTime("time execution montecarlo algorithm: ",duraction);
	saveToFile();
	//drawSpace();

}
Esempio n. 2
0
void Cmd::handleRequest() {

    switch(getCommand()) {
		case LIST :
			prepareDb();
			executeList();
			break;
		case UPDATE :
			prepareDb();
			executeUpdate();
			break;
		case ACT :
			prepareDb();
			executeAct();
			break;
        case DEACT :
			prepareDb();
            executeDeact();
            break;
        case EXEC :
			prepareDb();
            executeExec();
            break;
        case EVENT :
			prepareDb();
            executeEvent();
            break;
        case VERSION :
        	executeVersion();
		default:
			cons.printError("no command found");
			break;
	}

}
Esempio n. 3
0
static int	processLine(char *line, int lineLength)
{
	int	tokenCount;
	char	*cursor;
	int	i;
	char	*tokens[9];

	tokenCount = 0;
	for (cursor = line, i = 0; i < 9; i++)
	{
		if (*cursor == '\0')
		{
			tokens[i] = NULL;
		}
		else
		{
			findToken(&cursor, &(tokens[i]));
			tokenCount++;
		}
	}

	if (tokenCount == 0)
	{
		return 0;
	}

	/*	Skip over any trailing whitespace.			*/

	while (isspace((int) *cursor))
	{
		cursor++;
	}

	/*	Make sure we've parsed everything.			*/

	if (*cursor != '\0')
	{
		printText("Too many tokens.");
		return 0;
	}

	/*	Have parsed the command.  Now execute it.		*/

	switch (*(tokens[0]))		/*	Command code.		*/
	{
		case 0:			/*	Empty line.		*/
		case '#':		/*	Comment.		*/
			return 0;

		case '?':
		case 'h':
			printUsage();
			return 0;

		case 'a':
			executeAdd(tokenCount, tokens);
			return 0;

		case 'c':
			executeChange(tokenCount, tokens);
			return 0;

		case 'd':
			executeDelete(tokenCount, tokens);
			return 0;

		case 'i':
			executeInfo(tokenCount, tokens);
			return 0;

		case 'l':
			executeList(tokenCount, tokens);
			return 0;

		case 'e':
			switchEcho(tokenCount, tokens);
			return 0;

		case 'q':
			return -1;	/*	End program.		*/

		default:
			printText("Invalid command.  Enter '?' for help.");
			return 0;
	}
}