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.

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