MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / Solve

Method Solve

src/Tracker/ShortPathCalculator.cpp:18–68  ·  view source on GitHub ↗

\brief SPBipart::Solve \param costMatrix \param N \param M \param assignment \param maxCost

Source from the content-addressed store, hash-verified

16/// \param maxCost
17///
18void SPBipart::Solve(const distMatrix_t& costMatrix, size_t colsTracks, size_t rowsRegions, assignments_t& assignmentT2R, track_t maxCost)
19{
20 //std::cout << "SPBipart::Solve: colsTracks = " << colsTracks << ", rowsRegions = " << rowsRegions << std::endl;
21
22 MyGraph G;
23 G.make_directed();
24
25 std::vector<GTL::node> nodes(colsTracks + rowsRegions);
26
27 for (size_t i = 0; i < nodes.size(); ++i)
28 {
29 nodes[i] = G.new_node();
30 }
31
32 GTL::edge_map<int> weights(G, 100);
33 for (size_t i = 0; i < colsTracks; ++i)
34 {
35 bool hasZeroEdge = false;
36
37 for (size_t j = 0; j < rowsRegions; ++j)
38 {
39 track_t currCost = costMatrix[i + j * colsTracks];
40
41 GTL::edge e = G.new_edge(nodes[i], nodes[colsTracks + j]);
42
43 if (currCost < m_settings.m_distThres)
44 {
45 int weight = static_cast<int>(maxCost - currCost + 1);
46 G.set_edge_weight(e, weight);
47 weights[e] = weight;
48 }
49 else
50 {
51 if (!hasZeroEdge)
52 {
53 G.set_edge_weight(e, 0);
54 weights[e] = 0;
55 }
56 hasZeroEdge = true;
57 }
58 }
59 }
60
61 GTL::edges_t L = MAX_WEIGHT_BIPARTITE_MATCHING(G, weights);
62 for (GTL::edges_t::iterator it = L.begin(); it != L.end(); ++it)
63 {
64 GTL::node a = it->source();
65 GTL::node b = it->target();
66 assignmentT2R[b.id()] = static_cast<assignments_t::value_type>(a.id() - colsTracks);
67 }
68}
69
70///
71void SPLAPJV::Solve(const distMatrix_t& costMatrix, size_t colsTracks, size_t rowsRegions, assignments_t& assignmentT2R, track_t /*maxCost*/)

Callers 1

UpdateTrackingStateMethod · 0.45

Calls 13

lapFunction · 0.85
make_directedMethod · 0.80
new_nodeMethod · 0.80
new_edgeMethod · 0.80
set_edge_weightMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
resizeMethod · 0.80
sizeMethod · 0.45
sourceMethod · 0.45
targetMethod · 0.45

Tested by

no test coverage detected