You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

409 lines
19 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/exceptions/InvalidArgumentException.h"
  4. #include "src/storage/dd/DdManager.h"
  5. #include "src/storage/dd/Add.h"
  6. #include "src/storage/dd/Odd.h"
  7. #include "src/storage/dd/DdMetaVariable.h"
  8. #include "src/settings/SettingsManager.h"
  9. #include "src/storage/SparseMatrix.h"
  10. TEST(CuddDd, Constants) {
  11. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  12. storm::dd::Add<storm::dd::DdType::CUDD, double> zero;
  13. ASSERT_NO_THROW(zero = manager->template getAddZero<double>());
  14. EXPECT_EQ(0ul, zero.getNonZeroCount());
  15. EXPECT_EQ(1ul, zero.getLeafCount());
  16. EXPECT_EQ(1ul, zero.getNodeCount());
  17. EXPECT_EQ(0, zero.getMin());
  18. EXPECT_EQ(0, zero.getMax());
  19. storm::dd::Add<storm::dd::DdType::CUDD, double> one;
  20. ASSERT_NO_THROW(one = manager->template getAddOne<double>());
  21. EXPECT_EQ(0ul, one.getNonZeroCount());
  22. EXPECT_EQ(1ul, one.getLeafCount());
  23. EXPECT_EQ(1ul, one.getNodeCount());
  24. EXPECT_EQ(1, one.getMin());
  25. EXPECT_EQ(1, one.getMax());
  26. storm::dd::Add<storm::dd::DdType::CUDD, double> two;
  27. ASSERT_NO_THROW(two = manager->template getConstant<double>(2));
  28. EXPECT_EQ(0ul, two.getNonZeroCount());
  29. EXPECT_EQ(1ul, two.getLeafCount());
  30. EXPECT_EQ(1ul, two.getNodeCount());
  31. EXPECT_EQ(2, two.getMin());
  32. EXPECT_EQ(2, two.getMax());
  33. }
  34. TEST(CuddDd, AddGetMetaVariableTest) {
  35. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  36. ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9));
  37. EXPECT_EQ(2ul, manager->getNumberOfMetaVariables());
  38. ASSERT_THROW(manager->addMetaVariable("x", 0, 3), storm::exceptions::InvalidArgumentException);
  39. ASSERT_NO_THROW(manager->addMetaVariable("y", 0, 3));
  40. EXPECT_EQ(4ul, manager->getNumberOfMetaVariables());
  41. EXPECT_TRUE(manager->hasMetaVariable("x'"));
  42. EXPECT_TRUE(manager->hasMetaVariable("y'"));
  43. std::set<std::string> metaVariableSet = {"x", "x'", "y", "y'"};
  44. EXPECT_EQ(metaVariableSet, manager->getAllMetaVariableNames());
  45. }
  46. TEST(CuddDd, EncodingTest) {
  47. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  48. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  49. storm::dd::Bdd<storm::dd::DdType::CUDD> encoding;
  50. ASSERT_THROW(encoding = manager->getEncoding(x.first, 0), storm::exceptions::InvalidArgumentException);
  51. ASSERT_THROW(encoding = manager->getEncoding(x.first, 10), storm::exceptions::InvalidArgumentException);
  52. ASSERT_NO_THROW(encoding = manager->getEncoding(x.first, 4));
  53. EXPECT_EQ(1ul, encoding.getNonZeroCount());
  54. // As a BDD, this DD has one only leaf, because there does not exist a 0-leaf, and (consequently) one node less
  55. // than the MTBDD.
  56. EXPECT_EQ(5ul, encoding.getNodeCount());
  57. EXPECT_EQ(1ul, encoding.getLeafCount());
  58. // As an MTBDD, the 0-leaf is there, so the count is actually 2 and the node count is 6.
  59. EXPECT_EQ(6ul, encoding.template toAdd<double>().getNodeCount());
  60. EXPECT_EQ(2ul, encoding.template toAdd<double>().getLeafCount());
  61. }
  62. TEST(CuddDd, RangeTest) {
  63. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  64. std::pair<storm::expressions::Variable, storm::expressions::Variable> x;
  65. ASSERT_NO_THROW(x = manager->addMetaVariable("x", 1, 9));
  66. storm::dd::Bdd<storm::dd::DdType::CUDD> range;
  67. ASSERT_NO_THROW(range = manager->getRange(x.first));
  68. EXPECT_EQ(9ul, range.getNonZeroCount());
  69. EXPECT_EQ(1ul, range.getLeafCount());
  70. EXPECT_EQ(5ul, range.getNodeCount());
  71. }
  72. TEST(CuddDd, IdentityTest) {
  73. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  74. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  75. storm::dd::Add<storm::dd::DdType::CUDD, double> identity;
  76. ASSERT_NO_THROW(identity = manager->getIdentity<double>(x.first));
  77. EXPECT_EQ(9ul, identity.getNonZeroCount());
  78. EXPECT_EQ(10ul, identity.getLeafCount());
  79. EXPECT_EQ(21ul, identity.getNodeCount());
  80. }
  81. TEST(CuddDd, OperatorTest) {
  82. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  83. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  84. EXPECT_TRUE(manager->template getAddZero<double>() == manager->template getAddZero<double>());
  85. EXPECT_FALSE(manager->template getAddZero<double>() == manager->template getAddOne<double>());
  86. EXPECT_FALSE(manager->template getAddZero<double>() != manager->template getAddZero<double>());
  87. EXPECT_TRUE(manager->template getAddZero<double>() != manager->template getAddOne<double>());
  88. storm::dd::Add<storm::dd::DdType::CUDD, double> dd1 = manager->template getAddOne<double>();
  89. storm::dd::Add<storm::dd::DdType::CUDD, double> dd2 = manager->template getAddOne<double>();
  90. storm::dd::Add<storm::dd::DdType::CUDD, double> dd3 = dd1 + dd2;
  91. storm::dd::Bdd<storm::dd::DdType::CUDD> bdd;
  92. EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
  93. dd3 += manager->template getAddZero<double>();
  94. EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
  95. dd3 = dd1 * manager->template getConstant<double>(3);
  96. EXPECT_TRUE(dd3 == manager->template getConstant<double>(3));
  97. dd3 *= manager->template getConstant<double>(2);
  98. EXPECT_TRUE(dd3 == manager->template getConstant<double>(6));
  99. dd3 = dd1 - dd2;
  100. EXPECT_TRUE(dd3.isZero());
  101. dd3 -= manager->template getConstant<double>(-2);
  102. EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
  103. dd3 /= manager->template getConstant<double>(2);
  104. EXPECT_TRUE(dd3.isOne());
  105. bdd = !dd3.toBdd();
  106. EXPECT_TRUE(bdd.isZero());
  107. bdd = !bdd;
  108. EXPECT_TRUE(bdd.isOne());
  109. bdd = dd1.toBdd() || dd2.toBdd();
  110. EXPECT_TRUE(bdd.isOne());
  111. dd1 = manager->template getIdentity<double>(x.first);
  112. dd2 = manager->template getConstant<double>(5);
  113. dd3 = dd1.equals(dd2).template toAdd<double>();
  114. EXPECT_EQ(1ul, dd3.getNonZeroCount());
  115. storm::dd::Add<storm::dd::DdType::CUDD, double> dd4 = dd1.notEquals(dd2).template toAdd<double>();
  116. EXPECT_TRUE(dd4.toBdd() == !dd3.toBdd());
  117. dd3 = dd1.less(dd2).template toAdd<double>();
  118. EXPECT_EQ(11ul, dd3.getNonZeroCount());
  119. dd3 = dd1.lessOrEqual(dd2).template toAdd<double>();
  120. EXPECT_EQ(12ul, dd3.getNonZeroCount());
  121. dd3 = dd1.greater(dd2).template toAdd<double>();
  122. EXPECT_EQ(4ul, dd3.getNonZeroCount());
  123. dd3 = dd1.greaterOrEqual(dd2).template toAdd<double>();
  124. EXPECT_EQ(5ul, dd3.getNonZeroCount());
  125. dd3 = manager->getEncoding(x.first, 2).ite(dd2, dd1);
  126. dd4 = dd3.less(dd2).template toAdd<double>();
  127. EXPECT_EQ(10ul, dd4.getNonZeroCount());
  128. dd4 = dd3.minimum(dd1);
  129. dd4 *= manager->getEncoding(x.first, 2).template toAdd<double>();
  130. dd4 = dd4.sumAbstract({x.first});
  131. EXPECT_EQ(2, dd4.getValue());
  132. dd4 = dd3.maximum(dd1);
  133. dd4 *= manager->getEncoding(x.first, 2).template toAdd<double>();
  134. dd4 = dd4.sumAbstract({x.first});
  135. EXPECT_EQ(5, dd4.getValue());
  136. dd1 = manager->template getConstant<double>(0.01);
  137. dd2 = manager->template getConstant<double>(0.01 + 1e-6);
  138. EXPECT_TRUE(dd1.equalModuloPrecision(dd2, 1e-6, false));
  139. EXPECT_FALSE(dd1.equalModuloPrecision(dd2, 1e-6));
  140. }
  141. TEST(CuddDd, AbstractionTest) {
  142. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  143. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  144. storm::dd::Add<storm::dd::DdType::CUDD, double> dd1;
  145. storm::dd::Add<storm::dd::DdType::CUDD, double> dd2;
  146. storm::dd::Add<storm::dd::DdType::CUDD, double> dd3;
  147. dd1 = manager->template getIdentity<double>(x.first);
  148. dd2 = manager->template getConstant<double>(5);
  149. dd3 = dd1.equals(dd2).template toAdd<double>();
  150. storm::dd::Bdd<storm::dd::DdType::CUDD> dd3Bdd = dd3.toBdd();
  151. EXPECT_EQ(1ul, dd3Bdd.getNonZeroCount());
  152. ASSERT_THROW(dd3Bdd = dd3Bdd.existsAbstract({x.second}), storm::exceptions::InvalidArgumentException);
  153. ASSERT_NO_THROW(dd3Bdd = dd3Bdd.existsAbstract({x.first}));
  154. EXPECT_EQ(0ul, dd3Bdd.getNonZeroCount());
  155. EXPECT_EQ(1, dd3Bdd.template toAdd<double>().getMax());
  156. dd3 = dd1.equals(dd2).template toAdd<double>();
  157. dd3 *= manager->template getConstant<double>(3);
  158. EXPECT_EQ(1ul, dd3.getNonZeroCount());
  159. ASSERT_THROW(dd3Bdd = dd3.toBdd().existsAbstract({x.second}), storm::exceptions::InvalidArgumentException);
  160. ASSERT_NO_THROW(dd3Bdd = dd3.toBdd().existsAbstract({x.first}));
  161. EXPECT_TRUE(dd3Bdd.isOne());
  162. dd3 = dd1.equals(dd2).template toAdd<double>();
  163. dd3 *= manager->template getConstant<double>(3);
  164. ASSERT_THROW(dd3 = dd3.sumAbstract({x.second}), storm::exceptions::InvalidArgumentException);
  165. ASSERT_NO_THROW(dd3 = dd3.sumAbstract({x.first}));
  166. EXPECT_EQ(0ul, dd3.getNonZeroCount());
  167. EXPECT_EQ(3, dd3.getMax());
  168. dd3 = dd1.equals(dd2).template toAdd<double>();
  169. dd3 *= manager->template getConstant<double>(3);
  170. ASSERT_THROW(dd3 = dd3.minAbstract({x.second}), storm::exceptions::InvalidArgumentException);
  171. ASSERT_NO_THROW(dd3 = dd3.minAbstract({x.first}));
  172. EXPECT_EQ(0ul, dd3.getNonZeroCount());
  173. EXPECT_EQ(0, dd3.getMax());
  174. dd3 = dd1.equals(dd2).template toAdd<double>();
  175. dd3 *= manager->template getConstant<double>(3);
  176. ASSERT_THROW(dd3 = dd3.maxAbstract({x.second}), storm::exceptions::InvalidArgumentException);
  177. ASSERT_NO_THROW(dd3 = dd3.maxAbstract({x.first}));
  178. EXPECT_EQ(0ul, dd3.getNonZeroCount());
  179. EXPECT_EQ(3, dd3.getMax());
  180. }
  181. TEST(CuddDd, SwapTest) {
  182. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  183. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  184. std::pair<storm::expressions::Variable, storm::expressions::Variable> z = manager->addMetaVariable("z", 2, 8);
  185. storm::dd::Add<storm::dd::DdType::CUDD, double> dd1;
  186. storm::dd::Add<storm::dd::DdType::CUDD, double> dd2;
  187. dd1 = manager->template getIdentity<double>(x.first);
  188. ASSERT_THROW(dd1 = dd1.swapVariables({std::make_pair(x.first, z.first)}), storm::exceptions::InvalidArgumentException);
  189. ASSERT_NO_THROW(dd1 = dd1.swapVariables({std::make_pair(x.first, x.second)}));
  190. EXPECT_TRUE(dd1 == manager->template getIdentity<double>(x.second));
  191. }
  192. TEST(CuddDd, MultiplyMatrixTest) {
  193. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  194. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  195. storm::dd::Add<storm::dd::DdType::CUDD, double> dd1 = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)).template toAdd<double>();
  196. storm::dd::Add<storm::dd::DdType::CUDD, double> dd2 = manager->getRange(x.second).template toAdd<double>();
  197. storm::dd::Add<storm::dd::DdType::CUDD, double> dd3;
  198. dd1 *= manager->template getConstant<double>(2);
  199. ASSERT_NO_THROW(dd3 = dd1.multiplyMatrix(dd2, {x.second}));
  200. ASSERT_NO_THROW(dd3 = dd3.swapVariables({std::make_pair(x.first, x.second)}));
  201. EXPECT_TRUE(dd3 == dd2 * manager->template getConstant<double>(2));
  202. }
  203. TEST(CuddDd, GetSetValueTest) {
  204. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  205. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  206. storm::dd::Add<storm::dd::DdType::CUDD, double> dd1 = manager->template getAddOne<double>();
  207. ASSERT_NO_THROW(dd1.setValue(x.first, 4, 2));
  208. EXPECT_EQ(2ul, dd1.getLeafCount());
  209. std::map<storm::expressions::Variable, int_fast64_t> metaVariableToValueMap;
  210. metaVariableToValueMap.emplace(x.first, 1);
  211. EXPECT_EQ(1, dd1.getValue(metaVariableToValueMap));
  212. metaVariableToValueMap.clear();
  213. metaVariableToValueMap.emplace(x.first, 4);
  214. EXPECT_EQ(2, dd1.getValue(metaVariableToValueMap));
  215. }
  216. TEST(CuddDd, AddIteratorTest) {
  217. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  218. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  219. std::pair<storm::expressions::Variable, storm::expressions::Variable> y = manager->addMetaVariable("y", 0, 3);
  220. storm::dd::Add<storm::dd::DdType::CUDD, double> dd;
  221. ASSERT_NO_THROW(dd = manager->getRange(x.first).template toAdd<double>());
  222. storm::dd::AddIterator<storm::dd::DdType::CUDD, double> it, ite;
  223. ASSERT_NO_THROW(it = dd.begin());
  224. ASSERT_NO_THROW(ite = dd.end());
  225. std::pair<storm::expressions::SimpleValuation, double> valuationValuePair;
  226. uint_fast64_t numberOfValuations = 0;
  227. while (it != ite) {
  228. ASSERT_NO_THROW(valuationValuePair = *it);
  229. ASSERT_NO_THROW(++it);
  230. ++numberOfValuations;
  231. }
  232. EXPECT_EQ(9ul, numberOfValuations);
  233. dd = manager->getRange(x.first).template toAdd<double>();
  234. dd = dd.notZero().ite(manager->template getAddOne<double>(), manager->template getAddOne<double>());
  235. ASSERT_NO_THROW(it = dd.begin());
  236. ASSERT_NO_THROW(ite = dd.end());
  237. numberOfValuations = 0;
  238. while (it != ite) {
  239. ASSERT_NO_THROW(valuationValuePair = *it);
  240. ASSERT_NO_THROW(++it);
  241. ++numberOfValuations;
  242. }
  243. EXPECT_EQ(16ul, numberOfValuations);
  244. ASSERT_NO_THROW(it = dd.begin(false));
  245. ASSERT_NO_THROW(ite = dd.end());
  246. numberOfValuations = 0;
  247. while (it != ite) {
  248. ASSERT_NO_THROW(valuationValuePair = *it);
  249. ASSERT_NO_THROW(++it);
  250. ++numberOfValuations;
  251. }
  252. EXPECT_EQ(1ul, numberOfValuations);
  253. }
  254. TEST(CuddDd, AddOddTest) {
  255. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  256. std::pair<storm::expressions::Variable, storm::expressions::Variable> a = manager->addMetaVariable("a");
  257. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  258. storm::dd::Add<storm::dd::DdType::CUDD, double> dd = manager->template getIdentity<double>(x.first);
  259. storm::dd::Odd odd;
  260. ASSERT_NO_THROW(odd = dd.createOdd());
  261. EXPECT_EQ(9ul, odd.getTotalOffset());
  262. EXPECT_EQ(12ul, odd.getNodeCount());
  263. std::vector<double> ddAsVector;
  264. ASSERT_NO_THROW(ddAsVector = dd.toVector());
  265. EXPECT_EQ(9ul, ddAsVector.size());
  266. for (uint_fast64_t i = 0; i < ddAsVector.size(); ++i) {
  267. EXPECT_TRUE(i+1 == ddAsVector[i]);
  268. }
  269. // Create a non-trivial matrix.
  270. dd = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
  271. dd += manager->getEncoding(x.first, 1).template toAdd<double>() * manager->getRange(x.second).template toAdd<double>() + manager->getEncoding(x.second, 1).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
  272. // Create the ODDs.
  273. storm::dd::Odd rowOdd;
  274. ASSERT_NO_THROW(rowOdd = manager->getRange(x.first).template toAdd<double>().createOdd());
  275. storm::dd::Odd columnOdd;
  276. ASSERT_NO_THROW(columnOdd = manager->getRange(x.second).template toAdd<double>().createOdd());
  277. // Try to translate the matrix.
  278. storm::storage::SparseMatrix<double> matrix;
  279. ASSERT_NO_THROW(matrix = dd.toMatrix({x.first}, {x.second}, rowOdd, columnOdd));
  280. EXPECT_EQ(9ul, matrix.getRowCount());
  281. EXPECT_EQ(9ul, matrix.getColumnCount());
  282. EXPECT_EQ(25ul, matrix.getNonzeroEntryCount());
  283. dd = manager->getRange(x.first).template toAdd<double>() * manager->getRange(x.second).template toAdd<double>() * manager->getEncoding(a.first, 0).ite(dd, dd + manager->template getConstant<double>(1));
  284. ASSERT_NO_THROW(matrix = dd.toMatrix({a.first}, rowOdd, columnOdd));
  285. EXPECT_EQ(18ul, matrix.getRowCount());
  286. EXPECT_EQ(9ul, matrix.getRowGroupCount());
  287. EXPECT_EQ(9ul, matrix.getColumnCount());
  288. EXPECT_EQ(106ul, matrix.getNonzeroEntryCount());
  289. }
  290. TEST(CuddDd, BddOddTest) {
  291. std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
  292. std::pair<storm::expressions::Variable, storm::expressions::Variable> a = manager->addMetaVariable("a");
  293. std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
  294. storm::dd::Add<storm::dd::DdType::CUDD, double> dd = manager->template getIdentity<double>(x.first);
  295. storm::dd::Bdd<storm::dd::DdType::CUDD> bdd = dd.notZero();
  296. storm::dd::Odd odd;
  297. ASSERT_NO_THROW(odd = bdd.createOdd());
  298. EXPECT_EQ(9ul, odd.getTotalOffset());
  299. EXPECT_EQ(5ul, odd.getNodeCount());
  300. std::vector<double> ddAsVector;
  301. ASSERT_NO_THROW(ddAsVector = dd.toVector());
  302. EXPECT_EQ(9ul, ddAsVector.size());
  303. for (uint_fast64_t i = 0; i < ddAsVector.size(); ++i) {
  304. EXPECT_TRUE(i+1 == ddAsVector[i]);
  305. }
  306. storm::dd::Add<storm::dd::DdType::CUDD, double> vectorAdd = storm::dd::Add<storm::dd::DdType::CUDD, double>::fromVector(*manager, ddAsVector, odd, {x.first});
  307. // Create a non-trivial matrix.
  308. dd = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
  309. dd += manager->getEncoding(x.first, 1).template toAdd<double>() * manager->getRange(x.second).template toAdd<double>() + manager->getEncoding(x.second, 1).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
  310. // Create the ODDs.
  311. storm::dd::Odd rowOdd;
  312. ASSERT_NO_THROW(rowOdd = manager->getRange(x.first).createOdd());
  313. storm::dd::Odd columnOdd;
  314. ASSERT_NO_THROW(columnOdd = manager->getRange(x.second).createOdd());
  315. // Try to translate the matrix.
  316. storm::storage::SparseMatrix<double> matrix;
  317. ASSERT_NO_THROW(matrix = dd.toMatrix({x.first}, {x.second}, rowOdd, columnOdd));
  318. EXPECT_EQ(9ul, matrix.getRowCount());
  319. EXPECT_EQ(9ul, matrix.getColumnCount());
  320. EXPECT_EQ(25ul, matrix.getNonzeroEntryCount());
  321. dd = manager->getRange(x.first).template toAdd<double>() * manager->getRange(x.second).template toAdd<double>() * manager->getEncoding(a.first, 0).ite(dd, dd + manager->template getConstant<double>(1));
  322. ASSERT_NO_THROW(matrix = dd.toMatrix({a.first}, rowOdd, columnOdd));
  323. EXPECT_EQ(18ul, matrix.getRowCount());
  324. EXPECT_EQ(9ul, matrix.getRowGroupCount());
  325. EXPECT_EQ(9ul, matrix.getColumnCount());
  326. EXPECT_EQ(106ul, matrix.getNonzeroEntryCount());
  327. }