/*private*/ bool LineIntersector::isInSegmentEnvelopes(const Coordinate& intPt) const { Envelope env0(*inputLines[0][0], *inputLines[0][1]); Envelope env1(*inputLines[1][0], *inputLines[1][1]); return env0.contains(intPt) && env1.contains(intPt); }
void runProblemSet2(char *problems, int multiplier) { Map *map = new Map(gDefaultMap); map->Scale(512, 512); msa = new MapSectorAbstraction(map, 8, multiplier); Graph *g = msa->GetAbstractGraph(1); GraphAbstractionHeuristic gah1(msa, 1); GraphDistanceHeuristic localGDH(g); localGDH.SetPlacement(kAvoidPlacement); for (unsigned int x = 0; x < 10; x++) localGDH.AddHeuristic(); GraphHeuristicContainer ghc(g); GraphRefinementEnvironment env1(msa, 1, &localGDH); GraphRefinementEnvironment env2(msa, 1, 0); // ghc.AddHeuristic(&localGDH); // ghc.AddHeuristic(&gah1); env1.SetDirected(false); FILE *f = fopen(problems, "r"); if (f == 0) { printf("Cannot open file: '%s'\n", problems); exit(0); } Timer t; printf("len\tnodes\ttoucht\tlen\ttime\tdiff_n\tdiff_t\tdiff_l\ttime\n"); while (!feof(f)) { int from, to, cost; if (fscanf(f, "%d\t%d\t%d\n", &from, &to, &cost) != 3) break; node *s1 = g->GetNode(from); node *g1 = g->GetNode(to); graphState gs, gg; gs = s1->GetNum(); gg = g1->GetNum(); std::vector<graphState> thePath; t.StartTimer(); astar.GetPath(&env2, gs, gg, thePath); t.EndTimer(); printf("%d\t", cost); printf("%llu\t%llu\t%1.2f\t%e\t", astar.GetNodesExpanded(), astar.GetNodesTouched(), env1.GetPathLength(thePath), t.GetElapsedTime()); t.StartTimer(); astar.GetPath(&env1, gs, gg, thePath); t.EndTimer(); printf("%llu\t%llu\t%1.2f\t%e", astar.GetNodesExpanded(), astar.GetNodesTouched(), env1.GetPathLength(thePath), t.GetElapsedTime()); printf("\n"); } fclose(f); exit(0); }
void test_vector_ifft() { logMsg("playing IFFT crossfade..."); IFFT vox1, vox2; vox1.set_bin_mag_phase(2, 0.25, 0); vox1.set_bin_mag_phase(4, 0.25, 0); vox2.set_bin_mag_phase(6, 0.25, 0); vox2.set_bin_mag_phase(8, 0.25, 0); LineSegment env1(3, 1, 0); // fade out LineSegment env2(3, 0, 1); // fade in MulOp mul1(vox1, env1); MulOp mul2(vox2, env2); AddOp add3(mul1, mul2); run_test(add3); logMsg("IFFT crossfade done."); }
void runProblemSet(char *problems, int multiplier) { Map *map = new Map(gDefaultMap); map->Scale(512, 512); msa = new MapSectorAbstraction(map, 8, multiplier); Graph *g = msa->GetAbstractGraph(1); GraphAbstractionHeuristic gah2(msa, 2); GraphAbstractionHeuristic gah1(msa, 1); GraphRefinementEnvironment env2(msa, 2, &gah2); GraphRefinementEnvironment env1(msa, 1, &gah1); env1.SetDirected(false); env2.SetDirected(false); FILE *f = fopen(problems, "r"); if (f == 0) { printf("Cannot open file: '%s'\n", problems); exit(0); } printf("len\tlvl2n\tlvl2nt\tlvl2len\tlvl2tim\tlvl1nf\tlvl1ntf\tlvl1tn\tlvl1tt\tlvl1len_f\ttot\ttott\ttot_len\n"); Timer t; while (!feof(f)) { int from, to, cost; if (fscanf(f, "%d\t%d\t%d\n", &from, &to, &cost) != 3) break; node *s1 = g->GetNode(from); node *g1 = g->GetNode(to); node *s2 = msa->GetParent(s1); node *g2 = msa->GetParent(g1); uint64_t nodesExpanded = 0; uint64_t nodesTouched = 0; double totalTime = 0; // printf("Searching from %d to %d in level 1; %d to %d in level 2\n", // s1->GetNum(), g1->GetNum(), s2->GetNum(), g2->GetNum()); graphState gs1, gs2; gs1 = s2->GetNum(); gs2 = g2->GetNum(); std::vector<graphState> thePath; std::vector<graphState> abstractPath; t.StartTimer(); astar.GetPath(&env2, gs1, gs2, abstractPath); totalTime = t.EndTimer(); printf("%d\t", cost); printf("%llu\t%llu\t%1.2f\t%f\t", astar.GetNodesExpanded(), astar.GetNodesTouched(), env2.GetPathLength(abstractPath), totalTime); if (abstractPath.size() == 0) { printf("%llu\t%llu\t%llu\t%llu\t%1.2f\t%f\t", (uint64_t)0, (uint64_t)0, astar.GetNodesExpanded(), astar.GetNodesTouched(), 0.0, 0.0); printf("%llu\t%llu\t%1.2f\t%f\t%d\t%d\n", astar.GetNodesExpanded(), astar.GetNodesTouched(), 0.0, 0.0, 0, 0); // printf("\n"); continue; } nodesExpanded += astar.GetNodesExpanded(); nodesTouched += astar.GetNodesTouched(); env1.SetPlanningCorridor(abstractPath, 2); gs1 = s1->GetNum(); gs2 = g1->GetNum(); t.StartTimer(); astar.GetPath(&env1, gs1, gs2, thePath); t.EndTimer(); printf("%llu\t%llu\t%llu\t%llu\t%1.2f\t%f\t", astar.GetNodesExpanded(), astar.GetNodesTouched(), astar.GetNodesExpanded()+nodesExpanded, astar.GetNodesTouched()+nodesTouched, env1.GetPathLength(thePath), totalTime+t.GetElapsedTime()); int abstractStart = 0; gs1 = s1->GetNum(); double totalLength = 0; int refineAmt = 2; int refinedPathNodes = 0; do { // not working yet -- fully check! env1.SetPlanningCorridor(abstractPath, 2, abstractStart); gs2 = g1->GetNum(); if (abstractPath.size()-abstractStart > refineAmt) { env1.SetUseAbstractGoal(true, 2); gs2 = abstractPath[abstractStart+refineAmt]; } else { env1.SetUseAbstractGoal(false, 0); } t.StartTimer(); astar.GetPath(&env1, gs1, gs2, thePath); t.EndTimer(); refinedPathNodes += thePath.size(); totalTime+=t.GetElapsedTime(); abstractStart += refineAmt; gs1 = thePath.back(); nodesExpanded += astar.GetNodesExpanded(); nodesTouched += astar.GetNodesTouched(); totalLength += env1.GetPathLength(thePath); if (thePath.back() == gs2) break; } while (thePath.back() != g1->GetNum()); // printf("%llu\t%llu\t%1.2f\t", astar.GetNodesExpanded(), astar.GetNodesTouched(), env1.GetPathLength(thePath)); thePath.resize(0); printf("%llu\t%llu\t%1.2f\t%f\t%d\t%d\n", nodesExpanded, nodesTouched, totalLength, totalTime, abstractPath.size(), refinedPathNodes); // gs1 = s1->GetNum(); // gs2 = g1->GetNum(); // env1.SetPlanningCorridor(abstractPath, 2); // astar.GetPath(&env1, gs1, gs2, thePath); // printf("%llu\t%1.2f\n", astar.GetNodesExpanded(), env1.GetPathLength(thePath)); } fclose(f); exit(0); }