本文整理汇总了C++中Experiment::GetGoalX方法的典型用法代码示例。如果您正苦于以下问题:C++ Experiment::GetGoalX方法的具体用法?C++ Experiment::GetGoalX怎么用?C++ Experiment::GetGoalX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Experiment
的用法示例。
在下文中一共展示了Experiment::GetGoalX方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintNthExperiment
void ScenarioConverter::PrintNthExperiment( int n )
{
char old_start, old_goal;
int start_x, start_y, goal_x, goal_y;
Experiment exp = this->scen->GetNthExperiment( n );
start_x = exp.GetStartX();
start_y = exp.GetStartY();
goal_x = exp.GetGoalX();
goal_y = exp.GetGoalY();
old_start = this->map[start_y][start_x];
old_goal = this->map[goal_y][goal_x];
this->map[start_y][start_x] = '@';
this->map[goal_y][goal_x] = '*';
this->PrintMap();
this->map[start_y][start_x] = old_start;
this->map[goal_y][goal_x] = old_goal;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
//.........这里部分代码省略.........
示例6: 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);
}
示例7: main
//.........这里部分代码省略.........
}
mp = new Map(mname);
if(exp.GetXScale() <= 0) {
printf("Invalid scaling\n");
//exit(-1);
delete mp;
continue;
}
currentMap = (string)(mname);
currentScaleX = exp.GetXScale();
currentScaleY = exp.GetYScale();
mp->scale(exp.GetXScale(), exp.GetYScale());
g = GraphSearchConstants::GetGraph(mp);
heuristic = new GraphMapInconsistentHeuristic(mp, g);
env = new GraphEnvironment(g,heuristic); //
}
//mp = new Map(mname);
//// need to scale the map !
//if(exp.GetXScale() <= 0) {
// printf("Invalid scaling\n");
// exit(-1);
//}
//mp->scale(exp.GetXScale(), exp.GetYScale());
//g = GetMapGraph(mp);
// identify from & to
graphState from, to;
from = mp->getNodeNum(exp.GetStartX(),exp.GetStartY());
to = mp->getNodeNum(exp.GetGoalX(),exp.GetGoalY());
int bid = exp.GetBucket();
//maxDiffX[bid] = (int)max(maxDiffX[bid],abs(exp.GetStartX()-exp.GetGoalX()));
//maxDiffY[bid] = (int)max(maxDiffY[bid],abs(exp.GetStartY()-exp.GetGoalY()));
//printf("scene=%s,iexp=%d\n",scenfile,iexp);
Prop A(PROP_A);
Prop B(PROP_B);
Prop BP(PROP_BP);
Prop BPMX1(PROP_BPMX);
Prop BPMX2(PROP_BPMX);
BPMX2.bpmxLevel = 2;
Prop BPMX3(PROP_BPMX);
BPMX3.bpmxLevel = 3;
Prop BPMXi(PROP_BPMX);
BPMXi.bpmxLevel = 65536;
AStarDelay asd(0);
AStarDelay asdmx(1);
AStarDelay asdmxinf(65536);
Prop DP(PROP_DP);
DP.bpmxLevel = 0;
Prop DPMX(PROP_DP);
DPMX.bpmxLevel = 1;
Prop DPDL2MX(PROP_DPDLMX);
//alg0.bpmxLevel = 1;