Browse Source

more efficient comparison of epoch classes

tempestpy_adaptions
TimQu 7 years ago
parent
commit
27ee299f63
  1. 19
      src/storm/modelchecker/multiobjective/rewardbounded/MultiDimensionalRewardUnfolding.cpp
  2. 4
      src/storm/modelchecker/multiobjective/rewardbounded/MultiDimensionalRewardUnfolding.h

19
src/storm/modelchecker/multiobjective/rewardbounded/MultiDimensionalRewardUnfolding.cpp

@ -184,7 +184,7 @@ namespace storm {
template<typename ValueType, bool SingleObjectiveMode>
typename MultiDimensionalRewardUnfolding<ValueType, SingleObjectiveMode>::EpochModel& MultiDimensionalRewardUnfolding<ValueType, SingleObjectiveMode>::setCurrentEpoch(Epoch const& epoch) {
// Check if we need to update the current epoch class
if (!currentEpoch || getClassOfEpoch(epoch) != getClassOfEpoch(currentEpoch.get())) {
if (!currentEpoch || !sameEpochClass(epoch, currentEpoch.get())) {
setCurrentEpochClass(epoch);
}
@ -211,7 +211,7 @@ namespace storm {
swAux2.start();
SolutionType choiceSolution;
bool firstSuccessor = true;
if (getClassOfEpoch(epoch) == getClassOfEpoch(successorEpoch)) {
if (sameEpochClass(epoch, successorEpoch)) {
swAux3.start();
for (auto const& successor : memoryProduct.getProduct().getTransitionMatrix().getRow(productChoice)) {
if (firstSuccessor) {
@ -836,17 +836,14 @@ namespace storm {
}
template<typename ValueType, bool SingleObjectiveMode>
typename MultiDimensionalRewardUnfolding<ValueType, SingleObjectiveMode>::EpochClass MultiDimensionalRewardUnfolding<ValueType, SingleObjectiveMode>::getClassOfEpoch(Epoch const& epoch) const {
// Get a BitVector that is 1 wherever the epoch is non-negative
storm::storage::BitVector classAsBitVector(epoch.size(), false);
uint64_t i = 0;
for (auto const& e : epoch) {
if (e >= 0) {
classAsBitVector.set(i, true);
bool MultiDimensionalRewardUnfolding<ValueType, SingleObjectiveMode>::sameEpochClass(Epoch const& epoch1, Epoch const& epoch2) const {
assert(epoch1.size() == epoch2.size());
for (auto e1It = epoch1.begin(), e2It = epoch2.begin(); e1It != epoch1.end(); ++e1It, ++e2It) {
if ((*e1It) < 0 != (*e2It < 0)) {
return false;
}
++i;
}
return classAsBitVector.getAsInt(0, epoch.size());
return true;
}
template<typename ValueType, bool SingleObjectiveMode>

4
src/storm/modelchecker/multiobjective/rewardbounded/MultiDimensionalRewardUnfolding.h

@ -23,7 +23,6 @@ namespace storm {
public:
typedef std::vector<int64_t> Epoch; // The number of reward steps that are "left" for each dimension
typedef uint64_t EpochClass; // Collection of epochs that consider the same epoch model
typedef typename std::conditional<SingleObjectiveMode, ValueType, std::vector<ValueType>>::type SolutionType;
@ -132,8 +131,7 @@ namespace storm {
std::vector<storm::storage::BitVector> computeMemoryStateMap(storm::storage::MemoryStructure const& memory) const;
std::vector<std::vector<ValueType>> computeObjectiveRewardsForProduct(Epoch const& epoch) const;
EpochClass getClassOfEpoch(Epoch const& epoch) const;
bool sameEpochClass(Epoch const& epoch1, Epoch const& epoch2) const;
Epoch getSuccessorEpoch(Epoch const& epoch, Epoch const& step) const;

Loading…
Cancel
Save