|
|
@ -159,103 +159,129 @@ TEST(CuddDd, BddExistAbstractRepresentative) { |
|
|
|
EXPECT_EQ(4ul, representative_xyz.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddX0Y0Z0 == representative_xyz); |
|
|
|
} |
|
|
|
/*
|
|
|
|
|
|
|
|
TEST(CuddDd, AddMinExistAbstractRepresentative) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>()); |
|
|
|
|
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddZero; |
|
|
|
ASSERT_NO_THROW(bddZero = manager->getBddZero()); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddOne; |
|
|
|
ASSERT_NO_THROW(bddOne = manager->getBddOne()); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> zero; |
|
|
|
ASSERT_NO_THROW(zero = manager->template getAddZero<double>()); |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> one; |
|
|
|
ASSERT_NO_THROW(one = manager->template getAddOne<double>()); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> addZero; |
|
|
|
ASSERT_NO_THROW(addZero = manager->template getAddZero<double>()); |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> addOne; |
|
|
|
ASSERT_NO_THROW(addOne = manager->template getAddOne<double>()); |
|
|
|
|
|
|
|
std::pair<storm::expressions::Variable, storm::expressions::Variable> x; |
|
|
|
std::pair<storm::expressions::Variable, storm::expressions::Variable> y; |
|
|
|
std::pair<storm::expressions::Variable, storm::expressions::Variable> z; |
|
|
|
ASSERT_NO_THROW(x = manager->addMetaVariable("x", 0, 1)); |
|
|
|
ASSERT_NO_THROW(y = manager->addMetaVariable("y", 0, 1)); |
|
|
|
ASSERT_NO_THROW(z = manager->addMetaVariable("z", 0, 1)); |
|
|
|
|
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddX0 = manager->getEncoding(x.first, 0); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddX1 = manager->getEncoding(x.first, 1); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddY0 = manager->getEncoding(y.first, 0); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddY1 = manager->getEncoding(y.first, 1); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddZ0 = manager->getEncoding(z.first, 0); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> bddZ1 = manager->getEncoding(z.first, 1); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> complexAdd = |
|
|
|
((bddX1 && (bddY1 && bddZ1)).template toAdd<double>() * manager->template getConstant<double>(0.4)) |
|
|
|
+ ((bddX1 && (bddY1 && bddZ0)).template toAdd<double>() * manager->template getConstant<double>(0.7)) |
|
|
|
+ ((bddX1 && (bddY0 && bddZ1)).template toAdd<double>() * manager->template getConstant<double>(0.3)) |
|
|
|
+ ((bddX1 && (bddY0 && bddZ0)).template toAdd<double>() * manager->template getConstant<double>(0.3)) |
|
|
|
+ ((bddX0 && (bddY1 && bddZ1)).template toAdd<double>() * manager->template getConstant<double>(0.9)) |
|
|
|
+ ((bddX0 && (bddY1 && bddZ0)).template toAdd<double>() * manager->template getConstant<double>(0.5)) |
|
|
|
+ ((bddX0 && (bddY0 && bddZ1)).template toAdd<double>() * manager->template getConstant<double>(1.0)) |
|
|
|
+ ((bddX0 && (bddY0 && bddZ0)).template toAdd<double>() * manager->template getConstant<double>(0.0)); |
|
|
|
complexAdd.exportToDot("test_CUDD_complexAdd.dot"); |
|
|
|
|
|
|
|
// Abstract from FALSE
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> representative_false_x = zero.existsAbstractRepresentative({x.first}); |
|
|
|
std::cout << "Before FALSE" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_false_x = addZero.minAbstractRepresentative({x.first}); |
|
|
|
EXPECT_EQ(0ul, representative_false_x.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_false_x.getLeafCount()); |
|
|
|
EXPECT_EQ(1ul, representative_false_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_false_x == zero); |
|
|
|
|
|
|
|
EXPECT_EQ(2ul, representative_false_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_false_x == bddX0); |
|
|
|
representative_false_x.exportToDot("test_CUDD_representative_false_x.dot"); |
|
|
|
bddX0.exportToDot("test_CUDD_bddX0.dot"); |
|
|
|
|
|
|
|
// Abstract from TRUE
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> representative_true_x = one.existsAbstractRepresentative({x.first}); |
|
|
|
EXPECT_EQ(1ul, representative_true_x.getNonZeroCount()); |
|
|
|
std::cout << "Before TRUE" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_true_x = addOne.minAbstractRepresentative({x.first}); |
|
|
|
EXPECT_EQ(0ul, representative_true_x.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_true_x.getLeafCount()); |
|
|
|
EXPECT_EQ(1ul, representative_true_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_true_x == manager->getEncoding(x.first, 0)); |
|
|
|
EXPECT_EQ(2ul, representative_true_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_true_x == bddX0); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddX1 = manager->getEncoding(x.first, 1); |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddY0 = manager->getEncoding(y.first, 0); |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddZ0 = manager->getEncoding(z.first, 0); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddX1Y0Z0 = (bddX1 && bddY0) && bddZ0; |
|
|
|
EXPECT_EQ(1ul, bddX1Y0Z0.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, bddX1Y0Z0.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, bddX1Y0Z0.getNodeCount()); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> representative_x = bddX1Y0Z0.existsAbstractRepresentative({x.first}); |
|
|
|
EXPECT_EQ(1ul, representative_x.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_x.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddX1Y0Z0 == representative_x); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> representative_y = bddX1Y0Z0.existsAbstractRepresentative({y.first}); |
|
|
|
EXPECT_EQ(1ul, representative_y.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_y.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_y.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddX1Y0Z0 == representative_y); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> representative_z = bddX1Y0Z0.existsAbstractRepresentative({z.first}); |
|
|
|
EXPECT_EQ(1ul, representative_z.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_z.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_z.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddX1Y0Z0 == representative_z); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> representative_xyz = bddX1Y0Z0.existsAbstractRepresentative({x.first, y.first, z.first}); |
|
|
|
EXPECT_EQ(1ul, representative_xyz.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_xyz.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_xyz.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddX1Y0Z0 == representative_xyz); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddX0 = manager->getEncoding(x.first, 0); |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddY1 = manager->getEncoding(y.first, 1); |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddZ1 = manager->getEncoding(z.first, 1); |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddX0Y0Z0 = (bddX0 && bddY0) && bddZ0; |
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddX1Y1Z1 = (bddX1 && bddY1) && bddZ1; |
|
|
|
|
|
|
|
storm::dd::Add<storm::dd::DdType::CUDD, double> bddAllTrueOrAllFalse = bddX0Y0Z0 || bddX1Y1Z1; |
|
|
|
//bddAllTrueOrAllFalse.template toAdd<double>().exportToDot("test_cudd_addAllTrueOrAllFalse.dot");
|
|
|
|
|
|
|
|
representative_x = bddAllTrueOrAllFalse.existsAbstractRepresentative({x.first}); |
|
|
|
EXPECT_EQ(2ul, representative_x.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_x.getLeafCount()); |
|
|
|
EXPECT_EQ(5ul, representative_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddAllTrueOrAllFalse == representative_x); |
|
|
|
|
|
|
|
representative_y = bddAllTrueOrAllFalse.existsAbstractRepresentative({y.first}); |
|
|
|
EXPECT_EQ(2ul, representative_y.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_y.getLeafCount()); |
|
|
|
EXPECT_EQ(5ul, representative_y.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddAllTrueOrAllFalse == representative_y); |
|
|
|
|
|
|
|
representative_z = bddAllTrueOrAllFalse.existsAbstractRepresentative({z.first}); |
|
|
|
EXPECT_EQ(2ul, representative_z.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_z.getLeafCount()); |
|
|
|
EXPECT_EQ(5ul, representative_z.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddAllTrueOrAllFalse == representative_z); |
|
|
|
|
|
|
|
representative_xyz = bddAllTrueOrAllFalse.existsAbstractRepresentative({x.first, y.first, z.first}); |
|
|
|
EXPECT_EQ(1ul, representative_xyz.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_xyz.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_xyz.getNodeCount()); |
|
|
|
EXPECT_TRUE(bddX0Y0Z0 == representative_xyz); |
|
|
|
}*/ |
|
|
|
std::cout << "Before TRUE xyz" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_true_xyz = addOne.minAbstractRepresentative({x.first, y.first, z.first}); |
|
|
|
EXPECT_EQ(0ul, representative_true_xyz.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_true_xyz.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_true_xyz.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_true_xyz == ((bddX0 && bddY0) && bddZ0)); |
|
|
|
|
|
|
|
// Abstract x
|
|
|
|
std::cout << "Before x" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_complex_x = complexAdd.minAbstractRepresentative({x.first}); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> comparison_complex_x = ( |
|
|
|
((bddX0 && (bddY0 && bddZ0))) |
|
|
|
|| ((bddX1 && (bddY0 && bddZ1))) |
|
|
|
|| ((bddX0 && (bddY1 && bddZ0))) |
|
|
|
|| ((bddX1 && (bddY1 && bddZ1))) |
|
|
|
); |
|
|
|
EXPECT_EQ(4ul, representative_complex_x.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_complex_x.getLeafCount()); |
|
|
|
EXPECT_EQ(3ul, representative_complex_x.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_complex_x == comparison_complex_x); |
|
|
|
representative_complex_x.template toAdd<double>().exportToDot("test_CUDD_representative_complex_x.dot"); |
|
|
|
comparison_complex_x.template toAdd<double>().exportToDot("test_CUDD_comparison_complex_x.dot"); |
|
|
|
|
|
|
|
// Abstract y
|
|
|
|
std::cout << "Before y" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_complex_y = complexAdd.minAbstractRepresentative({y.first}); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> comparison_complex_y = ( |
|
|
|
((bddX0 && (bddY0 && bddZ0))) |
|
|
|
|| ((bddX0 && (bddY1 && bddZ1))) |
|
|
|
|| ((bddX1 && (bddY0 && bddZ0))) |
|
|
|
|| ((bddX1 && (bddY0 && bddZ1))) |
|
|
|
); |
|
|
|
EXPECT_EQ(4ul, representative_complex_y.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_complex_y.getLeafCount()); |
|
|
|
EXPECT_EQ(5ul, representative_complex_y.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_complex_y == comparison_complex_y); |
|
|
|
representative_complex_y.template toAdd<double>().exportToDot("test_CUDD_representative_complex_y.dot"); |
|
|
|
comparison_complex_y.template toAdd<double>().exportToDot("test_CUDD_comparison_complex_y.dot"); |
|
|
|
|
|
|
|
// Abstract z
|
|
|
|
std::cout << "Before z" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_complex_z = complexAdd.minAbstractRepresentative({z.first}); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> comparison_complex_z = ( |
|
|
|
((bddX0 && (bddY0 && bddZ0))) |
|
|
|
|| ((bddX0 && (bddY1 && bddZ0))) |
|
|
|
|| ((bddX1 && (bddY0 && bddZ0))) |
|
|
|
|| ((bddX1 && (bddY1 && bddZ1))) |
|
|
|
); |
|
|
|
EXPECT_EQ(0ul, representative_complex_z.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_complex_z.getLeafCount()); |
|
|
|
EXPECT_EQ(2ul, representative_complex_z.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_complex_z == comparison_complex_z); |
|
|
|
representative_complex_z.template toAdd<double>().exportToDot("test_CUDD_representative_complex_z.dot"); |
|
|
|
comparison_complex_z.template toAdd<double>().exportToDot("test_CUDD_comparison_complex_z.dot"); |
|
|
|
|
|
|
|
// Abstract x, y, z
|
|
|
|
std::cout << "Before x, y, z" << std::endl; |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> representative_complex_xyz = complexAdd.minAbstractRepresentative({x.first, y.first, z.first}); |
|
|
|
storm::dd::Bdd<storm::dd::DdType::CUDD> comparison_complex_xyz = (bddX0 && (bddY0 && bddZ0)); |
|
|
|
EXPECT_EQ(1ul, representative_complex_xyz.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1ul, representative_complex_xyz.getLeafCount()); |
|
|
|
EXPECT_EQ(4ul, representative_complex_xyz.getNodeCount()); |
|
|
|
EXPECT_TRUE(representative_complex_xyz == comparison_complex_xyz); |
|
|
|
representative_complex_xyz.template toAdd<double>().exportToDot("test_CUDD_representative_complex_xyz.dot"); |
|
|
|
comparison_complex_xyz.template toAdd<double>().exportToDot("test_CUDD_representative_complex_xyz.dot"); |
|
|
|
} |
|
|
|
|
|
|
|
TEST(CuddDd, AddGetMetaVariableTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>()); |
|
|
|