CkPttn 1.2.4
Loading...
Searching...
No Matches
FMBiGainMgr.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <span>
9
10#include "FMBiGainCalc.hpp"
11#include "FMGainMgr.hpp"
12#include "moveinfo.hpp" // for MoveInfo
13
14// struct FMBiGainMgr;
15
25template <typename Gnl> class FMBiGainMgr
26 : public FMGainMgr<Gnl, FMBiGainCalc<Gnl>, FMBiGainMgr<Gnl>> {
27 public:
30 using node_t = typename Gnl::node_t;
31
37 explicit FMBiGainMgr(const Gnl& hyprgraph) : Base{hyprgraph, 2} {}
38
44 FMBiGainMgr(const Gnl& hyprgraph, std::uint8_t /* num_parts */) : Base{hyprgraph, 2} {}
45
52 auto init(std::span<const std::uint8_t> part) -> int;
53
61 auto modify_key(const node_t& w, std::uint8_t part_w, int key) -> void {
62 auto& item = this->gain_calc.vertex_list[w];
63 if (item.is_locked()) {
64 return;
65 }
66 this->gain_bucket[1 - part_w].modify_key(item, key);
67 }
68
75 auto update_move_v(const MoveInfoV<node_t>& move_info_v, int gain) -> void {
76 // this->vertex_list[node_v].data.second -= 2 * gain;
77 // auto [from_part, _ = move_info_v;
78 this->_set_key(move_info_v.from_part, move_info_v.v, -gain);
79 }
80
87 auto lock(uint8_t whichPart, const node_t& v) -> void {
88 auto& vlink = this->gain_calc.vertex_list[v];
89 this->gain_bucket[whichPart].detach(vlink);
90 vlink.lock();
91 }
92
99 auto lock_all(uint8_t from_part, const node_t& v) -> void { this->lock(1 - from_part, v); }
100
101 private:
109 auto _set_key(uint8_t whichPart, const node_t& v, int key) -> void {
110 this->gain_bucket[whichPart].set_key(this->gain_calc.vertex_list[v], key);
111 }
112};
Binary FM gain calculator for 2-way partitioning.
CRTP base class for FM gain management.
Binary Fiduccia-Mattheyses Gain Calculator.
Definition FMBiGainCalc.hpp:32
Binary Fiduccia-Mattheyses Gain Manager.
Definition FMBiGainMgr.hpp:26
FMBiGainMgr(const Gnl &hyprgraph)
Construct a new FMBiGainMgr object.
Definition FMBiGainMgr.hpp:37
auto lock(uint8_t whichPart, const node_t &v) -> void
Locks the vertex in the specified partition.
Definition FMBiGainMgr.hpp:87
auto init(std::span< const std::uint8_t > part) -> int
Initializes the FMBiGainMgr object with the given partition.
auto lock_all(uint8_t from_part, const node_t &v) -> void
Locks the vertex in the opposite partition from the specified partition.
Definition FMBiGainMgr.hpp:99
typename Gnl::node_t node_t
Definition FMBiGainMgr.hpp:30
auto update_move_v(const MoveInfoV< node_t > &move_info_v, int gain) -> void
Updates the move information for the given vertex and gain.
Definition FMBiGainMgr.hpp:75
auto modify_key(const node_t &w, std::uint8_t part_w, int key) -> void
Modifies the key for the given vertex in the gain bucket of the opposite partition.
Definition FMBiGainMgr.hpp:61
FMBiGainMgr(const Gnl &hyprgraph, std::uint8_t)
Constructs a new FMBiGainMgr object with the given hypergraph.
Definition FMBiGainMgr.hpp:44
Fiduccia-Mattheyses Gain Manager.
Definition FMGainMgr.hpp:32
const Gnl & hyprgraph
Reference to the hypergraph being partitioned.
Definition FMGainMgr.hpp:41
FMBiGainCalc< Gnl > gain_calc
Gain calculator instance.
Definition FMGainMgr.hpp:49
std::vector< BPQueue< node_t > > gain_bucket
Gain buckets for each partition (used in bucket-based gain management)
Definition FMGainMgr.hpp:43
Move information structures for FM partitioning algorithm.
Move information for a single vertex (without net reference)
Definition moveinfo.hpp:37