void CliquePartitionProblem::writeSolution( FractionnarySolution const& bestSolution, double lb) const { std::ofstream file( GetStr("optimal/", problemName(), "_", lb, ".txt").c_str()); for (auto const & c : bestSolution) { for (auto const & edge : getCosts()) { int const r(edge._i); int const b(edge._j); if (c.first->contains(r) && c.first->contains(b)) { file << std::setw(6) << 1 + r; file << std::setw(6) << 1 + b; file << std::endl; } } // for (int r(0); r < nR(); ++r) { // for (int b(0); b < nB(); ++b) { // if (c.first->contains(r) && c.first->contains(nR() + b)) { // file << std::setw(6) << 1 + r; // file << std::setw(6) << 1 + b + nR(); // file << std::endl; // } // // } // } } file.close(); }
int main(int argc, char **argv) { // Run all three problems for (unsigned int n = 0; n < 3; n++) { // initialize the planner og::SimpleSetupPtr ss = setupProblem(PlannerType(n)); // attempt to solve the problem ob::PlannerStatus solved = ss->solve(10.0); if (solved) { if (solved == ob::PlannerStatus::EXACT_SOLUTION) std::cout << "Found solution.\n"; else std::cout << "Found approximate solution.\n"; // Set up to write the path std::ofstream f(problemName(PlannerType(n)).c_str()); ompl::geometric::PathGeometric p = ss->getSolutionPath(); p.interpolate(); auto upstream(std::make_shared<ob::VFUpstreamCriterionOptimizationObjective>( ss->getSpaceInformation(), field)); p.printAsMatrix(f); std::cout << "Total upstream cost: " << p.cost(upstream) << "\n"; } else std::cout << "No solution found.\n"; } return 0; }