Beispiel #1
0
void SRLBaselineExt::open_select_config(string selectConfig)
{
    ifstream conf_input(selectConfig.c_str());
    if (!conf_input)
    {
        throw runtime_error("select_config file cannot open!");
    }
    m_srlSelectFeatures.clear();
    string line;
    while (getline(conf_input, line))
    {
        if ("" != line)
        {
            if ('#' == line[0])
            {
                continue;
            }
            vector<string> vec_str;
            replace(line.begin(), line.end(), '+', ' ');
            istringstream istr(line);
            string temp_str;
            while (istr >> temp_str)
            {
                vec_str.push_back(temp_str);
            }
            m_srlSelectFeatures.push_back(vec_str);
        }
    }
    conf_input.close();
}
Beispiel #2
0
void SimManager::init() {
	srand48(_seed);
	srand(_seed);

	ifstream conf_input(_conf_file);
	if(conf_input.good() == false) _IO.die("Can't read configuration file '%s'", _conf_file);

	// here we handle the SIGTERM signal;
	signal (SIGTERM, gbl_terminate);
	signal (SIGABRT, gbl_terminate);
	signal (SIGINT, gbl_terminate);

	char time_scale[256];
	getInputString(&_input, "time_scale", time_scale, 1);
	if(strcmp(time_scale, "linear") == 0) _time_scale = TS_LIN;
	else if(strcmp(time_scale, "log_lin") == 0) _time_scale = TS_LOG_LIN;
	else _IO.die("Time scale '%s' not supported", time_scale);

	char line[512];
	conf_input.getline(line, 512);
	int res = sscanf(line, "t = %lld", &_start_step);
	if(res != 1) _IO.die("The first line of the configuration file is not correct, aborting");
	if(_restart_step_counter != 0) _start_step = 0;

	// init time_scale_manager
	initTimeScale(&_time_scale_manager, _time_scale);

	int tmp;
	getInputInt(&_input, "print_conf_interval", &tmp, 1);
	setTSInterval(&_time_scale_manager, tmp);

	if(_time_scale == TS_LOG_LIN) {
		getInputInt(&_input, "print_conf_ppc", &tmp, 1);
		setTSPPC(&_time_scale_manager, tmp);
	}
	// end

	setTSInitialStep(&_time_scale_manager, _start_step);

	_IO.init();
	_backend->init(conf_input);

	_max_steps = _start_step + _steps;
}