-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtestHungarian.cpp
51 lines (45 loc) · 1.05 KB
/
testHungarian.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "hungarianAlg.hpp"
#include <iomanip>
int main()
{
/* for example row size:total worker, column size: total jobs */
int rows = 4;
int cols = 4;
vector<float> cost(
{
80, 40, 50, 46,
40, 70, 20, 25,
30, 10, 20, 30,
35, 20, 25, 30
}
);
assignmentProblemSolver aps( rows, cols );
aps.Solve( cost );
vector<int> assignment = aps.getAssignment();
cout << "original matrix" << endl;
for ( int i = 0; i < rows; i++ )
{
for ( int j = 0; j < cols; j++ )
{
cout << setw( 3 ) << cost[i * cols + j];
}
cout << endl;
}
cout << "assigned" << endl;
for ( unsigned int i = 0; i < assignment.size(); i++ )
{
for ( int j = 0; j < cols; j++ )
{
if ( assignment[i] == j )
{
cout << setw( 3 ) << cost[i * cols + assignment[i]];
}
else
{
cout << setw( 3 ) << "x";
}
}
cout << endl;
}
return 0;
}