void run() { typedef typename Algo::Graph Graph; Algo algo; Graph graph; algo.readGraph(graph, filename, transposeGraphName); Galois::preAlloc(numThreads + (2*graph.size() * sizeof(typename Graph::node_data_type)) / Galois::Runtime::MM::hugePageSize); Galois::reportPageAlloc("MeminfoPre"); Galois::StatTimer T; auto eamp = -amp;///tolerance; std::cout << "Running " << algo.name() << " version\n"; std::cout << "tolerance: " << tolerance << "\n"; std::cout << "effective amp: " << eamp << "\n"; T.start(); Galois::do_all_local(graph, [&graph] (typename Graph::GraphNode n) { graph.getData(n).init(); }); algo(graph, tolerance, eamp); T.stop(); Galois::reportPageAlloc("MeminfoPost"); if (!skipVerify) { algo.verify(graph, tolerance); printTop(graph, 10, algo.name().c_str(), numThreads); } }
int main(void) { FileParser* fp = new FileParser(); DetQuadProblem * dqp = fp->parseDetModel("benchmark/FTSE.txt", "benchmark/SIMPLE_FE.txt"); LinearProblem lp = dqp->getSimpleLinearProblem(); #ifdef DEBUG dqp->print(); lp.print(); #endif Algo * algo = new SimulatedAnnealing(); Solver * s = new LpsolveAdaptator(); Solution sol = algo->solve(*dqp, s); /*Solution sol = s->getAdmissibleSolution(&lp); std::cout << "Risk = "<< dqp->objectiveFunction(sol) << " : " << sol.toString() << std::endl; sol = lp.getNeighbour(sol, 1); lp = dqp->getFixedLP(sol); sol = s->getAdmissibleSolution(&lp); std::cout << "Risk = "<< dqp->objectiveFunction(sol) << " : " << sol.toString() << std::endl; sol = lp.getNeighbour(sol, 1); lp = dqp->getFixedLP(sol); sol = s->getAdmissibleSolution(&lp); std::cout << "Risk = "<< dqp->objectiveFunction(sol) << " : " << sol.toString() << std::endl;*/ return EXIT_SUCCESS; }
void run() { typedef typename Algo::Graph Graph; typedef typename Graph::GraphNode GNode; Algo algo; Graph graph; GNode source; initialize(algo, graph, source); Galois::preAlloc(numThreads + (3*graph.size() * sizeof(typename Graph::node_data_type)) / Galois::Runtime::MM::pageSize); Galois::reportPageAlloc("MeminfoPre"); Galois::StatTimer T; std::cout << "Running " << algo.name() << " version\n"; T.start(); Galois::do_all_local(graph, typename Algo::Initialize(graph)); algo(graph, source); T.stop(); Galois::reportPageAlloc("MeminfoPost"); if (!skipVerify) { int count = 0; for (typename Graph::iterator ii = graph.begin(), ei = graph.end(); ii != ei && count < 10; ++ii, ++count) { std::cout << count << ": " << std::setiosflags(std::ios::fixed) << std::setprecision(6) << graph.getData(*ii).dependencies << "\n"; } } }
void runPPR() { typedef typename Algo::Graph Graph; Algo algo; Graph graph; algo.readGraph(graph, filename, transposeGraphName); std::cout << "Read " << std::distance(graph.begin(), graph.end()) << " Nodes\n"; Galois::preAlloc(numThreads + (graph.size() * sizeof(typename Graph::node_data_type)) / Galois::Runtime::MM::hugePageSize); Galois::reportPageAlloc("MeminfoPre"); unsigned numSeeds = 2; Galois::StatTimer Tt; Tt.start(); auto seeds = findPPRSeeds(graph, numSeeds); Tt.stop(); std::cout << "Find " << numSeeds << " seeds (found " << seeds.size() << ") in " << Tt.get() << "ms\n"; std::map<typename Graph::GraphNode, std::deque<unsigned> > clusters; unsigned counter = 0; for (auto seed : seeds) { Galois::StatTimer T1, T2, T3; std::cout << "Running " << algo.name() << " version\n"; T1.start(); Galois::do_all_local(graph, [&graph] (typename Graph::GraphNode n) { graph.getData(n).init(); }); T1.stop(); T2.start(); algo(graph, seed); T2.stop(); T3.start(); auto c = algo.cluster_from_sweep(graph); T3.stop(); std::cout << T1.get() << " " << T2.get() << " " << T3.get() << "\n"; std::cout << seed << " : " << c.size() << "\n"; // for (auto n : c) // std::cout << n << " "; // std::cout << "\n"; for (auto n : c) clusters[n].push_back(counter); ++counter; Galois::reportPageAlloc("MeminfoPost"); } for (auto np : clusters) { std::cout << np.first << ": "; for (auto n : np.second) std::cout << n << " "; std::cout << "\n"; } }
bool update(Algo& algo, const F &callbacks) { callbacks.at_begin_bundle_adjustment_iteration(); auto save_container = bundle.clone_opt_container(); rms1 = algo.get_erreur(); // double C = 0; algo.compute(bundle,lambda,is_better); rms2 = algo.compute_erreur(bundle); // double& A = rms1; // double& B = rms2; // // double rho = (B-A) / (C-A); // // std::cout << "\n A : " << rms1 << std::endl; // std::cout << " B : " << rms2 << std::endl; // std::cout << " C : " << C << std::endl; // std::cout << " ared : " << (B-A) << std::endl; // std::cout << " pred : " << (C-A) << std::endl; // std::cout << color.red() << " rho = " << rho << std::endl << color.reset() << std::endl; double nb_obs = bundle.nb_obs(); if(rms2 > rms1) { algo.restore_erreur(); bundle.restore_container(save_container); is_better = false; callbacks.at_end_bundle_adjustment_iteration(*this); lambda *= 10.0; if (lambda > 1e30) return false; } else { is_better = true; callbacks.at_end_bundle_adjustment_iteration(*this); if (stop(nb_obs)) { rms1 = rms2; return false; } else lambda = std::max(min_lambda,lambda / 10.0); rms1 = rms2; } return true; }
static BOOST_FORCEINLINE typename parallel::util::detail::algorithm_result<ExPolicy>::type parallel(Algo const& algo, ExPolicy const& policy, Args const&... args) { using hpx::traits::segmented_local_iterator_traits; algo.call(policy, boost::mpl::false_(), segmented_local_iterator_traits<Args>::local(args)... ); }
static BOOST_FORCEINLINE R parallel(Algo const& algo, ExPolicy const& policy, Args const&... args) { using hpx::traits::segmented_local_iterator_traits; return detail::algorithm_result_helper<R>::call( algo.call(policy, boost::mpl::false_(), segmented_local_iterator_traits<Args>::local(args)... ) ); }
void initialize(Algo& algo, typename Algo::Graph& graph, typename Algo::Graph::GraphNode& source) { algo.readGraph(graph); std::cout << "Read " << graph.size() << " nodes\n"; if (startNode >= graph.size()) { std::cerr << "failed to set source: " << startNode << "\n"; assert(0); abort(); } typename Algo::Graph::iterator it = graph.begin(); std::advance(it, startNode); source = *it; }