diff --git a/mt-kahypar/dynamic/dynamic_partitioner.h b/mt-kahypar/dynamic/dynamic_partitioner.h index 4b7970e29..9e3fe9172 100644 --- a/mt-kahypar/dynamic/dynamic_partitioner.h +++ b/mt-kahypar/dynamic/dynamic_partitioner.h @@ -15,7 +15,7 @@ namespace mt_kahypar::dyn { ds::StaticHypergraph& hypergraph_s = utils::cast(hypergraph); // If the number of changes is not specified or is greater than the number of changes in the file, we process all the changes - size_t changes_size = context.dynamic.max_changes == 0 ? changes.size() : std::min((size_t) context.dynamic.max_changes, changes.size()); + size_t max_changes = context.dynamic.max_changes == 0 ? changes.size() : std::min((size_t) context.dynamic.max_changes, changes.size()); DynamicStrategy* strategy; @@ -35,13 +35,13 @@ namespace mt_kahypar::dyn { try { - std::cout << "Processing " << context.dynamic.max_changes << " changes" << std::endl; + std::cout << "Processing " << max_changes << " changes" << std::endl; - for (size_t i = 0; i < changes_size; ++i) { + for (size_t i = 0; i < max_changes; ++i) { Change& change = changes[i]; - strategy->partition(hypergraph_s, context, change); + strategy->partition(hypergraph_s, context, change, max_changes); if (!context.dynamic.server && *(&strategy->history.back().valid)) { - print_progress_bar(i, context.dynamic.max_changes, &strategy->history); + print_progress_bar(i, max_changes, &strategy->history); } log_km1_live(i, context, strategy->history.back()); } diff --git a/mt-kahypar/dynamic/dynamic_strategy.h b/mt-kahypar/dynamic/dynamic_strategy.h index c2a4de88b..4cd4ff8ed 100644 --- a/mt-kahypar/dynamic/dynamic_strategy.h +++ b/mt-kahypar/dynamic/dynamic_strategy.h @@ -119,7 +119,7 @@ namespace mt_kahypar::dyn { * The strategy should partition the hypergraph according to the change. * The strategy should update the history vector with the result of the partitioning. */ - virtual void partition(ds::StaticHypergraph &hypergraph, Context &context, Change change) = 0; + virtual void partition(ds::StaticHypergraph &hypergraph, Context &context, Change change, size_t changes_size) = 0; /* * A Strategy can print final statistics after the last partitioning step. diff --git a/mt-kahypar/dynamic/strategies/connectivity.h b/mt-kahypar/dynamic/strategies/connectivity.h index c4a9d718f..efbc7dfc3 100644 --- a/mt-kahypar/dynamic/strategies/connectivity.h +++ b/mt-kahypar/dynamic/strategies/connectivity.h @@ -40,7 +40,7 @@ namespace mt_kahypar::dyn { } public: - void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change) override { + void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change, size_t changes_size) override { //on first call, initialize partitioned_hypergraph_s if (!partitioned_hypergraph_s) { diff --git a/mt-kahypar/dynamic/strategies/lokalFM.h b/mt-kahypar/dynamic/strategies/lokalFM.h index 54be9a07f..66ab704e6 100644 --- a/mt-kahypar/dynamic/strategies/lokalFM.h +++ b/mt-kahypar/dynamic/strategies/lokalFM.h @@ -17,6 +17,7 @@ namespace mt_kahypar::dyn { std::unique_ptr _rebalancer; void repartition(ds::StaticHypergraph& hypergraph_s, Context& context) { + std::cout << "Repartitioning" << std::endl; partitioned_hypergraph_s = partition_hypergraph_km1(hypergraph_s, context); _gain_cache = GainCachePtr::constructGainCache(context); _rebalancer = RebalancerFactory::getInstance().createObject( @@ -74,7 +75,7 @@ namespace mt_kahypar::dyn { public: - void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change) override { + void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change, size_t changes_size) override { //on first call, initialize partitioned_hypergraph_s if (!partitioned_hypergraph_s) { diff --git a/mt-kahypar/dynamic/strategies/never_repartition.h b/mt-kahypar/dynamic/strategies/never_repartition.h index aea48d392..347d02ba4 100644 --- a/mt-kahypar/dynamic/strategies/never_repartition.h +++ b/mt-kahypar/dynamic/strategies/never_repartition.h @@ -73,7 +73,7 @@ namespace mt_kahypar::dyn { } public: - void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change) override { + void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change, size_t changes_size) override { //on first call, initialize partitioned_hypergraph_s if (!partitioned_hypergraph_s) { diff --git a/mt-kahypar/dynamic/strategies/repartition.h b/mt-kahypar/dynamic/strategies/repartition.h index 69a833590..76898aabc 100644 --- a/mt-kahypar/dynamic/strategies/repartition.h +++ b/mt-kahypar/dynamic/strategies/repartition.h @@ -8,9 +8,10 @@ namespace mt_kahypar::dyn { private: size_t skipped_changes = 0; size_t initial_num_enabled_nodes = 0; + size_t step_size = 0; public: - void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change) override { + void partition(ds::StaticHypergraph& hypergraph, Context& context, Change change, size_t changes_size) override { process_change(hypergraph, context, change); PartitionResult partition_result = *new PartitionResult(); @@ -23,7 +24,10 @@ namespace mt_kahypar::dyn { } } - auto step_size = static_cast(context.dynamic.step_size_pct * context.dynamic.max_changes); + if (step_size == 0) { + size_t max_changes = context.dynamic.max_changes == 0 ? changes_size : std::min((size_t) context.dynamic.max_changes, changes_size); + step_size = static_cast(context.dynamic.step_size_pct * max_changes); + } if (skipped_changes < step_size) { partition_result.valid = false;