コード例 #1
0
ファイル: diff_restore.cpp プロジェクト: AMDmi3/osm2go
static void test_osmChange(osm_t::ref osm, const char *fn)
{
   xmlDocGuard doc(osmchange_init());
  const char *changeset = "42";

  osmchange_delete(osm->modified(), xmlDocGetRootElement(doc.get()), changeset);

  xmlChar *result;
  int len;
  xmlDocDumpFormatMemoryEnc(doc.get(), &result, &len, "UTF-8", 1);

  compare_with_file(result, len, fn);
  xmlFree(result);
}
コード例 #2
0
ファイル: phsp.cpp プロジェクト: rionda/wiggins
int main(int argc, char *argv[]) {
	clock_t start = clock();
	/*
		Parsing the arguments
	*/
	string TASK, filename, SFILE, TFILE;
	uint64_t len_samp, len_test;

	int num_iter = 51, probes, num_simuls = 1, ind; 
	double epsilon = 0.1, theta = 0.75;

	for (int i=0; i<argc; ++i) {			
		if (! strcmp(argv[i],"-TASK")) {			
			TASK = argv[i+1];
		} else if (! strcmp(argv[i],"-SAMPLE")) {
			len_samp = stoi(argv[i+1]);
		} else if (! strcmp(argv[i],"-TEST")) {
			len_test = stoi(argv[i+1]);
		} else if (! strcmp(argv[i],"-DIR")) {
			filename = argv[i+1];
			filename +=  "graph";			
		} else if (! strcmp(argv[i],"-EPSILON")) {
			epsilon = stod(argv[i+1]);
		} else if (! strcmp(argv[i],"-THETA")) {
			theta = stod(argv[i+1]);
		} else if (! strcmp(argv[i],"-NUM_ITER")) {
			num_iter = stod(argv[i+1]);
		} else if (! strcmp(argv[i],"-PROBES")) {
			probes = stod(argv[i+1]);
		} else if (! strcmp(argv[i],"-NUM_SIMULS")) {
			num_simuls = stod(argv[i+1]);
		} else if (! strcmp(argv[i],"-IND")) {
			ind = stod(argv[i+1]);
		} else if (! strcmp(argv[i],"-SAMPLE_FILE")) {
			SFILE = argv[i+1];
		} else if (! strcmp(argv[i],"-TEST_FILE")) {
			TFILE = argv[i+1];
		}

	}

	/*
		Running the tasks
	*/



	if (TASK == "sampler") {
		Graph g(filename, theta);
		sampler(g, my_get_dir_name(filename), len_samp);
	} else if (TASK == "auto_sampler") {
		Graph g(filename, theta);
		len_samp = getAutoLenSamp(g.number_of_nodes, epsilon, theta); // computing the sample size
		sampler(g, my_get_dir_name(filename), len_samp);

	} else if (TASK == "indexed_sampler") {
		Graph g(filename, theta);
		indexed_sampler(g, my_get_dir_name(filename), len_samp, ind);

	} else if (TASK == "auto_indexed_sampler") {
		Graph g(filename, theta);
		len_samp = getAutoLenSamp(g.number_of_nodes, epsilon, theta); // computing the sample size
		indexed_sampler(g, my_get_dir_name(filename), len_samp, ind);		

	} else if (TASK == "solver") {
		string samp_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_samp);
		solver(samp_file, theta, num_iter, probes);	

	} else if (TASK == "auto_solver") {
		Graph g(filename, theta);
		len_samp = getAutoLenSamp(g.number_of_nodes, epsilon, theta); // computing the sample size
		string samp_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_samp);
		solver(samp_file, theta, num_iter, probes);	

	} else if (TASK == "solver-with-file") {
		string samp_file = SFILE;
		solver(samp_file, theta, num_iter, probes);	

	} else if (TASK == "indexed_solver") {
		string samp_file = my_get_dir_name(filename)  +"indexed/S-"+to_string(len_samp)+"-"+to_string(ind);
		solver(samp_file, theta, num_iter, probes);	

	} else if (TASK == "tester") {
		string samp_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_samp);
		string test_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_test);
		tester(samp_file, test_file, num_iter, probes, theta);

	} else if (TASK == "indexed_tester") {
		string samp_file = my_get_dir_name(filename)  +"indexed/S-"+to_string(len_samp)+"-"+to_string(ind);
		string test_file = my_get_dir_name(filename)  +"indexed/S-"+to_string(len_test)+"-"+to_string(ind);
		tester(samp_file, test_file, num_iter, probes, theta);
		
	} else if (TASK == "simulator") {
		epsilon = 0.1;
		simulator(filename, num_simuls, num_iter, theta, epsilon);
	
	} else if (TASK == "compare") {
		string samp_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_samp);
		string test_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_test);
		compare(filename, samp_file, test_file, num_iter, probes, theta);	
	} else if (TASK == "compare-with-file") {
		string samp_file = SFILE;
		string test_file = TFILE;
		compare_with_file(samp_file, test_file, num_iter, probes, theta);	
	
	//  -------------------------------
	} else if (TASK == "auto_compare") {
		Graph g(filename, theta);
		len_samp = getAutoLenSamp(g.number_of_nodes, epsilon, theta);
		probes = 1;

		string samp_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_samp);
		string test_file = my_get_dir_name(filename)  +"samples/S-"+to_string(len_samp)+"-"+to_string(ind);
		compare(filename, samp_file, test_file, num_iter, probes, theta);
	
//  ---------------------------------------
	} else if (TASK == "solver_uniform") {
		vector<int> lens = {5,10,20,50,100,200,500,1000,2000,5000,10000,20000};
		// vector<int> lens = {10};
		probes = 1;
		// num_iter = 101;
		theta = 0.99;
		
		string samp_file;
		for (auto l : lens) {
			cout << "working on lenght " << l << ": ";
			for (int idx=0; idx<10; ++idx) {
				samp_file = my_get_dir_name(filename) + "S-" + to_string(l) + "-" + to_string(idx);
				cout << idx << ", ";
				randsolver(samp_file, theta, num_iter, probes);
				// cout << samp_file << endl;
				
			}
			cout << endl;
		}
	} else if (TASK == "cost_uniform") {
		vector<int> lens = {5,10,20,50,100,200,500,1000,2000,5000,10000,20000};
		
		probes = 1;
		// num_iter = 101;
		theta = 0.99;
		
		string samp_file, test_file;
		double c;
		ofstream fout("D100-costs");

		for (auto l : lens) {
			cout << "working on lenght " << l << ": ";
			fout << l << "\t";
			for (int idx=0; idx<10; ++idx) {
				samp_file = my_get_dir_name(filename) + "S-" + to_string(l) + "-" + to_string(idx);
				test_file = my_get_dir_name(filename) + "T";
				// cout << idx << ", ";
				
				c = unif_compare_with_file(samp_file, test_file, num_iter,probes, theta);
				cout << " " << c;
				fout << c << "\t";
				
			}
			cout << endl;
			fout << endl;
		}
		fout.close();

		cout << endl << endl;
		fout.open("D100-vardist");
		for (auto l : lens) {
			cout << "working on lenght " << l << ": ";
			fout << l << "\t";
			for (int idx=0; idx<10; ++idx) {
				samp_file = my_get_dir_name(filename) + "S-" + to_string(l) + "-" + to_string(idx);
				test_file = my_get_dir_name(filename) + "T";
				// cout << idx << ", ";
				
				c = vardist_f(samp_file, test_file, num_iter,probes, theta);
				cout << " " << c;
				fout << c << "\t";
				
			}
			cout << endl;
			fout << endl;
		}
		fout.close();

	}

	clock_t stop = clock();
	cout << "total_time: " << double(stop-start) / CLOCKS_PER_SEC << endl;
	
	return 0;
}