Example #1
0
void ModValueDeltaCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, false, weighted);
	
	for (int x = 2; x <= 10; x++)
	{
		g.Reset();
		printf("==>Compressing (mod-delta) by factor of %d\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, true);
		tse.lookups.push_back({kLeafNode, -0, -0, 0});

		uint64_t oldSize = tse.Get_PDB_Size(g, 8);
		uint64_t newSize = oldSize / x;
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Delta_Compress_PDB(g, 1, true);
		tse.Mod_Compress_PDB(1, newSize, true);
//		tse.lookups.push_back({kLeafModCompress, -0, -0, -0});
//		MeasureIR(tse);
	}
}
Example #2
0
void ExtractPatterns(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, false, weighted);

	tse.ClearPDBs();
	tse.Load_Regular_PDB(getPDB6a(weighted), g, false);
	tse.lookups.push_back({kLeafNode, -0, -0, 0});
	
	tse.Load_Regular_PDB(getPDB7a(weighted), g, false);
	tse.Delta_Compress_PDB(g, 1, true);
	std::vector<int> cutoffs;
	GetBitValueCutoffs(cutoffs, 1);
	tse.Value_Compress_PDB(1, cutoffs, true);
	for (unsigned int x = 0; x < tse.PDB[1].size(); x++)
	{
		tse.GetStateFromPDBHash(x, s, N, tse.PDB_distincts[1]);
		for (int y = 0; y < N; y++)
			printf(" %d", s.puzzle[y]);
		printf(": %d\n", tse.PDB[1][x]);
	}
}
Example #3
0
void ValidateCompressionIdeas(unsigned long , tKeyboardModifier , char)
{
//	const int tiles = 10;
	MNPuzzle tse(3, 3);
	MNPuzzleState s(3, 3), g(3, 3);
//	TopSpin tse(tiles, k);
//	TopSpinState s(tiles, k);
//	TopSpinState g(tiles, k);
//	const int entriesLarge = 4;
//	const int entriesSmall = 3;
	std::vector<int> patternLarge = {1, 2, 3, 4, 5, 6, 7};
	std::vector<int> patternSmall = {1, 2, 3, 4};
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	tse.Build_PDB(s, patternLarge, "tmp", std::thread::hardware_concurrency(), false);
	tse.Build_PDB(s, patternSmall, "tmp", std::thread::hardware_concurrency(), false);
	tse.Min_Compress_PDB(0, 60, true);
	
//	uint64_t count = tse.Get_PDB_Size(s, entriesLarge);
//	for (int x = 0; x < count; x++)
//	{
//		tse.GetStateFromPDBHash(x, s, tiles, patternLarge);
//		uint64_t big = tse.GetPDBHash(s, patternLarge);
//		uint64_t small = tse.GetPDBHash(s, patternSmall);
//		printf("HASH: large: %llu, small: %llu\n", big, small);
//	}
}
Example #4
0
void DivNodesCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, true, weighted);
	
	for (int x = 1; x <= 10; x++)
	{
		g.Reset();
		printf("==>Compressing (div) by factor of %d\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Min_Compress_PDB(0, x, true);
		tse.Load_Regular_PDB(getPDB8b(weighted), g, true);
		tse.Min_Compress_PDB(1, x, true);

		tse.lookups.push_back({kMaxNode, 2, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kLeafMinCompress, static_cast<uint8_t>(x), -0, 0});
		tse.lookups.push_back({kLeafMinCompress, static_cast<uint8_t>(x), -0, 1});

		std::string desc = "DIV-";
		desc += ('0'+x/10);
		desc += ('0'+x%10);
		Test(tse, desc.c_str());
		//MeasureIR(tse);
	}
}
Example #5
0
void BitDeltaValueCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, false, weighted);
	
	for (int x = 1; x <= 4; x*=2)
	{
		g.Reset();
		printf("==>Compressing (value-range-delta) to %d bits\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, false);
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		
		tse.Load_Regular_PDB(getPDB8a(weighted), g, false);
		tse.Delta_Compress_PDB(g, 1, true);
		std::vector<int> cutoffs;
		GetBitValueCutoffs(cutoffs, x);
		tse.Value_Compress_PDB(1, cutoffs, true);
		//MeasureIR(tse);
	}
}
Example #6
0
void ModNodesCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, true, weighted);
	
	for (int x = 2; x <= 10; x++)
	{
		g.Reset();
		printf("==>Compressing (mod) by factor of %d\n", x);
		tse.ClearPDBs();
		uint64_t oldSize = tse.Get_PDB_Size(g, 8);
		uint64_t newSize = oldSize / x;
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8b(weighted), g, true);
		tse.Mod_Compress_PDB(0, newSize, true);
		tse.Mod_Compress_PDB(1, newSize, true);
		tse.lookups.push_back({kMaxNode, 2, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kLeafModCompress, -0, -0, 0});
		tse.lookups.push_back({kLeafModCompress, -0, -0, 1});

		std::string desc = "MOD-";
		desc += ('0'+x/10);
		desc += ('0'+x%10);
		Test(tse, desc.c_str());
	}
}
Example #7
0
void GetBitValueCutoffs(std::vector<int> &cutoffs, int bits)
{
	TopSpin tse(N, k);
	TopSpinState g(N, k);
	g.Reset();
	
	if (tse.GCost(g, 1) != tse.GCost(g, 2)) // non-uniform costs
	{
		switch (bits)
		{
			case 1:
			{
				cutoffs.push_back(0);
				cutoffs.push_back(13);
				//cutoffs.push_back(14);
				cutoffs.push_back(1000); // higher than max value
			} break;
			case 2:
			{
				cutoffs.push_back(0);
				cutoffs.push_back(9);
				cutoffs.push_back(16);
				cutoffs.push_back(22);
//				cutoffs.push_back(0);
//				cutoffs.push_back(10);
//				cutoffs.push_back(17);
//				cutoffs.push_back(23);
				cutoffs.push_back(1000); // higher than max value
			} break;
			case 4:
			{
				cutoffs.push_back(0);
				cutoffs.push_back(2);
				cutoffs.push_back(4);
				cutoffs.push_back(6);
				cutoffs.push_back(8);
				cutoffs.push_back(10);
				cutoffs.push_back(12);
				cutoffs.push_back(14);
				cutoffs.push_back(16);
				cutoffs.push_back(18);
				cutoffs.push_back(20);
				cutoffs.push_back(22);
				cutoffs.push_back(24);
				cutoffs.push_back(26);
				cutoffs.push_back(29);
				cutoffs.push_back(34);
				cutoffs.push_back(1000); // higher than max value
			} break;
			default: printf("Unknown bits\n"); exit(0);
		}
	}
	else {
		for (int x = 0; x <= bits; x++)
			cutoffs.push_back(x);
		cutoffs.push_back(1000);
	}
}
Example #8
0
void MeasureRLE(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, false, weighted);
	
	for (int x = 1; x <= 1; x*=2)
	{
		g.Reset();
		printf("==>Compressing (value-range-delta) to %d bits\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, false);
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		
		tse.Load_Regular_PDB(getPDB8a(weighted), g, false);
		tse.Delta_Compress_PDB(g, 1, true);
		std::vector<int> cutoffs;
		GetBitValueCutoffs(cutoffs, x);
		tse.Value_Compress_PDB(1, cutoffs, true);

		int last = -1;
		int len = 0;
		std::vector<int> lengths(9);
		for (int x = 0; x < tse.PDB[1].size(); x++)
		{
			if (tse.PDB[1][x] == last && len < 8)
			{
				len++;
			}
			else {
				lengths[len]++;
				last = tse.PDB[1][x];
				len = 1;
			}
		}
		lengths[len]++;
		for (int x = 1; x < lengths.size(); x++)
		{
			if (lengths[x] != 0)
				printf("%d\t%d\n", x, lengths[x]);
		}
		//printf("%d ", tse.PDB[1][x]);
		//MeasureIR(tse);
	}
}
Example #9
0
TopSpinState GetInstance(int which, bool weighted)
{
	srandom(which*101+11);
	TopSpin tse(16, 4);
	TopSpinState s(16,4);
	s.Reset();
	int length = 10000;
	for (int x = 0; x < length; x++)
	{
		tse.ApplyAction(s, random()%16);
	}
	return s;
}
Example #10
0
void DivDeltaValueCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	if (!fileExists(getPDB7a(weighted)))
	{
		g.Reset();
		tiles.resize(0);
		for (int x = 0; x <= 6; x++)
			tiles.push_back(x);
		
		tse.Build_PDB(g, tiles, getPDB7a(weighted),
					  std::thread::hardware_concurrency(), false);
		tse.ClearPDBs();
	}
	
	if (!fileExists(getPDB8a(weighted)))
	{
		g.Reset();
		tiles.resize(0);
		for (int x = 0; x < 8; x++)
			tiles.push_back(x);
		
		tse.Build_PDB(g, tiles, getPDB8a(weighted),
					  std::thread::hardware_concurrency(), false);
		tse.ClearPDBs();
	}
	
	for (int x = 2; x <= 10; x++)
	{
		g.Reset();
		printf("==>Compressing (div delta) by factor of %d\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, false);
		tse.lookups.push_back({kLeafNode, -0, -0, 0});

		tse.Load_Regular_PDB(getPDB8a(weighted), g, false);
		tse.Delta_Compress_PDB(g, 1, true);
		tse.Min_Compress_PDB(1, x, true);
		//MeasureIR(tse);
	}
}
Example #11
0
void BitDeltaNodesCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, true, weighted);
	
	for (int x = 2; x <= 4; x*=2)
	{
		std::vector<int> cutoffs;
		GetBitValueCutoffs(cutoffs, x);

		g.Reset();
		printf("==>Compressing to %d bits\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, false); // PDB 0
		tse.Load_Regular_PDB(getPDB8a(weighted), g, false); // PDB 1
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.Delta_Compress_PDB(g, 1, true);
		tse.Value_Range_Compress_PDB(1, x, true);
		tse.Load_Regular_PDB(getPDB7b(weighted), g, false); // PDB 2
		tse.Load_Regular_PDB(getPDB8b(weighted), g, false); // PDB 3
		tse.lookups.back().PDBID = 2;
		tse.Delta_Compress_PDB(g, 3, true);
		//tse.Value_Compress_PDB(3, cutoffs, true);
		tse.Value_Range_Compress_PDB(3, x, true);


		tse.lookups.resize(0);
		tse.lookups.push_back({kMaxNode, 2, 1, -0});
		tse.lookups.push_back({kAddNode, 2, 3, -0});
		tse.lookups.push_back({kAddNode, 2, 5, -0});
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.lookups.push_back({kLeafNode, -0, -0, 1});
		tse.lookups.push_back({kLeafNode, -0, -0, 2});
		tse.lookups.push_back({kLeafNode, -0, -0, 3});

		std::string desc = "VALRNG-";
		desc += ('0'+x/10);
		desc += ('0'+x%10);
		Test(tse, desc.c_str());
	}
}
Example #12
0
void DivDeltaNodesCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, true, weighted);
	
	for (int x = 2; x <= 10; x++)
	{
		g.Reset();
		printf("==>Compressing (div-delta) by factor of %d\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB7b(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8b(weighted), g, true);
		
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.Delta_Compress_PDB(g, 2, true);
		tse.lookups.back().PDBID = 1;
		tse.Delta_Compress_PDB(g, 3, true);
		tse.lookups.resize(0);

		tse.Min_Compress_PDB(2, x, true);
		tse.Min_Compress_PDB(3, x, true);
		
		tse.lookups.push_back({kMaxNode, 2, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kAddNode, 2, 3, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kAddNode, 2, 5, -0}); // max of 2 children starting at 1 in the tree

		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.lookups.push_back({kLeafMinCompress, static_cast<uint8_t>(x), -0, 2});
		tse.lookups.push_back({kLeafNode, -0, -0, 1});
		tse.lookups.push_back({kLeafMinCompress, static_cast<uint8_t>(x), -0, 3});
		
		std::string desc = "DIV-D-";
		desc += ('0'+x/10);
		desc += ('0'+x%10);
		Test(tse, desc.c_str());
	}
}
Example #13
0
void BootstrapDiscovery::run(){
	log() << "Starting bootstrap" << std::endl;
	std::fstream bootstrapfile(ConfigManager::getInstance()->getDirectory()+getValue<std::string>("discovery.bootstrap.filename"));

	std::string peer_readable_tse;

	while(getline(bootstrapfile, peer_readable_tse)){
		transport::SocketEndpoint tse(transport_socket.get());
		try {
			tse.fromString(peer_readable_tse);
			handshake(tse);
		} catch(int e){
			log() << e << std::endl;
		}
	}
}
Example #14
0
//Fractional_Mod_Compress_PDB
void FractionalNodesCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, true, weighted);
	
	for (int x = 2; x <= 10; x++)
	{
		g.Reset();
		printf("==>Fractional (contiguous): Reducing by factor of %d\n", x);
		tse.ClearPDBs();
		uint64_t oldSize = tse.Get_PDB_Size(g, 8);
		uint64_t newSize = oldSize / x;
		tse.Load_Regular_PDB(getPDB7a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB7b(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8b(weighted), g, true);
		tse.Fractional_Compress_PDB(1, newSize, true);
		tse.Fractional_Compress_PDB(3, newSize, true);
		tse.lookups.push_back({kMaxNode, 4, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.lookups.push_back({kLeafFractionalCompress, -0, -0, 1});
		tse.lookups.push_back({kLeafNode, -0, -0, 2});
		tse.lookups.push_back({kLeafFractionalCompress, -0, -0, 3});
		std::string desc = "FCT-C-";
		desc += ('0'+x/10);
		desc += ('0'+x%10);
		Test(tse, desc.c_str());
	}
}
Example #15
0
void BaseHeuristicTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	
	tse.ClearPDBs();
	BuildPDBs(true, true, weighted);
	
	{
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB7b(weighted), g, true);
		tse.lookups.push_back({kMaxNode, 2, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.lookups.push_back({kLeafNode, -0, -0, 1});
		std::string desc = "BASE7-";
		Test(tse, desc.c_str());
	}
	
	{
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8b(weighted), g, true);
		tse.lookups.push_back({kMaxNode, 2, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.lookups.push_back({kLeafNode, -0, -0, 1});
		std::string desc = "BASE8-";
		Test(tse, desc.c_str());
	}
}
Example #16
0
void FractionalModNodesCompressionTest(bool weighted)
{
	std::vector<int> tiles;
	
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();
	
	BuildPDBs(true, true, weighted);
	
	for (int x = 2; x <= 10; x++)
	{
		g.Reset();
		printf("==>Fractional MOD: Reducing by factor of %d\n", x);
		tse.ClearPDBs();
		tse.Load_Regular_PDB(getPDB7a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8a(weighted), g, true);
		tse.Load_Regular_PDB(getPDB7b(weighted), g, true);
		tse.Load_Regular_PDB(getPDB8b(weighted), g, true);
		tse.Fractional_Mod_Compress_PDB(1, x, true);
		tse.Fractional_Mod_Compress_PDB(3, x, true);
		tse.lookups.push_back({kMaxNode, 4, 1, -0}); // max of 2 children starting at 1 in the tree
		tse.lookups.push_back({kLeafNode, -0, -0, 0});
		tse.lookups.push_back({kLeafFractionalModCompress, static_cast<uint8_t>(x), -0, 1}); // factor, -- , id
		tse.lookups.push_back({kLeafNode, -0, -0, 2});
		tse.lookups.push_back({kLeafFractionalModCompress, static_cast<uint8_t>(x), -0, 3});
		std::string desc = "FCT-M-";
		desc += ('0'+x/10);
		desc += ('0'+x%10);
		Test(tse, desc.c_str());
	}
}
Example #17
0
void TSTest(unsigned long , tKeyboardModifier , char)
{
	int N = 16, k = 4;
	std::vector<int> tiles;

	TopSpin tse(N, k);
	TopSpinState s(N, k);
	TopSpinState g(N, k);

//	if (ts->PDB.size() == 0)
//	{
//		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_0-5.pdb", g, true);
//		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_12-15.pdb", g, true);
//		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_6-11.pdb", g, true);
//		tse.lookups.push_back({kMaxNode, 3, 1, 0});
//		tse.lookups.push_back({kLeafNode, 0, 0, 0});
//		tse.lookups.push_back({kLeafNode, 0, 0, 1});
//		tse.lookups.push_back({kLeafNode, 0, 0, 2});
//	}

	if (ts->PDB.size() == 0)
	{
		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_0-3.pdb", g, true);
		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_0-5+.pdb", g, true);
		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_6-9.pdb", g, true);
		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_6-11+.pdb", g, true);
		tse.Load_Regular_PDB("/Users/nathanst/Desktop/TS_12-15.pdb", g, true);
		tse.lookups.push_back({kMaxNode, 3, 1, 0});
		tse.lookups.push_back({kAddNode, 2, 4, 0});
		tse.lookups.push_back({kAddNode, 2, 6, 0});
		tse.lookups.push_back({kLeafNode, 0, 0, 4});
		tse.lookups.push_back({kLeafNode, 0, 0, 0});
		tse.lookups.push_back({kLeafNode, 0, 0, 1});
		tse.lookups.push_back({kLeafNode, 0, 0, 2});
		tse.lookups.push_back({kLeafNode, 0, 0, 3});
	}

	
	IDAStar<TopSpinState, TopSpinAction> ida;
	std::vector<TopSpinAction> path1;


	tse.SetPruneSuccessors(true);
	for (int x = 0; x < 100; x++)
	{
		GetTSInstance(tse, s, x);
		std::cout << "Problem " << x << std::endl;
		std::cout << "Searching from: " << std::endl << s << std::endl << g << std::endl;
		Timer t;
		t.StartTimer();
		ida.GetPath(&tse, s, g, path1);
		t.EndTimer();
		std::cout << "Path found, length " << path1.size() << " time:" << t.GetElapsedTime() << " ";
		std::cout << ida.GetNodesExpanded() << " nodes expanded" << std::endl;
//		for (int x = 0; x < ts->histogram.size(); x++)
//		{
//			printf("%2d  %d\n", x, ts->histogram[x]);
//		}
		
//		tse.PrintHStats();
	}
}
Example #18
0
bool UsingWeighted()
{
	TopSpin tse(N, k);
	TopSpinState g(N, 4);
	return (tse.GCost(g, 1) != tse.GCost(g, 2));
}
Example #19
0
void BuildPDBs(bool aPDBs, bool bPDBs, bool weighted)
{
	TopSpin tse(N, k);
	tse.SetWeighted(weighted);
	std::vector<int> tiles;
	
	TopSpinState s(N, k);
	TopSpinState g(N, k);
	
	tse.StoreGoal(g);
	tse.ClearPDBs();

	if (aPDBs)
	{
		if (!fileExists(getPDB6a(weighted)))
		{
			g.Reset();
			tiles.resize(0);
			//for (int x = 0; x <= 12; x+=2)
			for (int x = 0; x <= 5; x++)
				tiles.push_back(x);
			
			tse.Build_PDB(g, tiles, getPDB6a(weighted),
						  std::thread::hardware_concurrency(), false);
			tse.ClearPDBs();
		}

		if (!fileExists(getPDB7a(weighted)))
		{
			g.Reset();
			tiles.resize(0);
			//for (int x = 0; x <= 12; x+=2)
			for (int x = 0; x <= 6; x++)
				tiles.push_back(x);
			
			tse.Build_PDB(g, tiles, getPDB7a(weighted),
						  std::thread::hardware_concurrency(), false);
			tse.ClearPDBs();
		}
		
		if (!fileExists(getPDB8a(weighted)))
		{
			g.Reset();
			tiles.resize(0);
			//for (int x = 0; x <= 14; x+=2)
			for (int x = 0; x <= 7; x++)
				tiles.push_back(x);
			
			tse.Build_PDB(g, tiles, getPDB8a(weighted),
						  std::thread::hardware_concurrency(), false);
			tse.ClearPDBs();
		}
	}
	
	if (bPDBs)
	{
		if (!fileExists(getPDB6b(weighted)))
		{
			g.Reset();
			tiles.resize(0);
			for (int x = 8; x <= 13; x++)
				//for (int x = 1; x <= 14; x+=2)
				tiles.push_back(x);
			
			tse.Build_PDB(g, tiles, getPDB6b(weighted),
						  std::thread::hardware_concurrency(), false);
			tse.ClearPDBs();
		}

		if (!fileExists(getPDB7b(weighted)))
		{
			g.Reset();
			tiles.resize(0);
			for (int x = 8; x <= 14; x++)
				//for (int x = 1; x <= 14; x+=2)
				tiles.push_back(x);
			
			tse.Build_PDB(g, tiles, getPDB7b(weighted),
						  std::thread::hardware_concurrency(), false);
			tse.ClearPDBs();
		}
		
		if (!fileExists(getPDB8b(weighted)))
		{
			g.Reset();
			tiles.resize(0);
			for (int x = 8; x <= 15; x++)
			//for (int x = 1; x <= 15; x+=2)
				tiles.push_back(x);
			
			tse.Build_PDB(g, tiles, getPDB8b(weighted),
						  std::thread::hardware_concurrency(), false);
			tse.ClearPDBs();
		}
	}
}
Example #20
0
void DbEntry::addExtRef(DbEntry* dbe)
{
    DbListSeek tse(e_DbList::tExtRef, dbe);
    if (entries.seekptr(&tse) == 0)
        entries.append(new e_DbList(dbe));
}