Skip to content

Commit

Permalink
Load initial partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
V0G3L committed Oct 15, 2024
1 parent 15a93d6 commit 496bf55
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 17 deletions.
7 changes: 4 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ if [ ! -f build/Makefile ]; then
mkdir -p build
fi

#cd build_debug && cmake .. -DCMAKE_BUILD_TYPE=Debug $CMAKE_COMMANDS && cd ${ROOT}
#cmake --build build_debug --parallel "$(get_num_cores)" --target MtKaHyPar
cd build_debug && cmake .. -DCMAKE_BUILD_TYPE=Debug $CMAKE_COMMANDS && cd ${ROOT}
cmake --build build_debug --parallel "$(get_num_cores)" --target MtKaHyPar
cd build && cmake .. -DCMAKE_BUILD_TYPE=Release $CMAKE_COMMANDS && cd ${ROOT}
cmake --build build --parallel "$(get_num_cores)" --target MtKaHyPar

#cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_COMMANDS && cd ${ROOT}
#cmake --build build --parallel "$(get_num_cores)" --target MtKaHyPar
117 changes: 117 additions & 0 deletions config/debug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# general
mode=direct
preset-type=quality
maxnet-removal-factor=0.01
smallest-maxnet-threshold=50000
maxnet-ignore=1000
num-vcycles=0
partition-evolutionary=true
time-limit=60
# main -> shared_memory
s-use-localized-random-shuffle=false
s-static-balancing-work-packages=128
# main -> preprocessing
p-enable-community-detection=true
# main -> preprocessing -> community_detection
p-louvain-edge-weight-function=hybrid
p-max-louvain-pass-iterations=5
p-louvain-min-vertex-move-fraction=0.01
p-vertex-degree-sampling-threshold=200000
# main -> coarsening
c-type=multilevel_coarsener
c-use-adaptive-edge-size=true
c-min-shrink-factor=1.01
c-max-shrink-factor=2.5
c-s=1
c-t=160
c-vertex-degree-sampling-threshold=200000
# main -> coarsening -> rating
c-rating-score=heavy_edge
c-rating-heavy-node-penalty=no_penalty
c-rating-acceptance-criterion=best_prefer_unmatched
# main -> initial_partitioning
i-mode=rb
i-runs=20
i-use-adaptive-ip-runs=true
i-min-adaptive-ip-runs=5
i-perform-refinement-on-best-partitions=true
i-fm-refinement-rounds=1
i-lp-maximum-iterations=20
i-lp-initial-block-size=5
# main -> initial_partitioning -> refinement
i-r-refine-until-no-improvement=false
i-r-relative-improvement-threshold=0.0
# main -> initial_partitioning -> refinement -> label_propagation
i-r-lp-type=label_propagation
i-r-lp-maximum-iterations=5
i-r-lp-rebalancing=true
i-r-lp-he-size-activation-threshold=100
# main -> initial_partitioning -> refinement -> fm
i-r-fm-type=kway_fm
i-r-fm-multitry-rounds=5
i-r-fm-perform-moves-global=false
i-r-fm-rollback-parallel=true
i-r-fm-rollback-balance-violation-factor=1
i-r-fm-seed-nodes=25
i-r-fm-obey-minimal-parallelism=false
i-r-fm-release-nodes=true
i-r-fm-time-limit-factor=0.25
i-r-fm-iter-moves-on-recalc=true
# main -> initial_partitioning -> refinement -> flows
i-r-flow-algo=do_nothing
# main -> refinement
r-rebalancer-type=advanced_rebalancer
r-refine-until-no-improvement=true
r-relative-improvement-threshold=0.0025
# main -> refinement -> label_propagation
r-lp-type=label_propagation
r-lp-unconstrained=true
r-lp-maximum-iterations=5
r-lp-rebalancing=true
r-lp-he-size-activation-threshold=100
r-lp-relative-improvement-threshold=0.001
# main -> refinement -> fm
r-fm-type=unconstrained_fm
r-fm-multitry-rounds=10
r-fm-unconstrained-rounds=8
r-fm-perform-moves-global=false
r-fm-rollback-parallel=true
r-fm-rollback-balance-violation-factor=1.0
r-fm-threshold-border-node-inclusion=0.7
r-fm-imbalance-penalty-min=0.2
r-fm-imbalance-penalty-max=1.0
r-fm-seed-nodes=25
r-fm-release-nodes=true
r-fm-min-improvement=-1.0
r-fm-unconstrained-min-improvement=0.002
r-fm-obey-minimal-parallelism=true
r-fm-time-limit-factor=0.25
r-fm-iter-moves-on-recalc=true
# main -> refinement -> flows
r-flow-algo=flow_cutter
r-flow-scaling=16
r-flow-max-num-pins=4294967295
r-flow-find-most-balanced-cut=true
r-flow-determine-distance-from-cut=true
r-flow-parallel-search-multiplier=1.0
r-flow-max-bfs-distance=2
r-flow-min-relative-improvement-per-round=0.001
r-flow-time-limit-factor=8
r-flow-skip-small-cuts=true
r-flow-skip-unpromising-blocks=true
r-flow-pierce-in-bulk=true
r-flow-process-mapping-policy=lower_bound
# main -> mapping
one-to-one-mapping-strategy=greedy_mapping
mapping-use-local-search=true
use-two-phase-approach=false
max-steiner-tree-size=4
mapping-largest-he-fraction=0.0
mapping-min-pin-coverage=0.05
#main -> evolutionary
evo-population-size=10
evo-dynamic-population-size=false
evo-dynamic-population-amount-of-time=0.15
evo-diversify-interval=1
evo-mutation-chance=0.5
evo-replacement-strategy=strong_diverse
12 changes: 6 additions & 6 deletions config/evo_quality_preset.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ max-steiner-tree-size=4
mapping-largest-he-fraction=0.0
mapping-min-pin-coverage=0.05
#main -> evolutionary
evolutionary.population_size=10;
evolutionary.dynamic_population_size=false;
evolutionary.dynamic_population_amount_of_time=0.15;
evolutionary.diversify_interval=1;
evolutionary.mutation_chance=0.5;
evo-replacement-strategy=strong-diverse;
evo-population-size=10
evo-dynamic-population-size=false
evo-dynamic-population-amount-of-time=0.15
evo-diversify-interval=1
evo-mutation-chance=0.5
evo-replacement-strategy=strong_diverse
14 changes: 7 additions & 7 deletions config/evo_quality_preset_short.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ smallest-maxnet-threshold=50000
maxnet-ignore=1000
num-vcycles=0
partition-evolutionary=true
time-limit=20
time-limit=120
# main -> shared_memory
s-use-localized-random-shuffle=false
s-static-balancing-work-packages=128
Expand Down Expand Up @@ -109,9 +109,9 @@ max-steiner-tree-size=4
mapping-largest-he-fraction=0.0
mapping-min-pin-coverage=0.05
#main -> evolutionary
evolutionary.population_size=10;
evolutionary.dynamic_population_size=false;
evolutionary.dynamic_population_amount_of_time=0.15;
evolutionary.diversify_interval=1;
evolutionary.mutation_chance=0.5;
evo-replacement-strategy=strong-diverse;
evo-population-size=10
evo-dynamic-population-size=false
evo-dynamic-population-amount-of-time=0.15
evo-diversify-interval=1
evo-mutation-chance=0.5
evo-replacement-strategy=strong_diverse
1 change: 1 addition & 0 deletions mt-kahypar/io/command_line_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ namespace mt_kahypar {
.add(refinement_options)
.add(flow_options)
.add(mapping_options)
.add(evolutionary_options)
.add(shared_memory_options);

po::store(po::parse_config_file(file, ini_line_options, true), cmd_vm);
Expand Down
2 changes: 1 addition & 1 deletion mt-kahypar/partition/context_enum_classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ namespace mt_kahypar {
return EvoReplaceStrategy::worst;
} else if (type == "diverse") {
return EvoReplaceStrategy::diverse;
} else if (type == "strong_divers") {
} else if (type == "strong_diverse") {
return EvoReplaceStrategy::strong_diverse;
}
throw InvalidParameterException("Illegal option: " + type);
Expand Down
33 changes: 33 additions & 0 deletions mt-kahypar/partition/evo_partitioner.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "evo_partitioner.h"
#include "partitioner.cpp"
#include <mutex>
#include "mt-kahypar/io/hypergraph_io.h"

namespace mt_kahypar {

Expand Down Expand Up @@ -36,6 +37,38 @@ namespace mt_kahypar {
Population population;
std::string history = generateInitialPopulation(hypergraph, context, target_graph, population);

/*for (int i = 0; i < context.evolutionary.population_size; i++) {
std::string epsilon_str = std::to_string(context.partition.epsilon);
epsilon_str.erase(epsilon_str.find_last_not_of('0') + 1, std::string::npos);
std::string partition_filename =
context.partition.graph_filename
+ ".part"
+ std::to_string(context.partition.k)
+ ".epsilon"
+ epsilon_str
+ ".seed"
+ std::to_string(i)
+ ".KaHyPar";
PartitionedHypergraph partitioned_hypergraph(context.partition.k, hypergraph);
std::vector<PartitionID> precomputed;
io::readPartitionFile(partition_filename, precomputed);
partitioned_hypergraph.doParallelForAllNodes([&](const HypernodeID& hn) {
partitioned_hypergraph.setOnlyNodePart(hn, precomputed[hn]);
});
partitioned_hypergraph.initializePartition();
Individual individual(partitioned_hypergraph, context);
population.addStartingIndividual(individual, context);
}
auto start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
std::string history = "Starttime: " + std::to_string(start.count()) + "\n";
history += "" + std::to_string(start.count()) + ", Initial, " + std::to_string(population.bestFitness()) + "\n";
LOG << "Loaded precomputed partitions. Current best quality: " << population.bestFitness();*/

history += performEvolution(hypergraph, context, target_graph, population);

if (context.evolutionary.history_file != "") {
Expand Down

0 comments on commit 496bf55

Please sign in to comment.