Browse Source

fixing volatile k-shortest path test that returns different (yet correct) results on different machines/compilers because of double imprecisions

tempestpy_adaptions
dehnert 7 years ago
parent
commit
bb6fb04f72
  1. 23
      src/test/storm/utility/KSPTest.cpp

23
src/test/storm/utility/KSPTest.cpp

@ -80,23 +80,26 @@ TEST(KSPTest, kspStateSet) {
auto model = buildExampleModel();
storm::utility::ksp::ShortestPathsGenerator<double> spg(*model, testState);
storm::storage::BitVector referenceBV(model->getNumberOfStates(), false);
for (auto s : std::vector<storm::utility::ksp::state_t>{0, 1, 2, 4, 6, 9, 12, 17, 22, 30, 37, 45, 52, 58, 65, 70, 74, 77, 81, 85, 92, 98, 104, 112, 119, 127, 134, 140, 146, 154, 161, 169, 176, 182, 188, 196, 203, 211, 218, 224, 230, 238, 245, 253, 260, 266, 272, 281, 288, 296}) {
referenceBV.set(s, true);
}
auto bv = spg.getStates(7);
EXPECT_EQ(referenceBV, bv);
EXPECT_EQ(50, bv.getNumberOfSetBits());
// The result may sadly depend on the compiler/system, so checking a particular outcome is not feasible.
// storm::storage::BitVector referenceBV(model->getNumberOfStates(), false);
// for (auto s : std::vector<storm::utility::ksp::state_t>{0, 1, 2, 4, 6, 9, 12, 17, 22, 30, 37, 45, 52, 58, 65, 70, 74, 77, 81, 85, 92, 98, 104, 112, 119, 127, 134, 140, 146, 154, 161, 169, 176, 182, 188, 196, 203, 211, 218, 224, 230, 238, 245, 253, 260, 266, 272, 281, 288, 296}) {
// referenceBV.set(s, true);
// }
//
// EXPECT_EQ(referenceBV, bv);
}
TEST(KSPTest, kspPathAsList) {
auto model = buildExampleModel();
storm::utility::ksp::ShortestPathsGenerator<double> spg(*model, testState);
// TODO: use path that actually has a loop or something to make this more interesting
auto reference = storm::utility::ksp::OrderedStateList{296, 288, 281, 272, 266, 260, 253, 245, 238, 230, 224, 218, 211, 203, 196, 188, 182, 176, 169, 161, 154, 146, 140, 134, 127, 119, 112, 104, 98, 92, 85, 77, 70, 81, 74, 65, 58, 52, 45, 37, 30, 22, 17, 12, 9, 6, 4, 2, 1, 0};
auto list = spg.getPathAsList(7);
EXPECT_EQ(50, list.size());
EXPECT_EQ(reference, list);
// TODO: use path that actually has a loop or something to make this more interesting
// auto reference = storm::utility::ksp::OrderedStateList{296, 288, 281, 272, 266, 260, 253, 245, 238, 230, 224, 218, 211, 203, 196, 188, 182, 176, 169, 161, 154, 146, 140, 134, 127, 119, 112, 104, 98, 92, 85, 77, 70, 81, 74, 65, 58, 52, 45, 37, 30, 22, 17, 12, 9, 6, 4, 2, 1, 0};
// EXPECT_EQ(reference, list);
}
Loading…
Cancel
Save