|
|
@ -7,7 +7,6 @@ |
|
|
|
|
|
|
|
TEST(CuddDdManager, Constants) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> zero; |
|
|
|
ASSERT_NO_THROW(zero = manager->getZero()); |
|
|
|
|
|
|
@ -38,7 +37,6 @@ TEST(CuddDdManager, Constants) { |
|
|
|
|
|
|
|
TEST(CuddDdManager, AddGetMetaVariableTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9)); |
|
|
|
EXPECT_EQ(1, manager->getNumberOfMetaVariables()); |
|
|
|
|
|
|
@ -64,8 +62,7 @@ TEST(CuddDdManager, AddGetMetaVariableTest) { |
|
|
|
|
|
|
|
TEST(CuddDdManager, EncodingTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9)); |
|
|
|
manager->addMetaVariable("x", 1, 9); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> encoding; |
|
|
|
ASSERT_THROW(encoding = manager->getEncoding("x", 0), storm::exceptions::InvalidArgumentException); |
|
|
@ -78,7 +75,6 @@ TEST(CuddDdManager, EncodingTest) { |
|
|
|
|
|
|
|
TEST(CuddDdManager, RangeTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9)); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> range; |
|
|
@ -92,8 +88,7 @@ TEST(CuddDdManager, RangeTest) { |
|
|
|
|
|
|
|
TEST(CuddDdManager, IdentityTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9)); |
|
|
|
manager->addMetaVariable("x", 1, 9); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> range; |
|
|
|
ASSERT_THROW(range = manager->getIdentity("y"), storm::exceptions::InvalidArgumentException); |
|
|
@ -106,8 +101,7 @@ TEST(CuddDdManager, IdentityTest) { |
|
|
|
|
|
|
|
TEST(CuddDdMetaVariable, AccessorTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9)); |
|
|
|
manager->addMetaVariable("x", 1, 9); |
|
|
|
EXPECT_EQ(1, manager->getNumberOfMetaVariables()); |
|
|
|
ASSERT_NO_THROW(storm::dd::DdMetaVariable<storm::dd::CUDD> const& metaVariableX = manager->getMetaVariable("x")); |
|
|
|
storm::dd::DdMetaVariable<storm::dd::CUDD> const& metaVariableX = manager->getMetaVariable("x"); |
|
|
@ -119,13 +113,150 @@ TEST(CuddDdMetaVariable, AccessorTest) { |
|
|
|
EXPECT_EQ(4, metaVariableX.getNumberOfDdVariables()); |
|
|
|
} |
|
|
|
|
|
|
|
//TEST(CuddDd, OperatorTest) {
|
|
|
|
// std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>());
|
|
|
|
//
|
|
|
|
// ASSERT_NO_THROW(manager->addMetaVariable("x", 1, 9));
|
|
|
|
// EXPECT_EQ(manager->getZero(), manager->getZero());
|
|
|
|
// EXPECT_NE(manager->getZero(), manager->getOne());
|
|
|
|
//
|
|
|
|
// storm::dd::Dd<storm::dd::CUDD> add;
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
TEST(CuddDd, OperatorTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
manager->addMetaVariable("x", 1, 9); |
|
|
|
EXPECT_TRUE(manager->getZero() == manager->getZero()); |
|
|
|
EXPECT_FALSE(manager->getZero() == manager->getOne()); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd1 = manager->getOne(); |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd2 = manager->getOne(); |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd3 = dd1 + dd2; |
|
|
|
EXPECT_TRUE(dd3 == manager->getConstant(2)); |
|
|
|
|
|
|
|
dd3 += manager->getZero(); |
|
|
|
EXPECT_TRUE(dd3 == manager->getConstant(2)); |
|
|
|
|
|
|
|
dd3 = dd1 * manager->getConstant(3); |
|
|
|
EXPECT_TRUE(dd3 == manager->getConstant(3)); |
|
|
|
|
|
|
|
dd3 *= manager->getConstant(2); |
|
|
|
EXPECT_TRUE(dd3 == manager->getConstant(6)); |
|
|
|
|
|
|
|
dd3 = dd1 - dd2; |
|
|
|
EXPECT_TRUE(dd3 == manager->getZero()); |
|
|
|
|
|
|
|
dd3 -= manager->getConstant(-2); |
|
|
|
EXPECT_TRUE(dd3 == manager->getConstant(2)); |
|
|
|
|
|
|
|
dd3 /= manager->getConstant(2); |
|
|
|
EXPECT_TRUE(dd3 == manager->getOne()); |
|
|
|
|
|
|
|
dd3.complement(); |
|
|
|
EXPECT_TRUE(dd3 == manager->getZero()); |
|
|
|
|
|
|
|
dd1 = ~dd3; |
|
|
|
EXPECT_TRUE(dd1 == manager->getOne()); |
|
|
|
|
|
|
|
dd1 = manager->getIdentity("x"); |
|
|
|
dd2 = manager->getConstant(5); |
|
|
|
|
|
|
|
dd3 = dd1.equals(dd2); |
|
|
|
EXPECT_EQ(1, dd3.getNonZeroCount()); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd4 = dd1.notEquals(dd2); |
|
|
|
EXPECT_TRUE(dd4 == ~dd3); |
|
|
|
|
|
|
|
dd3 = dd1.less(dd2); |
|
|
|
EXPECT_EQ(11, dd3.getNonZeroCount()); |
|
|
|
|
|
|
|
dd3 = dd1.lessOrEqual(dd2); |
|
|
|
EXPECT_EQ(12, dd3.getNonZeroCount()); |
|
|
|
|
|
|
|
dd3 = dd1.greater(dd2); |
|
|
|
EXPECT_EQ(4, dd3.getNonZeroCount()); |
|
|
|
|
|
|
|
dd3 = dd1.greaterOrEqual(dd2); |
|
|
|
EXPECT_EQ(5, dd3.getNonZeroCount()); |
|
|
|
} |
|
|
|
|
|
|
|
TEST(CuddDd, AbstractionTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
manager->addMetaVariablesInterleaved({"x", "x'"}, 1, 9); |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd1; |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd2; |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd3; |
|
|
|
|
|
|
|
dd1 = manager->getIdentity("x"); |
|
|
|
dd2 = manager->getConstant(5); |
|
|
|
dd3 = dd1.equals(dd2); |
|
|
|
EXPECT_EQ(1, dd3.getNonZeroCount()); |
|
|
|
ASSERT_THROW(dd3.existsAbstract({"x'"}), storm::exceptions::InvalidArgumentException); |
|
|
|
ASSERT_NO_THROW(dd3.existsAbstract({"x"})); |
|
|
|
EXPECT_EQ(1, dd3.getNonZeroCount()); |
|
|
|
EXPECT_EQ(1, dd3.getMax()); |
|
|
|
|
|
|
|
dd3 = dd1.equals(dd2); |
|
|
|
dd3 *= manager->getConstant(3); |
|
|
|
EXPECT_EQ(1, dd3.getNonZeroCount()); |
|
|
|
ASSERT_THROW(dd3.existsAbstract({"x'"}), storm::exceptions::InvalidArgumentException); |
|
|
|
ASSERT_NO_THROW(dd3.existsAbstract({"x"})); |
|
|
|
EXPECT_TRUE(dd3 == manager->getZero()); |
|
|
|
|
|
|
|
dd3 = dd1.equals(dd2); |
|
|
|
dd3 *= manager->getConstant(3); |
|
|
|
ASSERT_THROW(dd3.sumAbstract({"x'"}), storm::exceptions::InvalidArgumentException); |
|
|
|
ASSERT_NO_THROW(dd3.sumAbstract({"x"})); |
|
|
|
EXPECT_EQ(1, dd3.getNonZeroCount()); |
|
|
|
EXPECT_EQ(3, dd3.getMax()); |
|
|
|
|
|
|
|
dd3 = dd1.equals(dd2); |
|
|
|
dd3 *= manager->getConstant(3); |
|
|
|
ASSERT_THROW(dd3.minAbstract({"x'"}), storm::exceptions::InvalidArgumentException); |
|
|
|
ASSERT_NO_THROW(dd3.minAbstract({"x"})); |
|
|
|
EXPECT_EQ(0, dd3.getNonZeroCount()); |
|
|
|
EXPECT_EQ(0, dd3.getMax()); |
|
|
|
|
|
|
|
dd3 = dd1.equals(dd2); |
|
|
|
dd3 *= manager->getConstant(3); |
|
|
|
ASSERT_THROW(dd3.maxAbstract({"x'"}), storm::exceptions::InvalidArgumentException); |
|
|
|
ASSERT_NO_THROW(dd3.maxAbstract({"x"})); |
|
|
|
EXPECT_EQ(1, dd3.getNonZeroCount()); |
|
|
|
EXPECT_EQ(3, dd3.getMax()); |
|
|
|
} |
|
|
|
|
|
|
|
TEST(CuddDd, SwapTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
|
|
|
|
manager->addMetaVariablesInterleaved({"x", "x'"}, 1, 9); |
|
|
|
manager->addMetaVariable("z", 2, 8); |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd1; |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd2; |
|
|
|
|
|
|
|
dd1 = manager->getIdentity("x"); |
|
|
|
ASSERT_THROW(dd1.swapVariables({std::make_pair("x", "z")}), storm::exceptions::InvalidArgumentException); |
|
|
|
ASSERT_NO_THROW(dd1.swapVariables({std::make_pair("x", "x'")})); |
|
|
|
EXPECT_TRUE(dd1 == manager->getIdentity("x'")); |
|
|
|
} |
|
|
|
|
|
|
|
TEST(CuddDd, MultiplyMatrixTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
manager->addMetaVariablesInterleaved({"x", "x'"}, 1, 9); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd1 = manager->getIdentity("x").equals(manager->getIdentity("x'")); |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd2 = manager->getRange("x'"); |
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd3; |
|
|
|
dd1 *= manager->getConstant(2); |
|
|
|
|
|
|
|
ASSERT_NO_THROW(dd3 = dd1.multiplyMatrix(dd2, {"x'"})); |
|
|
|
ASSERT_NO_THROW(dd3.swapVariables({std::make_pair("x", "x'")})); |
|
|
|
EXPECT_TRUE(dd3 == dd2 * manager->getConstant(2)); |
|
|
|
} |
|
|
|
|
|
|
|
TEST(CuddDd, GetSetValueTest) { |
|
|
|
std::shared_ptr<storm::dd::DdManager<storm::dd::CUDD>> manager(new storm::dd::DdManager<storm::dd::CUDD>()); |
|
|
|
manager->addMetaVariable("x", 1, 9); |
|
|
|
|
|
|
|
storm::dd::Dd<storm::dd::CUDD> dd1 = manager->getOne(); |
|
|
|
ASSERT_NO_THROW(dd1.setValue("x", 4, 2)); |
|
|
|
EXPECT_EQ(2, dd1.getLeafCount()); |
|
|
|
dd1.exportToDot("dd1.dot"); |
|
|
|
|
|
|
|
std::map<std::string, int_fast64_t> metaVariableToValueMap; |
|
|
|
metaVariableToValueMap.emplace("x", 1); |
|
|
|
EXPECT_EQ(1, dd1.getValue(metaVariableToValueMap)); |
|
|
|
|
|
|
|
metaVariableToValueMap.clear(); |
|
|
|
metaVariableToValueMap.emplace("x", 4); |
|
|
|
EXPECT_EQ(2, dd1.getValue(metaVariableToValueMap)); |
|
|
|
} |