-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRefineAndBalanceHyperFlowCutter.cpp
75 lines (61 loc) · 3.06 KB
/
RefineAndBalanceHyperFlowCutter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "io/process_cmd_rebahfc.h"
#include "algorithm/multicutter_disconnected.h"
#include "io/hlafc_output.h"
#include "algorithm/hla_piercing_heuristics/hla_basic_piercing_filters.h"
namespace hyper {
void hidden_main(State& state, std::vector<STOptions>& stOptions) {
Random::setSeed(state.seed);
LoggingInformation::set_output_detail(state.output_detail);
Hypergraph hg = HMetisReader::readWithHyperedgeFiltering(state);
ConnectedComponents cc = ConnectivityCheck::connectedComponents(hg);
state.hypergraphIsConnectedAfterHyperedgeFiltering = cc.numComponents() <= 1;
ParetoFront front(hg.totalNodeWeight());
auto t = time_now();
auto easto = [&](STOptions& sto, const Hypergraph& hg, ParetoFront& lambda_front, State& state) {
//cuts of external partitioner and runtime can be accessed via state.external_partitioner_results and state.running_time_gen_fbt
double desired_eps = state.epsilons[0];
auto desired_smb = Metrics::smallerBlockSize(hg.totalNodeWeight(), desired_eps);
auto [achieved_smb, c] = lambda_front.getCut(desired_eps);
flow_t hfc_cut = c.cut + state.nDeletedHyperedges;
double achieved_eps = Metrics::imbalance(hg.totalNodeWeight(), achieved_smb);
flow_t external_cut = MAX_FLOW;
for (auto& x : state.external_partitioner_results) {
if (x.size_of_smaller_block >= desired_smb) {
external_cut = std::min(external_cut, x.cut);
}
}
//Format: algoname,hg,eps,achieved_eps,seed,cut,runtime
std::cout
<< state.algo_name << "," << state.getHypergraphName() << ","
<< desired_eps << "," << achieved_eps << ","
<< state.seed << "," << std::min(hfc_cut, external_cut) << ","
<< inSeconds(duration(time_now() - t)).count() << std::endl;
/*
std::cout << "ExternalCut," << external_cut << std::endl;
//distinguishable runtime format. all in seconds: ensemble, dp, gen_fbt, multicutter
//std::cout << "runtime ensemble" << "runtime dp" << "runtime gen fbt" << "runtime multicutter" << std::endl;
std::cout
<< inSeconds(state.running_time_ensemble_partitioner).count() << ","
<< inSeconds(state.running_time_disconnected_dp).count() << ","
<< inSeconds(state.running_time_gen_fbt).count() << ","
<< inSeconds(state.running_time_multi_cutter).count()
<< std::endl;
*/
};
if (cc.numComponents() <= 1) {
auto t_ensemble = time_now();
EnsemblePartitioning ep = EnsemblePartitioning::buildPatohEnsemblePartitioning(hg, state);
state.running_time_ensemble_partitioner += duration(time_now() - t_ensemble);
nodeid smb = state.getMaxSmallerBlocksize(hg.totalNodeWeight());
MultiCutter::run<IgnoreOptionsPiercing::PiercingPipeline>(hg, front, state, ep, stOptions, smb, easto);
}
else {
DisconnectedMultiCutter::run<IgnoreOptionsPiercing::PiercingPipeline>(hg, front, cc, state, stOptions, easto);
}
}
}
int main(int argc, const char* argv[]) {
auto [stOption, state] = hyper::ProcessCMDReBaHFC::processCommandLineOptions(argc, argv);
std::vector<hyper::STOptions> stOptions(stOption.numDistinctFinishBalanceTerminals, stOption);
hyper::hidden_main(state, stOptions);
}