Exemplo n.º 1
0
UserPaths::UserPaths() : Config()
{
	#ifdef WITH_BOOST_PROGRAM_OPTIONS
		initBoostOptions();
	#endif // WITH_BOOST_PROGRAM_OPTIONS

	// try to read the data from the home directory
	// FIXME this is most likely _not_ portable
	char *home_dir = getenv("HOME");
	std::string backup;
	if (home_dir == NULL) { // happens with WIN32
		backup = "C:/temp/";
		home_dir = const_cast<char *>(backup.c_str());
	}
		
	std::stringstream vole_config_file;
	vole_config_file << home_dir << "/.vole.cfg";

	std::string cfg_file = vole_config_file.str();

	if (FilesystemHelpers::file_exists(cfg_file)) {
		readConfig(cfg_file.c_str());
	} else {
		std::cerr << "vole global config file " << cfg_file << " not found, created standard config file; please check the paths if they suit your needs" << std::endl;
		// FIXME again highly unportable
// FIXME
#ifdef __unix__
		char *working_dir = get_current_dir_name();
		verbosity = 1;
		gvole_config_root = std::string(working_dir);
		gvole_data_root = "/disks/data1/riess/gvole_data";
		if (!storeConfig(cfg_file.c_str()) || (errno != 0)) {
			std::stringstream error_msg_stream;
			error_msg_stream << "unable to create config file " << cfg_file
				<< ", no config written" << std::endl;
			std::string error_msg = error_msg_stream.str();
			std::cerr << error_msg;
			free(working_dir);
			throw error_msg;
		}
		free(working_dir);
		std::exit(1);
// #else
		verbosity = 1;
		std::cout << "working_dir not used, creating .vole.cfg in (home?? ) directory " << home_dir << std::endl;
		gvole_config_root = std::string(home_dir);
		gvole_data_root = "/disks/data1/riess/gvole_data";
		if (!storeConfig(cfg_file.c_str()) || (errno != 0)) {
			std::stringstream error_msg_stream;
			error_msg_stream << "unable to create config file " << cfg_file
				<< ", no config written" << std::endl;
			std::string error_msg = error_msg_stream.str();
			std::cerr << error_msg;
			throw error_msg;
		}
#else
#endif
	}
}
Exemplo n.º 2
0
void GridFitter::GradientDescent::optimize()
{
	const size_t num = std::min(_settings.gradient_num_initial, _initialCandidates.size());
	candidate_set::iterator candidate_it = _initialCandidates.begin();
	// iterate over the settings.numInitial best initial candidates
	for (size_t idx = 0; idx < num; ++idx) {
		candidate_t candidate = *candidate_it;
		const Util::gridconfig_t& initial_config = candidate.config;

		size_t iteration = 0;
		PipelineGrid grid(initial_config);
		Util::gridconfig_t config = initial_config;
		double error = evaluateCandidate(grid, _roi, _binarizedRoi, _edgeRoiX, _edgeRoiY, _settings);
		storeConfig(error, config);

		candidate_set bestGridsForCandidate;
		bestGridsForCandidate.insert(candidate);

		std::array<StepParameter, 6> parameters { SCALE, POSX, POSY, ANGLE_X, ANGLE_Y, ANGLE_Z };

		// gradient descent
		size_t numWithoutImprovement = 0;
		while ((error > _settings.gradient_error_threshold) && (iteration < _settings.gradient_max_iterations)) {
			double const initerror = error;

			// shuffle order of parameters
			//std::shuffle(parameters.begin(), parameters.end(), _random_engine);
			for (const StepParameter param : parameters) {
				std::tie(error, config) = step(bestGridsForCandidate, config, error, param);
			}

			++iteration;
			// abort gradient descent if error measurement did not improve by
			// a significant amount during the last six steps
			assert(!bestGridsForCandidate.empty());
			if ((initerror - bestGridsForCandidate.begin()->error) < 0.0001) {
				++numWithoutImprovement;
				if (numWithoutImprovement >= 5) break;
			} else {
				numWithoutImprovement = 0;
			}

			// instead of continuing the next iteration with the result of the
			// last step, use the best currently found config from now on.
			error  = bestGridsForCandidate.begin()->error;
			config = bestGridsForCandidate.begin()->config;
		}
		assert(!bestGridsForCandidate.empty());
		storeConfig(bestGridsForCandidate.begin()->error, bestGridsForCandidate.begin()->config);
		++candidate_it;
	}
}
Exemplo n.º 3
0
void EpgConfigDialog::storeConfig()
{
	for (std::map<eString, Config>::const_iterator it=configItems.begin(); it != configItems.end(); ++it)
	{
		storeConfig(it->second);
	}
}
Exemplo n.º 4
0
void EpgConfigDialog::OnOkClicked()
{
	getCurrentVals();

	storeConfig();
	close(0);
}
Exemplo n.º 5
0
int run_mainMenu()
{
#if defined(AUTO_RUN) || defined(AUTO_FRAMERATE) || defined(AUTO_PROFILER)
	return 1;
#else
#if !defined(DEBUG_UAE4ALL) && !defined(PROFILER_UAE4ALL)
	static enum MainMenuEntry c = MAIN_MENU_ENTRY_LOAD;
#else
	static enum MainMenuEntry c = MAIN_MENU_ENTRY_SOUND;
#endif

	while (1)
	{
		enum MainMenuEntry action = MAIN_MENU_ENTRY_NONE;
		raise_mainMenu();
		while (action == MAIN_MENU_ENTRY_NONE)
		{
			draw_mainMenu(c);
			action = key_mainMenu(&c);
		}
		unraise_mainMenu();
		switch (action)
		{
			case MAIN_MENU_ENTRY_SAVED_STATES:
#ifndef NO_SAVE_MENU
				run_menuSave();
				if (savestate_state == STATE_DORESTORE || savestate_state == STATE_DOSAVE)
					return 1; /* leave, returning to the emulation */
#endif
				break;
			case MAIN_MENU_ENTRY_LOAD:
				run_menuDfSel();
				break;
			case MAIN_MENU_ENTRY_RESET_EMULATION:
				if (emulating)
					return 2; /* leave, resetting */
				/* Fall through */
			case MAIN_MENU_ENTRY_RETURN_TO_EMULATION:
				return 1; /* leave, returning to the emulation */
			case MAIN_MENU_ENTRY_EXIT_UAE:
				storeConfig();
#ifdef DREAMCAST
//malloc(16*1024*1024);
				arch_reboot();
#else
				do_leave_program();
				exit(0);
#endif
				break;
		}
	}
#endif
}
Exemplo n.º 6
0
void EpgConfigDialog::OnRetrieveClicked(void)
{
	if (currentCfg)
	{
		getCurrentVals();
		/* now ensure the configfile is up to date, before we start retrieval. Retrieve scripts might use some of our configvalues. */
		storeConfig(*currentCfg);
		if (currentCfg->isValid())
		{
			FileMap fm(configPath, currentCfg->getMapFile(), currentCfg->getType());
			RetrievalWnd w("Retrieving data, please wait...", currentCfg->getCommand(), fm.getMappedCount()); //add command to execute....
			w.show();
			w.exec();
			w.hide();
		}
	}
}
Exemplo n.º 7
0
void ToolsConfigWidget::accept()
{
    storeConfig();
}