Program Listing for File PartMgrBase.hpp¶
↰ Return to documentation for file (ckpttncpp/PartMgrBase.hpp)
#pragma once
// **Special code for two-pin nets**
// Take a snapshot when a move make **negative** gain.
// Snapshot in the form of "interface"???
// #include "netlist.hpp"
// #include <cinttypes>
#include <gsl/span>
// #include <iterator>
// #include <py2cpp/py2cpp.hpp>
// #include <type_traits>
// #include <vector>
#include <xnetwork/classes/graph.hpp>
// forward declare
template <typename graph_t>
struct Netlist;
// using RngIter = decltype(py::range(1));
// //using graph_t = xn::SimpleGraph;
using SimpleNetlist = Netlist<xn::SimpleGraph>;
enum class LegalCheck;
template <typename GainMgr, typename ConstrMgr,
template <typename _gainMgr, typename _constrMgr> class Derived> //
class PartMgrBase
{
public:
using GainCalc_ = typename GainMgr::GainCalc_;
using GainMgr_ = GainMgr;
using ConstrMgr_ = ConstrMgr;
using Der = Derived<GainMgr, ConstrMgr>;
protected:
Der& self = *static_cast<Der*>(this);
const SimpleNetlist& H;
GainMgr& gainMgr;
ConstrMgr& validator;
size_t K;
// std::vector<std::uint8_t> snapshot;
// std::vector<std::uint8_t> part;
public:
int totalcost {};
PartMgrBase(const SimpleNetlist& H, GainMgr& gainMgr, ConstrMgr& constrMgr,
size_t K)
: H {H}
, gainMgr {gainMgr}
, validator {constrMgr}
, K {K}
{
}
void init(gsl::span<std::uint8_t> part);
auto legalize(gsl::span<std::uint8_t> part) -> LegalCheck;
void optimize(gsl::span<std::uint8_t> part);
private:
void _optimize_1pass(gsl::span<std::uint8_t> part);
};