TTK
Loading...
Searching...
No Matches
AssignmentSolver.h
Go to the documentation of this file.
1
13
14#pragma once
15
16#include <Debug.h>
18
19namespace ttk {
20
21 template <class dataType>
22 class AssignmentSolver : virtual public Debug {
23
24 public:
25 AssignmentSolver() = default;
26
27 ~AssignmentSolver() override = default;
28
29 virtual int run(std::vector<MatchingType> &matchings) = 0;
30
31 virtual inline void clear() {
32 rowSize = 0;
33 colSize = 0;
34 }
35
36 virtual inline void clearMatrix() {
37 std::vector<std::vector<dataType>> C = getCostMatrix();
38 for(int r = 0, rS0 = rowSize; r < rS0; ++r)
39 for(int c = 0, cS0 = colSize; c < cS0; ++c)
40 C[r][c] = 0.0;
41 }
42
43 virtual inline int setInput(std::vector<std::vector<dataType>> &C_) {
44 rowSize = C_.size();
45 colSize = C_[0].size();
46
47 costMatrix = C_;
48
49 setBalanced((this->rowSize == this->colSize));
50
51 return 0;
52 }
53
54 virtual inline void setBalanced(bool balanced) {
55 balancedAssignment = balanced;
56 }
57
58 virtual inline std::vector<std::vector<dataType>> getCostMatrix() {
59 return costMatrix;
60 }
61
62 virtual inline std::vector<std::vector<dataType>> *getCostMatrixPointer() {
63 return &costMatrix;
64 }
65
66 void printTableVector(std::vector<std::vector<dataType>> &table) {
67 for(auto vecTemp : table) {
68 const std::stringstream ss;
69 for(auto valTemp : vecTemp) {
70 ss << valTemp << " ";
71 }
73 }
75 }
76
77 protected:
78 std::vector<std::vector<dataType>> costMatrix;
79
80 int rowSize = 0;
81 int colSize = 0;
82
84 };
85} // namespace ttk
virtual int run(std::vector< MatchingType > &matchings)=0
virtual std::vector< std::vector< dataType > > getCostMatrix()
virtual int setInput(std::vector< std::vector< dataType > > &C_)
virtual std::vector< std::vector< dataType > > * getCostMatrixPointer()
~AssignmentSolver() override=default
virtual void clearMatrix()
std::vector< std::vector< dataType > > costMatrix
AssignmentSolver()=default
void printTableVector(std::vector< std::vector< dataType > > &table)
virtual void setBalanced(bool balanced)
Minimalist debugging class.
Definition Debug.h:88
The Topology ToolKit.
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)