29 for (
const auto wid : wids) {
31 boost::add_edge(node, wnode,
m_graph);
40 std::unordered_map<vertex_t, int> stripes;
41 int nstripes = boost::connected_components(
m_graph, boost::make_assoc_property_map(stripes));
46 for (
auto& vci : stripes) {
48 char ntype =
m_graph[vtx].ntype;
52 const size_t stripe_index = vci.second;
53 ret[stripe_index].push_back(
m_graph[vtx]);
65 auto it = m_sid2vtx.find(sid);
66 if (it != m_sid2vtx.end()) {
70 m_sid2vtx[sid] = snode;
82 m_graph[mnode].ident = 0xdeadbeef;
90 for (
const auto& it : cset) {
91 double total_value = 0;
92 double total_weight = 0;
94 std::vector<vertex_t> snodes;
95 for (
const auto& node : it.second) {
96 if (node.ntype ==
'm') {
97 total_value += node.value;
98 total_weight += node.weight;
102 if (node.ntype ==
's') {
103 auto snode =
source_node(node.ident, node.value, node.weight);
104 snodes.push_back(snode);
109 if (!nms or snodes.empty()) {
113 auto mnode = measurement_node(total_value, total_weight/nms);
114 for (
auto snode : snodes) {
115 boost::add_edge(mnode, snode,
m_graph);
122 const std::vector<vertex_t>& sources,
123 const std::vector<vertex_t>& measures)
129 Ress::matrix_t geom = Ress::matrix_t::Zero(measures.size(), sources.size());
130 std::unordered_map<vertex_t, size_t> sv2ind, mv2ind;
131 for (
size_t mind=0; mind<measures.size(); ++mind) {
134 meas(mind) =
m_graph[mvtx].value;
136 for (
size_t sind=0; sind<sources.size(); ++sind) {
141 auto medges = boost::out_edges(svtx,
m_graph);
142 for (
auto mit = medges.first; mit != medges.second; ++mit) {
144 size_t mind = mv2ind[mvtx];
145 geom(mind, sind) = 1.0;
153 for (
int sind = 0; sind < solved.size(); ++sind) {
154 auto svtx = sources[sind];
155 m_graph[svtx].value = solved[sind];
156 answer[
m_graph[svtx].ident] = solved[sind];
163 std::unordered_map<vertex_t, int> probs;
164 int nprobs = boost::connected_components(
m_graph, boost::make_assoc_property_map(probs));
173 std::vector<vertex_t> sources, measures;
175 std::unordered_map<int, SMVecs> smvecs;
176 for (
auto it : probs) {
178 if (
m_graph[vtx].ntype ==
's') {
179 smvecs[it.second].sources.push_back(vtx);
181 if (
m_graph[vtx].ntype ==
'm') {
182 smvecs[it.second].measures.push_back(vtx);
186 for (
auto sit : smvecs) {
187 solve_one(answer, sit.second.sources, sit.second.measures);
std::unordered_map< ident_t, vertex_t > m_wid2vtx
vector_t solve(matrix_t response, vector_t measured, const Params ¶ms=Params(), vector_t source=Eigen::VectorXd(), vector_t weights=Eigen::VectorXd())
std::unordered_map< int, cluster_t > clusterset_t
boost::graph_traits< graph_t >::vertex_descriptor vertex_t
vertex_t source_node(ident_t sid, float value, float weight)
vertex_t wire_node(ident_t wid)
boost::graph_traits< graph_t >::vertex_descriptor vertex_t
virtual void add(char ntype, ident_t chid, std::vector< ident_t > wids, float value, float weight=1.0)
vertex_t measurement_node(float value, float weight)
const GenericPointer< typename T::ValueType > T2 value
void solve_one(solution_t &answer, const std::vector< vertex_t > &sources, const std::vector< vertex_t > &measures)
std::unordered_map< ident_t, float > solution_t
void add(const Grouping::clusterset_t &cset)
tbb::flow::source_node< boost::any > source_node