Browse Source

infinite horizon helper now store information

about shielding tasks and whether to compute all choice values
tempestpy_adaptions
Stefan Pranger 3 years ago
parent
commit
e406b00c02
  1. 10
      src/storm/modelchecker/helper/SingleValueModelCheckerHelper.cpp
  2. 11
      src/storm/modelchecker/helper/SingleValueModelCheckerHelper.h
  3. 1
      src/storm/modelchecker/helper/infinitehorizon/SparseInfiniteHorizonHelper.h
  4. 18
      src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicInfiniteHorizonHelper.cpp
  5. 5
      src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicInfiniteHorizonHelper.h
  6. 3
      src/storm/modelchecker/helper/utility/SetInformationFromCheckTask.h
  7. 12
      src/storm/modelchecker/rpatl/helper/internal/GameViHelper.cpp
  8. 11
      src/storm/modelchecker/rpatl/helper/internal/GameViHelper.h

10
src/storm/modelchecker/helper/SingleValueModelCheckerHelper.cpp

@ -83,6 +83,16 @@ namespace storm {
return _produceScheduler;
}
template <typename ValueType, storm::models::ModelRepresentation ModelRepresentation>
void SingleValueModelCheckerHelper<ValueType, ModelRepresentation>::setProduceChoiceValues(bool value) {
_produceChoiceValues = value;
}
template <typename ValueType, storm::models::ModelRepresentation ModelRepresentation>
bool SingleValueModelCheckerHelper<ValueType, ModelRepresentation>::isProduceChoiceValuesSet() const {
return _produceChoiceValues;
}
template <typename ValueType, storm::models::ModelRepresentation ModelRepresentation>
void SingleValueModelCheckerHelper<ValueType, ModelRepresentation>::setQualitative(bool value) {
_isQualitativeSet = value;

11
src/storm/modelchecker/helper/SingleValueModelCheckerHelper.h

@ -101,6 +101,16 @@ namespace storm {
*/
bool isProduceSchedulerSet() const;
/*!
* Sets whether all choice values shall be computed
*/
void setProduceChoiceValues(bool value);
/*!
* @return whether all choice values shall be computed
*/
bool isProduceChoiceValuesSet() const;
/*!
* Sets whether the property needs to be checked qualitatively
*/
@ -115,6 +125,7 @@ namespace storm {
boost::optional<storm::solver::OptimizationDirection> _optimizationDirection;
boost::optional<std::pair<storm::logic::ComparisonType, ValueType>> _valueThreshold;
bool _produceScheduler;
bool _produceChoiceValues;
bool _isQualitativeSet;
};
}

1
src/storm/modelchecker/helper/infinitehorizon/SparseInfiniteHorizonHelper.h

@ -132,6 +132,7 @@ namespace storm {
std::unique_ptr<storm::storage::Decomposition<LongRunComponentType>> _computedLongRunComponentDecomposition;
boost::optional<std::vector<uint64_t>> _producedOptimalChoices;
boost::optional<std::vector<ValueType>> _choiceValues;
};

18
src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicInfiniteHorizonHelper.cpp

@ -57,6 +57,13 @@ namespace storm {
return scheduler;
}
template <typename ValueType>
std::vector<ValueType> SparseNondeterministicInfiniteHorizonHelper<ValueType>::getChoiceValues() const {
STORM_LOG_ASSERT(this->isProduceChoiceValuesSet(), "Trying to get the computed choice values although this was not requested.");
STORM_LOG_ASSERT(this->_choiceValues.is_initialized(), "Trying to get the computed choice values but none were available. Was there a computation call before?");
return this->_choiceValues.get();
}
template <typename ValueType>
void SparseNondeterministicInfiniteHorizonHelper<ValueType>::createDecomposition() {
if (this->_longRunComponentDecomposition == nullptr) {
@ -81,6 +88,13 @@ namespace storm {
}
this->_producedOptimalChoices->resize(this->_transitionMatrix.getRowGroupCount());
}
// Allocate memory for the choice values.
if (this->isProduceSchedulerSet()) {
if (!this->_choiceValues.is_initialized()) {
this->_choiceValues.emplace();
}
this->_choiceValues->resize(this->_transitionMatrix.getRowCount());
}
auto trivialResult = this->computeLraForTrivialMec(env, stateRewardsGetter, actionRewardsGetter, component);
if (trivialResult.first) {
@ -156,6 +170,10 @@ namespace storm {
if (this->isProduceSchedulerSet()) {
optimalChoices = &this->_producedOptimalChoices.get();
}
std::vector<ValueType>* choiceValues = nullptr;
if (this->isProduceChoiceValuesSet()) {
choiceValues = &this->_choiceValues.get();
}
// Now create a helper and perform the algorithm
if (this->isContinuousTime()) {

5
src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicInfiniteHorizonHelper.h

@ -52,6 +52,11 @@ namespace storm {
*/
storm::storage::Scheduler<ValueType> extractScheduler() const;
/*!
* @return the computed choice values for the states.
*/
std::vector<ValueType> getChoiceValues() const;
/*!
* @param stateValuesGetter a function returning a value for a given state index
* @param actionValuesGetter a function returning a value for a given (global) choice index

3
src/storm/modelchecker/helper/utility/SetInformationFromCheckTask.h

@ -26,6 +26,9 @@ namespace storm {
// Scheduler Production
helper.setProduceScheduler(checkTask.isProduceSchedulersSet());
// Shield Synthesis
helper.setProduceChoiceValues(checkTask.isShieldingTask());
// Qualitative flag
helper.setQualitative(checkTask.isQualitativeSet());
}

12
src/storm/modelchecker/rpatl/helper/internal/GameViHelper.cpp

@ -50,7 +50,7 @@ namespace storm {
_multiplier->multiply(env, xNew(), &_b, constrainedChoiceValues);
auto rowGroupIndices = this->_transitionMatrix.getRowGroupIndices();
rowGroupIndices.erase(rowGroupIndices.begin());
_multiplier->reduce(env, dir, constrainedChoiceValues, rowGroupIndices, xNew());
_multiplier->reduce(env, dir, rowGroupIndices, constrainedChoiceValues, xNew(), nullptr, &_statesOfCoalition);
break;
}
performIterationStep(env, dir);
@ -125,6 +125,16 @@ namespace storm {
return _produceScheduler;
}
template <typename ValueType>
void GameViHelper<ValueType>::setShieldingTask(bool value) {
_shieldingTask = value;
}
template <typename ValueType>
bool GameViHelper<ValueType>::isShieldingTask() const {
return _shieldingTask;
}
template <typename ValueType>
void GameViHelper<ValueType>::updateTransitionMatrix(storm::storage::SparseMatrix<ValueType> newTransitionMatrix) {
_transitionMatrix = newTransitionMatrix;

11
src/storm/modelchecker/rpatl/helper/internal/GameViHelper.h

@ -38,6 +38,16 @@ namespace storm {
*/
bool isProduceSchedulerSet() const;
/*!
* Sets whether an optimal scheduler shall be constructed during the computation
*/
void setShieldingTask(bool value);
/*!
* @return whether an optimal scheduler shall be constructed during the computation
*/
bool isShieldingTask() const;
/*!
* Changes the transitionMatrix to the given one.
*/
@ -93,6 +103,7 @@ namespace storm {
std::unique_ptr<storm::solver::Multiplier<ValueType>> _multiplier;
bool _produceScheduler = false;
bool _shieldingTask = false;
boost::optional<std::vector<uint64_t>> _producedOptimalChoices;
};
}

Loading…
Cancel
Save