Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BeliefSupportTrackingTest.cpp
Go to the documentation of this file.
1#include "storm-config.h"
8#include "storm/api/storm.h"
11#include "test/storm_gtest.h"
12
13// TODO
14// These tests depend on the interpretation of action and observation numbers and those may change.
15// A more robust test would take the high-level actions and observations and track on those.
16
17TEST(BeliefSupportTracking, Maze) {
18#ifndef STORM_HAVE_Z3
19 GTEST_SKIP() << "Z3 not available.";
20#endif
21 storm::prism::Program program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/pomdp/maze2.prism");
22 program = storm::utility::prism::preprocess(program, "sl=0.4");
23 std::shared_ptr<storm::logic::Formula const> formula = storm::api::parsePropertiesForPrismProgram("Pmax=? [F \"goal\" ]", program).front().getRawFormula();
24 std::shared_ptr<storm::models::sparse::Pomdp<double>> pomdp =
25 storm::api::buildSparseModel<double>(program, {formula})->as<storm::models::sparse::Pomdp<double>>();
27 pomdp = makeCanonic.transform();
28
30 EXPECT_EQ(pomdp->getInitialStates(), tracker.getCurrentBeliefSupport());
31 tracker.track(0, 0);
32 auto beliefsup = tracker.getCurrentBeliefSupport();
33 EXPECT_EQ(6ul, beliefsup.getNumberOfSetBits());
34 tracker.track(0, 0);
35 EXPECT_EQ(beliefsup, tracker.getCurrentBeliefSupport());
36 tracker.track(0, 1);
37 EXPECT_TRUE(tracker.getCurrentBeliefSupport().empty());
38 tracker.reset();
39 EXPECT_EQ(pomdp->getInitialStates(), tracker.getCurrentBeliefSupport());
40 tracker.track(0, 0);
41 EXPECT_EQ(beliefsup, tracker.getCurrentBeliefSupport());
42 tracker.track(1, 0);
43 EXPECT_EQ(beliefsup, tracker.getCurrentBeliefSupport());
44 tracker.track(2, 1);
45 EXPECT_EQ(1ul, tracker.getCurrentBeliefSupport().getNumberOfSetBits());
46 tracker.track(3, 0);
47 EXPECT_EQ(1ul, tracker.getCurrentBeliefSupport().getNumberOfSetBits());
48 tracker.track(3, 0);
49 EXPECT_EQ(2ul, tracker.getCurrentBeliefSupport().getNumberOfSetBits());
50}
TEST(BeliefSupportTracking, Maze)
storm::storage::BitVector const & getCurrentBeliefSupport() const
The current belief support according to the tracker.
void track(uint64_t action, uint64_t observation)
Update current belief support state.
This class represents a partially observable Markov decision process.
Definition Pomdp.h:15
static storm::prism::Program parse(std::string const &filename, bool prismCompatability=false)
Parses the given file into the PRISM storage classes assuming it complies with the PRISM syntax.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint_fast64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
std::shared_ptr< storm::models::sparse::Pomdp< ValueType > > transform() const
std::vector< storm::jani::Property > parsePropertiesForPrismProgram(std::string const &inputString, storm::prism::Program const &program, boost::optional< std::set< std::string > > const &propertyFilter)
storm::prism::Program preprocess(storm::prism::Program const &program, std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions)
Definition prism.cpp:19