Browse Source

get reward names (in order) provided by the simulator

tempestpy_adaptions
Sebastian Junges 3 years ago
parent
commit
af2e8a7d03
  1. 9
      src/storm/simulator/PrismProgramSimulator.cpp
  2. 5
      src/storm/simulator/PrismProgramSimulator.h
  3. 1
      src/test/storm/simulator/PrismProgramSimulator.cpp

9
src/storm/simulator/PrismProgramSimulator.cpp

@ -125,6 +125,15 @@ namespace storm {
return explore();
}
template<typename ValueType>
std::vector<std::string> DiscreteTimePrismProgramSimulator<ValueType>::getRewardNames() const {
std::vector<std::string> names;
for (uint64_t i = 0; i < stateGenerator->getNumberOfRewardModels(); ++i) {
names.push_back(stateGenerator->getRewardModelInformation(i).getName());
}
return names;
}
template<typename ValueType>
uint32_t DiscreteTimePrismProgramSimulator<ValueType>::getOrAddStateIndex(generator::CompressedState const& state) {
uint32_t newIndex = static_cast<uint32_t>(stateToId.size());

5
src/storm/simulator/PrismProgramSimulator.h

@ -75,6 +75,11 @@ namespace storm {
bool resetToState(generator::CompressedState const& compressedState);
bool resetToState(expressions::SimpleValuation const& valuationState);
/**
* The names of the rewards that are returned.
*/
std::vector<std::string> getRewardNames() const;
protected:
bool explore();
void clearStateCaches();

1
src/test/storm/simulator/PrismProgramSimulator.cpp

@ -10,6 +10,7 @@ TEST(PrismProgramSimulatorTest, KnuthYaoDieTest) {
options.setBuildAllRewardModels();
storm::simulator::DiscreteTimePrismProgramSimulator<double> sim(program, options);
EXPECT_EQ("coin_flips", sim.getRewardNames()[0]);
auto rew = sim.getLastRewards();
rew = sim.getLastRewards();
EXPECT_EQ(1ul, rew.size());

Loading…
Cancel
Save