|
1 | 1 | #include <algorithm> |
2 | 2 |
|
3 | 3 | #include "algebra/mptype.h" |
| 4 | +#include "base/analysis/mcm/mcm.h" |
4 | 5 | #include "base/analysis/mcm/mcmdg.h" |
5 | 6 | #include "base/analysis/mcm/mcmgraph.h" |
6 | 7 | #include <base/analysis/mcm/mcmhoward.h> |
@@ -55,8 +56,8 @@ void MCMTest::test_howard() { |
55 | 56 | std::shared_ptr<std::vector<CDouble>> chi = nullptr; |
56 | 57 | std::shared_ptr<std::vector<CDouble>> v = nullptr; |
57 | 58 | std::shared_ptr<std::vector<int>> policy = nullptr; |
58 | | - int nr_iterations; |
59 | | - int nr_components; |
| 59 | + int nr_iterations = 0; |
| 60 | + int nr_components = 0; |
60 | 61 |
|
61 | 62 | convertMCMgraphToMatrix(g, &ij, &A); |
62 | 63 |
|
@@ -86,10 +87,20 @@ void MCMTest::test_howard() { |
86 | 87 | /// Test MCM Karp. |
87 | 88 | void MCMTest::test_karp() { |
88 | 89 | std::cout << "Running test: MCM-Karp" << std::endl; |
| 90 | + |
| 91 | + MCMgraph g = makeGraph1(); |
| 92 | + |
| 93 | + CDouble result = maximumCycleMeanKarp(g); |
| 94 | + ASSERT_APPROX_EQUAL(2.5, result, 1e-5); |
| 95 | + |
| 96 | + result = maximumCycleMeanKarpDouble(g, nullptr); |
| 97 | + ASSERT_APPROX_EQUAL(2.5, result, 1e-5); |
| 98 | + |
| 99 | + |
89 | 100 | ASSERT_APPROX_EQUAL(1.0, 1.0, 1e-5); |
90 | 101 | } |
91 | 102 |
|
92 | | -/// Test MCM Howard. |
| 103 | +/// Test MCM YTO. |
93 | 104 | void MCMTest::test_yto() { |
94 | 105 | std::cout << "Running test: MCM-YTO" << std::endl; |
95 | 106 | ASSERT_APPROX_EQUAL(1.0, 1.0, 1e-5); |
|
0 commit comments