本文整理汇总了C++中Experiment::GetBucket方法的典型用法代码示例。如果您正苦于以下问题:C++ Experiment::GetBucket方法的具体用法?C++ Experiment::GetBucket怎么用?C++ Experiment::GetBucket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Experiment
的用法示例。
在下文中一共展示了Experiment::GetBucket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunExperiments1
// experiments with 0, 10, ..., 100 differential heuristics
void RunExperiments1(ScenarioLoader *sl)
{
std::vector<graphState> aPath;
Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
m->Scale(sl->GetNthExperiment(0).GetXScale(),
sl->GetNthExperiment(0).GetYScale());
Graph *g = GraphSearchConstants::GetGraph(m);
GraphDistanceHeuristic diffHeuristic(g);
diffHeuristic.SetPlacement(kAvoidPlacement);
GraphEnvironment gEnv(g, &diffHeuristic);
gEnv.SetDirected(true);
TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;
for (int z = 0; z <= 10; z++)
{
for (int x = 0; x < sl->GetNumExperiments(); x++)
{
Experiment e = sl->GetNthExperiment(x);
graphState start, goal;
start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
Timer t;
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%d\t%d\t%lld\t%f\n", e.GetBucket(), diffHeuristic.GetNumHeuristics(), taNew.GetNodesExpanded(), t.GetElapsedTime());
}
for (int x = 0; x < 10; x++)
diffHeuristic.AddHeuristic();
}
exit(0);
}
示例2: RunExperiments4
// Compare:
// * 1 random lookup of 10 with BPMX
// * 1 random lookup of 10 without BPMX
// * octile
// * max of 10 heuristics
// * 1 lookup in compressed heuristic
void RunExperiments4(ScenarioLoader *sl)
{
std::vector<graphState> aPath;
Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
m->Scale(sl->GetNthExperiment(0).GetXScale(),
sl->GetNthExperiment(0).GetYScale());
Graph *g = GraphSearchConstants::GetGraph(m);
GraphMapInconsistentHeuristic diffHeuristic(m, g);
diffHeuristic.SetPlacement(kAvoidPlacement);
diffHeuristic.SetMode(kRandom);
GraphEnvironment gEnv(g, &diffHeuristic);
gEnv.SetDirected(true);
TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;
Timer t;
for (int x = 0; x < 10; x++)
diffHeuristic.AddHeuristic();
//diffHeuristic.SetNumUsedHeuristics(diffHeuristic.GetNumHeuristics()/10);
for (int x = 0; x < sl->GetNumExperiments(); x++)
{
Experiment e = sl->GetNthExperiment(x);
graphState start, goal;
start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
printf("%d\t", e.GetBucket());
// N memory -- 1 heuristic
diffHeuristic.SetNumUsedHeuristics(1);
diffHeuristic.SetMode(kMax);
taNew.SetUseBPMX(0);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%df\t%lld\t%f\t%f\t", diffHeuristic.GetNumHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
// N memory -- 10 compressed heuristics no BPMX
diffHeuristic.SetNumUsedHeuristics(10);
diffHeuristic.SetMode(kCompressed);
taNew.SetUseBPMX(0);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%dc\t%lld\t%f\t%f\t", diffHeuristic.GetNumHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
// N memory -- 10 compressed heuristics BPMX 1
diffHeuristic.SetNumUsedHeuristics(10);
diffHeuristic.SetMode(kCompressed);
taNew.SetUseBPMX(1);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%dcb1\t%lld\t%f\t%f\t", diffHeuristic.GetNumHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
// N memory -- 10 compressed heuristics BPMX(°)
diffHeuristic.SetNumUsedHeuristics(10);
diffHeuristic.SetMode(kCompressed);
taNew.SetUseBPMX(1000);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%dcbi\t%lld\t%f\t%f\n", diffHeuristic.GetNumHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
}
exit(0);
}
示例3: RunExperiments5
// Compare:
// * 10 N memory
// * 1...10 regular lookups
// * 1...9 random lookups with and without BPMX
// Only compare on longest problems
void RunExperiments5(ScenarioLoader *sl)
{
std::vector<graphState> aPath;
Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
m->Scale(sl->GetNthExperiment(0).GetXScale(),
sl->GetNthExperiment(0).GetYScale());
Graph *g = GraphSearchConstants::GetGraph(m);
GraphMapInconsistentHeuristic diffHeuristic(m, g);
diffHeuristic.SetPlacement(kAvoidPlacement);
diffHeuristic.SetMode(kRandom);
GraphEnvironment gEnv(g, &diffHeuristic);
gEnv.SetDirected(true);
TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;
Timer t;
for (int x = 0; x < 10; x++)
diffHeuristic.AddHeuristic();
//diffHeuristic.SetNumUsedHeuristics(diffHeuristic.GetNumHeuristics()/10);
for (int x = 0; x < sl->GetNumExperiments(); x++)
{
Experiment e = sl->GetNthExperiment(x);
if (e.GetBucket() != 127)
continue;
graphState start, goal;
start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
printf("%d\t", e.GetBucket());
for (int y = 1; y <= 10; y++)
{
// N memory -- 1 heuristic
diffHeuristic.SetNumUsedHeuristics(y);
diffHeuristic.SetMode(kMax);
taNew.SetUseBPMX(0);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%dmx\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
}
for (int y = 1; y <= 9; y++)
{
for (int z = 0; z <= 1; z++)
{
// N memory -- 1 heuristic
diffHeuristic.SetNumUsedHeuristics(y);
diffHeuristic.SetMode(kRandom);
taNew.SetUseBPMX(z);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
if (z==0)
printf("%drnd\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
else
printf("%drdb\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
}
}
printf("\n");
}
exit(0);
}
示例4: RunExperiments
// Compare:
// * 10 N memory
// * 100 compressed heuristics
void RunExperiments(ScenarioLoader *sl, int memory)
{
std::vector<graphState> aPath;
Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
m->Scale(sl->GetNthExperiment(0).GetXScale(),
sl->GetNthExperiment(0).GetYScale());
Graph *g = GraphSearchConstants::GetGraph(m);
GraphMapInconsistentHeuristic diffHeuristic(m, g);
GraphMapInconsistentHeuristic diff1(m, g);
diffHeuristic.SetPlacement(kAvoidPlacement);
diffHeuristic.SetMode(kRandom);
diff1.SetPlacement(kAvoidPlacement);
diff1.SetMode(kMax);
GraphEnvironment gEnv(g, &diffHeuristic);
gEnv.SetDirected(true);
GraphEnvironment gEnv2(g, &diff1);
gEnv2.SetDirected(true);
TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;
Timer t;
for (int x = 0; x < memory; x++)
diffHeuristic.AddHeuristic();
diffHeuristic.SetNumUsedHeuristics(memory);
diffHeuristic.Compress();
diff1.AddHeuristic();
diff1.SetNumUsedHeuristics(1);
for (int x = 0; x < sl->GetNumExperiments(); x++)
{
Experiment e = sl->GetNthExperiment(x);
// if (e.GetBucket() < 100)
// continue;
graphState start, goal;
start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
printf("%d\t", e.GetBucket());
// 10N memory -- 10 heuristics
// diffHeuristic.SetNumUsedHeuristics(1);
// diffHeuristic.SetMode(kMax);
// taNew.SetUseBPMX(0);
//
// t.StartTimer();
// taNew.GetPath(&gEnv, start, goal, aPath);
// t.EndTimer();
// printf("%dmx\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
// taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
// diffHeuristic.SetNumUsedHeuristics(memory);
// diffHeuristic.SetMode(kCompressed);
// taNew.SetUseBPMX(0);
// t.StartTimer();
// taNew.GetPath(&gEnv, start, goal, aPath);
// t.EndTimer();
// printf("%dcmp\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
// taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
// diffHeuristic.SetNumUsedHeuristics(memory);
// diffHeuristic.SetMode(kCompressed);
taNew.SetUseBPMX(0);
t.StartTimer();
taNew.GetPath(&gEnv2, start, goal, aPath);
t.EndTimer();
printf("%dbx1\t%lld\t%f\t%f\t", diff1.GetNumUsedHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
taNew.SetUseBPMX(0);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%dbx1\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
taNew.SetUseBPMX(1);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%dbx1\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
// diffHeuristic.SetNumUsedHeuristics(memory);
// diffHeuristic.SetMode(kCompressed);
// taNew.SetUseBPMX(1000);
//.........这里部分代码省略.........
示例5: RunExperiments2
// experiments with 0, 10, ..., 100 differential heuristics
// 10% of them are used at each step with and without BPMX
void RunExperiments2(ScenarioLoader *sl)
{
std::vector<graphState> aPath;
Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
m->Scale(sl->GetNthExperiment(0).GetXScale(),
sl->GetNthExperiment(0).GetYScale());
Graph *g = GraphSearchConstants::GetGraph(m);
GraphMapInconsistentHeuristic diffHeuristic(m, g);
diffHeuristic.SetPlacement(kAvoidPlacement);
diffHeuristic.SetMode(kRandom);
GraphEnvironment gEnv(g, &diffHeuristic);
gEnv.SetDirected(true);
TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;
Timer t;
for (int z = 0; z < 1; z++)
{
for (int x = 0; x < 10; x++)
diffHeuristic.AddHeuristic();
diffHeuristic.SetNumUsedHeuristics(diffHeuristic.GetNumHeuristics()/10);
for (int x = 0; x < sl->GetNumExperiments(); x++)
{
Experiment e = sl->GetNthExperiment(x);
// if (e.GetBucket() != 127)
// { continue; }
graphState start, goal;
start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
// taNew.SetUseBPMX(false);
// Timer t;
// t.StartTimer();
// taNew.GetPath(&gEnv, start, goal, aPath);
// t.EndTimer();
//
// printf("%d\t%d.%d\t%d\t%f\t\t%f\n", e.GetBucket(), diffHeuristic.GetNumHeuristics(), diffHeuristic.GetNumHeuristics()/10,
// taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
for (int y = 1; y < 6; y++)
{
if (y == 5)
taNew.SetUseBPMX(1000);
else
taNew.SetUseBPMX(y);
t.StartTimer();
taNew.GetPath(&gEnv, start, goal, aPath);
t.EndTimer();
printf("%d\t%d.%d\t%lld\t%f\tBPMX\t%f\n", e.GetBucket(), diffHeuristic.GetNumHeuristics(), y,
taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
}
}
}
exit(0);
}
示例6: main
int main(int argc, char* argv[])
{
char scenfile[1024];
char line[1024];
processArgs(argc,argv);
// Note: bid*4 is the actual bucket value
// init stat collection here !
hash_map<int, vector<vector<IncStat> > > stat; // [bid][alg][scenid]
hash_map<int, int> maxDiffX; // [bid]
hash_map<int, int> maxDiffY; // [bid]
FILE* catelog = fopen(filelist,"r");
if(catelog == 0)
exit(-1);
while(1) {
if(fgets(line,1024,catelog)==0)
break;
remove_newline(line);
if(strlen(line)==0)
continue;
sprintf(scenfile,"scenarios/%s",line);
ScenarioLoader* sl;
sl = new ScenarioLoader(scenfile);
if(sl->GetNumExperiments()==0)
{
std::cout<<"No experiments in this scenario file or invalid file:"<<scenfile<<endl;
//exit(1);
delete sl;
continue;
}
//fprintf(stderr,"line=%s\n",line);
vector<IncStat> tmp;
for(int iexp=0;iexp<sl->GetNumExperiments();iexp++) {
Experiment exp = sl->GetNthExperiment(iexp);
if(stat[exp.GetBucket()].size() > 0)
continue;
for(int i=0;i<=MAX_ALG_ID;i++) {// we have 9 algs
stat[exp.GetBucket()].push_back(tmp);
}
}
delete sl;
}
Graph* g=0;
Map* mp=0;
GraphMapInconsistentHeuristic* heuristic = 0;
GraphEnvironment* env=0;
string currentMap;
int currentScaleX=-1;
int currentScaleY=-1;
fclose(catelog);
catelog = fopen(filelist,"r");
while(1)
{
if(fgets(line,1024,catelog)==0)
break;
remove_newline(line);
if(strlen(line)==0)
continue;
sprintf(scenfile,"scenarios/%s",line);
ScenarioLoader* sl;
vector<graphState> thePath;
sl = new ScenarioLoader(scenfile);
if(sl->GetNumExperiments()==0)
{
std::cout<<"No experiments in this scenario file or invalid file.\n";
//exit(1);
delete sl;
continue;
}
// init buckets
//hash_map<int, vector<vector<InconsistStat> > > statBuckets; // [bucket][alg][item]
//for(int iexp=0;iexp<sl->GetNumExperiments();iexp++) {
// Experiment exp = sl->GetNthExperiment(iexp);
// if(statBuckets[exp.GetBucket()].size() > 0)
// continue;
// for(int i=0;i<10;i++) {// we have 9 algs
// vector<InconsistStat> tmp;
// statBuckets[exp.GetBucket()].push_back(tmp);
// }
//}
char datapath[100];
sprintf(datapath,"outputs/DB%d.dat.AOct",GraphMapInconsistentHeuristic::HN);
//.........这里部分代码省略.........