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.
69 lines
3.0 KiB
69 lines
3.0 KiB
#include "gtest/gtest.h"
|
|
#include "storm-config.h"
|
|
|
|
#include "src/parser/PrismParser.h"
|
|
#include "src/models/sparse/Dtmc.h"
|
|
#include "src/builder/ExplicitPrismModelBuilder.h"
|
|
#include "src/utility/graph.h"
|
|
#include "src/utility/shortestPaths.cpp"
|
|
|
|
// NOTE: These result values of these tests were generated by the
|
|
// KSP-Generator itself and checked for gross implausibility, but no
|
|
// more than that.
|
|
// An independent verification of the values would be really nice ...
|
|
|
|
TEST(KSPTest, dijkstra) {
|
|
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm");
|
|
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>().translateProgram(program);
|
|
|
|
storm::storage::sparse::state_type testState = 300;
|
|
storm::utility::ksp::ShortestPathsGenerator<double> spg(model, testState);
|
|
|
|
double dist = spg.computeKSP(1);
|
|
EXPECT_DOUBLE_EQ(0.015859334652581887, dist);
|
|
}
|
|
|
|
TEST(KSPTest, singleTarget) {
|
|
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm");
|
|
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>().translateProgram(program);
|
|
|
|
storm::storage::sparse::state_type testState = 300;
|
|
storm::utility::ksp::ShortestPathsGenerator<double> spg(model, testState);
|
|
|
|
double dist = spg.computeKSP(100);
|
|
EXPECT_DOUBLE_EQ(1.5231305000339649e-06, dist);
|
|
}
|
|
|
|
TEST(KSPTest, reentry) {
|
|
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm");
|
|
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>().translateProgram(program);
|
|
|
|
storm::storage::sparse::state_type testState = 300;
|
|
storm::utility::ksp::ShortestPathsGenerator<double> spg(model, testState);
|
|
|
|
double dist = spg.computeKSP(100);
|
|
EXPECT_DOUBLE_EQ(1.5231305000339649e-06, dist);
|
|
|
|
// get another distance to ensure re-entry is no problem
|
|
double dist2 = spg.computeKSP(500);
|
|
EXPECT_DOUBLE_EQ(3.0462610000679282e-08, dist2);
|
|
}
|
|
|
|
TEST(KSPTest, groupTarget) {
|
|
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm");
|
|
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>().translateProgram(program);
|
|
|
|
auto spg = storm::utility::ksp::ShortestPathsGenerator<double>(model, storm::utility::ksp::state_list_t{50, 90});
|
|
|
|
// this path should lead to 90
|
|
double dist1 = spg.computeKSP(8);
|
|
EXPECT_DOUBLE_EQ(7.3796982335999988e-06, dist1);
|
|
|
|
// this one to 50
|
|
double dist2 = spg.computeKSP(9);
|
|
EXPECT_DOUBLE_EQ(3.92e-06, dist2);
|
|
|
|
// this one to 90 again
|
|
double dist3 = spg.computeKSP(12);
|
|
EXPECT_DOUBLE_EQ(3.6160521344640002e-06, dist3);
|
|
}
|