예제 #1
0
void MainWindow::createMenus()
{
  QMenu   *menu;
  QAction *action;

  menu = getStandardMenu(FileMenu);
  menu->addAction(standardAction(New));
  menu->addAction(standardAction(Edit));
  menu->addAction(standardAction(Print));
  menu->addAction(standardAction(Edit));
  menu->addSeparator();
  menu->addAction(standardAction(Exit));

  menu = getStandardMenu(EditMenu);
  menu->addAction(standardAction(Undo));
  menu->addAction(standardAction(Redo));
  menu->addSeparator();
  menu->addAction(standardAction(Cut));
  menu->addAction(standardAction(Copy));
  menu->addAction(standardAction(Paste));
  menu->addSeparator();
  menu->addAction(standardAction(Delete));

  menu = getStandardMenu(SettingsMenu);
  action = menu->addAction(_("Common..."));
  connect(action, SIGNAL(triggered()), this, SLOT(commonSettings()));

  addStandardMenu(HelpMenu);
}
예제 #2
0
void MainWindow::createMenus()
{
  QMenu   *menu;
  QAction *action;

  menu = getStandardMenu(FileMenu);
  //menu->addSeparator();
  menu->addAction(standardAction(Exit));

  menu = getStandardMenu(SettingsMenu);
  action = menu->addAction(_("Common..."));
  connect(action, SIGNAL(triggered()), this, SLOT(commonSettings()));

  addStandardMenu(HelpMenu);
}
double runAlgoSequence(AlgoDescriptor const* descriptor, GMMDesc initialSolution, double initialTime,
	std::string const& outputDir, std::string const& outputFile)
{
	// Initialize output
	std::stringstream pathStream;
	pathStream << outputDir << "/csv";
	boost::filesystem::path outPath(pathStream.str());
	boost::filesystem::create_directories(outPath);
	std::stringstream filenameStream;
	filenameStream << pathStream.str() << "/" << outputFile;
	ioutil::openStatisticFile(filenameStream.str());


	// compute maximum spread
	Vector spreads = (input.points.rowwise().maxCoeff()
					 -input.points.rowwise().minCoeff());
					 
	if (commonSettings().verbose)
		std::cout << "maximum spread is " << spreads.maxCoeff() << std::endl;

	// Initialisation
	double totaltime = initialTime;
	GMMDesc last = initialSolution;

	// handle initial solution
	handleSolution(0, last, totaltime, true);

	// start computation of new algorithm sequence
	std::cout << "starting new algorithm sequence:" << std::endl;
			  
	AlgoDescriptor const* nextAlgo = descriptor;
	std:size_t roundOffset = 0;
	std::vector<std::size_t> finalRounds;
	std::vector<double> finalTimes;
	while (nextAlgo!=NULL)
	{
		std::cout << "creating algorithm from descriptor: "
				  << nextAlgo->tag() << std::endl;
				  
		GMMAlgorithm* algorithm = nextAlgo->create(input);
		algorithm->init(last);
		
		// run current algorithm
		for (std::size_t i=0; i<nextAlgo->steps(); ++i)
		{
			algorithm->run();
			handleSolution(roundOffset+i+1, algorithm->getGMMDesc(),
				algorithm->getRuntime()+totaltime, algorithm->hasChanged());
		}
		
		// Save results and delete algorithm
		last = algorithm->getGMMDesc();
		roundOffset += nextAlgo->steps();
		totaltime += algorithm->getRuntime();
		finalRounds.push_back(roundOffset);
		finalTimes.push_back(totaltime);
		std::cout << "   computation took " << algorithm->getRuntime() << " seconds." << std::endl;

		delete algorithm;

		nextAlgo = nextAlgo->getNext();
	}
	std::cout << std::endl;

	if (ioutil::StatisticFileIsOpen())
	{
		// Store statistics markers
		ioutil::storeStatisticMarkerVector(finalRounds, finalTimes, mincost_round, mincost_runtime);

		// Print overall results
		if (!truth.empty())
			std::cout << "         cost of truth = " << getCosts(input, truth) << std::endl;
		std::cout << "cost of final solution = " << costs.back() << std::endl;
		std::cout << "     cheapest solution = " << mincost << " after " << mincost_runtime << " seconds" << std::endl;
	}

	std::cout << std::endl;
	
	// Finalize output
	ioutil::closeAllFiles();
	
	return totaltime-initialTime;
}
fp_type getCosts(commonutil::DataSet const& data, GMMDesc const& gmmdesc)
{  		
	if(commonSettings().costmeasure == NLL)
		return gmmutil::nll(input, gmmdesc);
	gmmlab_throw("main_gmmlab::getCosts() - undefined costmeasure")
}