Browse Source
Merge pull request 'Refactoring Shields Choices and Scheduler' (#48) from shield_refactoring into main
Merge pull request 'Refactoring Shields Choices and Scheduler' (#48) from shield_refactoring into main
Reviewed-on: https://git.pranger.xyz/TEMPEST/tempest-devel/pulls/48main
54 changed files with 812 additions and 363 deletions
-
8resources/examples/testfiles/shields/mdp-shields/dieSelectionPostSafetylambda07Pmin.shield
-
2resources/examples/testfiles/shields/mdp-shields/dieSelectionPreSafetygamma08Pmin.shield
-
7resources/examples/testfiles/shields/mdp-shields/dieSelectionPreSafetylambda08Pmin.shield
-
3resources/examples/testfiles/shields/smg-shields/rightDecisionPostSafetyGamma05PminF5.shield
-
6resources/examples/testfiles/shields/smg-shields/rightDecisionPostSafetyGamma09PminF3.shield
-
9resources/examples/testfiles/shields/smg-shields/rightDecisionPostSafetyLambda05PminF5.shield
-
9resources/examples/testfiles/shields/smg-shields/rightDecisionPostSafetyLambda09PminF3.shield
-
3resources/examples/testfiles/shields/smg-shields/rightDecisionPreSafetyGamma05PminF5.shield
-
6resources/examples/testfiles/shields/smg-shields/rightDecisionPreSafetyGamma09PminF3.shield
-
9resources/examples/testfiles/shields/smg-shields/rightDecisionPreSafetyLambda05PminF5.shield
-
9resources/examples/testfiles/shields/smg-shields/rightDecisionPreSafetyLambda09PminF3.shield
-
2src/storm-cli-utilities/model-handling.h
-
16src/storm-parsers/parser/FormulaParserGrammar.cpp
-
2src/storm-parsers/parser/FormulaParserGrammar.h
-
22src/storm/logic/ShieldExpression.cpp
-
9src/storm/logic/ShieldExpression.h
-
10src/storm/modelchecker/helper/SingleValueModelCheckerHelper.cpp
-
11src/storm/modelchecker/helper/SingleValueModelCheckerHelper.h
-
1src/storm/modelchecker/helper/infinitehorizon/SparseInfiniteHorizonHelper.h
-
21src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicGameInfiniteHorizonHelper.cpp
-
5src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicGameInfiniteHorizonHelper.h
-
20src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicInfiniteHorizonHelper.cpp
-
5src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicInfiniteHorizonHelper.h
-
56src/storm/modelchecker/helper/infinitehorizon/internal/LraViHelper.cpp
-
6src/storm/modelchecker/helper/infinitehorizon/internal/LraViHelper.h
-
3src/storm/modelchecker/helper/utility/SetInformationFromCheckTask.h
-
5src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp
-
2src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp
-
12src/storm/modelchecker/rpatl/SparseSmgRpatlModelChecker.cpp
-
2src/storm/modelchecker/rpatl/helper/SparseSmgRpatlHelper.cpp
-
12src/storm/modelchecker/rpatl/helper/internal/GameViHelper.cpp
-
11src/storm/modelchecker/rpatl/helper/internal/GameViHelper.h
-
8src/storm/shields/AbstractShield.h
-
54src/storm/shields/OptimalShield.cpp
-
10src/storm/shields/OptimalShield.h
-
39src/storm/shields/PostShield.cpp
-
4src/storm/shields/PostShield.h
-
38src/storm/shields/PreShield.cpp
-
4src/storm/shields/PreShield.h
-
19src/storm/shields/ShieldHandling.cpp
-
6src/storm/shields/ShieldHandling.h
-
29src/storm/solver/Multiplier.cpp
-
2src/storm/solver/Multiplier.h
-
60src/storm/storage/PostScheduler.cpp
-
22src/storm/storage/PostScheduler.h
-
63src/storm/storage/PostSchedulerChoice.cpp
-
46src/storm/storage/PostSchedulerChoice.h
-
43src/storm/storage/PreScheduler.cpp
-
28src/storm/storage/PreScheduler.h
-
56src/storm/storage/PreSchedulerChoice.cpp
-
42src/storm/storage/PreSchedulerChoice.h
-
16src/test/storm/modelchecker/rpatl/smg/ShieldGenerationSmgRpatlModelCheckerTest.cpp
-
3src/test/storm/parser/GameShieldingParserTest.cpp
-
3src/test/storm/parser/MdpShieldingParserTest.cpp
@ -1,8 +1,8 @@ |
|||
___________________________________________________________________ |
|||
Post-Safety-Shield with relative comparison (lambda = 0.700000): |
|||
model state: correction [<action>: (<corrected action>)}: |
|||
0 0: 2; 1: 2; 2: 2 |
|||
1 0: 0; 1: 0; 2: 0 |
|||
3 0: 2; 1: 2; 2: 2 |
|||
4 0: 2; 1: 2; 2: 2 |
|||
0 0: 0; 1: 1; 2: 2 |
|||
1 0: 0; 1: 1; 2: 2 |
|||
3 0: 0; 1: 1; 2: 2 |
|||
4 0: 0; 1: 1; 2: 2 |
|||
___________________________________________________________________ |
@ -1,4 +1,11 @@ |
|||
___________________________________________________________________ |
|||
Pre-Safety-Shield with relative comparison (lambda = 0.800000): |
|||
model state: choice(s) [<value>: (<action>)}: |
|||
0 0.58: (0); 0.566: (1); 0.552: (2) |
|||
1 0.8285: (0); 0.7942: (1); 0.7599: (2) |
|||
2 0.8775: (0); 0.902: (1); 0.9265: (2) |
|||
3 0.755: (0); 0.706: (1); 0.657: (2) |
|||
4 1: (0); 1: (1); 1: (2) |
|||
5 1: (0); 1: (1); 1: (2) |
|||
6 0.825: (0); 0.79: (1); 0.755: (2) |
|||
___________________________________________________________________ |
@ -1,6 +1,5 @@ |
|||
___________________________________________________________________ |
|||
Post-Safety-Shield with absolute comparison (gamma = 0.500000): |
|||
model state: correction [<action>: (<corrected action>)}: |
|||
4 0: 0 |
|||
5 0: 0 |
|||
7 0: 0 |
|||
___________________________________________________________________ |
@ -1,6 +1,8 @@ |
|||
___________________________________________________________________ |
|||
Post-Safety-Shield with absolute comparison (gamma = 0.900000): |
|||
model state: correction [<action>: (<corrected action>)}: |
|||
4 0: 0 |
|||
5 0: 0 |
|||
1 0: 0; 1: 0 |
|||
2 0: 0 |
|||
7 0: 0 |
|||
10 0: 0 |
|||
___________________________________________________________________ |
@ -1,8 +1,9 @@ |
|||
___________________________________________________________________ |
|||
Post-Safety-Shield with relative comparison (lambda = 0.500000): |
|||
model state: correction [<action>: (<corrected action>)}: |
|||
0 0: 0; 1: 1 |
|||
4 0: 0 |
|||
5 0: 0 |
|||
9 0: 0; 1: 1 |
|||
1 0: 0; 1: 1 |
|||
2 0: 0 |
|||
7 0: 0 |
|||
8 0: 0 |
|||
10 0: 0 |
|||
___________________________________________________________________ |
@ -1,8 +1,9 @@ |
|||
___________________________________________________________________ |
|||
Post-Safety-Shield with relative comparison (lambda = 0.900000): |
|||
model state: correction [<action>: (<corrected action>)}: |
|||
0 0: 0; 1: 1 |
|||
4 0: 0 |
|||
5 0: 0 |
|||
9 0: 0; 1: 1 |
|||
1 0: 0; 1: 1 |
|||
2 0: 0 |
|||
7 0: 0 |
|||
8 0: 0 |
|||
10 0: 0 |
|||
___________________________________________________________________ |
@ -1,6 +1,5 @@ |
|||
___________________________________________________________________ |
|||
Pre-Safety-Shield with absolute comparison (gamma = 0.500000): |
|||
model state: choice(s) [<value>: (<action>)}: |
|||
4 0: (0) |
|||
5 0: (0) |
|||
7 0: (0) |
|||
___________________________________________________________________ |
@ -1,6 +1,8 @@ |
|||
___________________________________________________________________ |
|||
Pre-Safety-Shield with absolute comparison (gamma = 0.900000): |
|||
model state: choice(s) [<value>: (<action>)}: |
|||
4 0: (0) |
|||
5 0: (0) |
|||
1 0.9: (0) |
|||
2 0: (0) |
|||
7 0: (0) |
|||
10 0.9: (0) |
|||
___________________________________________________________________ |
@ -1,8 +1,9 @@ |
|||
___________________________________________________________________ |
|||
Pre-Safety-Shield with relative comparison (lambda = 0.500000): |
|||
model state: choice(s) [<value>: (<action>)}: |
|||
0 0: (1) |
|||
4 0: (0) |
|||
5 0: (0) |
|||
9 0: (1) |
|||
1 0.9: (0); 1: (1) |
|||
2 1: (0) |
|||
7 0: (0) |
|||
8 1: (0) |
|||
10 0.9: (0) |
|||
___________________________________________________________________ |
@ -1,8 +1,9 @@ |
|||
___________________________________________________________________ |
|||
Pre-Safety-Shield with relative comparison (lambda = 0.900000): |
|||
model state: choice(s) [<value>: (<action>)}: |
|||
0 0: (1) |
|||
4 0: (0) |
|||
5 0: (0) |
|||
9 0: (1) |
|||
1 0.9: (0); 1: (1) |
|||
2 0: (0) |
|||
7 0: (0) |
|||
8 1: (0) |
|||
10 0.9: (0) |
|||
___________________________________________________________________ |
@ -0,0 +1,63 @@ |
|||
#include "storm/storage/PostSchedulerChoice.h"
|
|||
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
#include "storm/exceptions/InvalidOperationException.h"
|
|||
#include "storm/adapters/RationalFunctionAdapter.h"
|
|||
#include "storm/adapters/RationalNumberAdapter.h"
|
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <typename ValueType> |
|||
PostSchedulerChoice<ValueType>::PostSchedulerChoice() { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template <typename ValueType> |
|||
void PostSchedulerChoice<ValueType>::addChoice(uint_fast64_t oldChoiceIndex, uint_fast64_t newChoiceIndex) { |
|||
choiceMap.emplace_back(oldChoiceIndex, newChoiceIndex); |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
std::vector<std::tuple<uint_fast64_t, uint_fast64_t>> const& PostSchedulerChoice<ValueType>::getChoiceMap() const { |
|||
return choiceMap; |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
std::tuple<uint_fast64_t, uint_fast64_t> const& PostSchedulerChoice<ValueType>::getChoice(uint_fast64_t choiceIndex) const { |
|||
return choiceMap.at(choiceIndex); |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
bool PostSchedulerChoice<ValueType>::isEmpty() const { |
|||
return choiceMap.size() == 0; |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
std::ostream& operator<<(std::ostream& out, PostSchedulerChoice<ValueType> const& schedulerChoice) { |
|||
if (!schedulerChoice.isEmpty()) { |
|||
bool firstChoice = true; |
|||
for(auto const& choice : schedulerChoice.getChoiceMap()) { |
|||
if(firstChoice) firstChoice = false; |
|||
else out << ", "; |
|||
out << std::get<0>(choice) << " -> " << std::get<1>(choice); |
|||
} |
|||
} else { |
|||
out << "undefined"; |
|||
} |
|||
return out; |
|||
} |
|||
|
|||
template class PostSchedulerChoice<double>; |
|||
template std::ostream& operator<<(std::ostream& out, PostSchedulerChoice<double> const& schedulerChoice); |
|||
template class PostSchedulerChoice<float>; |
|||
template std::ostream& operator<<(std::ostream& out, PostSchedulerChoice<float> const& schedulerChoice); |
|||
template class PostSchedulerChoice<storm::RationalNumber>; |
|||
template std::ostream& operator<<(std::ostream& out, PostSchedulerChoice<storm::RationalNumber> const& schedulerChoice); |
|||
template class PostSchedulerChoice<storm::RationalFunction>; |
|||
template std::ostream& operator<<(std::ostream& out, PostSchedulerChoice<storm::RationalFunction> const& schedulerChoice); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/utility/constants.h" |
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <typename ValueType> |
|||
class PostSchedulerChoice { |
|||
|
|||
public: |
|||
|
|||
/*! |
|||
* Creates an undefined scheduler choice |
|||
*/ |
|||
PostSchedulerChoice(); |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
void addChoice(uint_fast64_t oldChoiceIndex, uint_fast64_t newChoiceIndex); |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
bool isEmpty() const; |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
std::vector<std::tuple<uint_fast64_t, uint_fast64_t>> const& getChoiceMap() const; |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
std::tuple<uint_fast64_t, uint_fast64_t> const& getChoice(uint_fast64_t choiceIndex) const; |
|||
|
|||
private: |
|||
//std::vector<std::tuple<uint_fast64_t, storm::storage::Distribution<ValueType, uint_fast64_t>>> choiceMap; |
|||
std::vector<std::tuple<uint_fast64_t, uint_fast64_t>> choiceMap; |
|||
}; |
|||
|
|||
template<typename ValueType> |
|||
std::ostream& operator<<(std::ostream& out, PostSchedulerChoice<ValueType> const& schedulerChoice); |
|||
} |
|||
} |
@ -0,0 +1,56 @@ |
|||
#include "storm/storage/PreSchedulerChoice.h"
|
|||
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
#include "storm/exceptions/InvalidOperationException.h"
|
|||
#include "storm/adapters/RationalFunctionAdapter.h"
|
|||
#include "storm/adapters/RationalNumberAdapter.h"
|
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <typename ValueType> |
|||
PreSchedulerChoice<ValueType>::PreSchedulerChoice() { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template <typename ValueType> |
|||
void PreSchedulerChoice<ValueType>::addChoice(uint_fast64_t choiceIndex, ValueType probToSatisfy) { |
|||
choiceMap.emplace_back(probToSatisfy, choiceIndex); |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
std::vector<std::tuple<ValueType, uint_fast64_t>> const& PreSchedulerChoice<ValueType>::getChoiceMap() const { |
|||
return choiceMap; |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
bool PreSchedulerChoice<ValueType>::isEmpty() const { |
|||
return choiceMap.size() == 0; |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
std::ostream& operator<<(std::ostream& out, PreSchedulerChoice<ValueType> const& schedulerChoice) { |
|||
out << schedulerChoice.getChoiceMap().size(); |
|||
if (!schedulerChoice.isEmpty()) { |
|||
for(auto const& choice : schedulerChoice.getChoiceMap()) { |
|||
out << std::get<0>(choice) << ": " << std::get<1>(choice); |
|||
} |
|||
} else { |
|||
out << "undefined"; |
|||
} |
|||
return out; |
|||
} |
|||
|
|||
template class PreSchedulerChoice<double>; |
|||
template std::ostream& operator<<(std::ostream& out, PreSchedulerChoice<double> const& schedulerChoice); |
|||
template class PreSchedulerChoice<float>; |
|||
template std::ostream& operator<<(std::ostream& out, PreSchedulerChoice<float> const& schedulerChoice); |
|||
template class PreSchedulerChoice<storm::RationalNumber>; |
|||
template std::ostream& operator<<(std::ostream& out, PreSchedulerChoice<storm::RationalNumber> const& schedulerChoice); |
|||
template class PreSchedulerChoice<storm::RationalFunction>; |
|||
template std::ostream& operator<<(std::ostream& out, PreSchedulerChoice<storm::RationalFunction> const& schedulerChoice); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/utility/constants.h" |
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
template <typename ValueType> |
|||
class PreSchedulerChoice { |
|||
|
|||
public: |
|||
|
|||
/*! |
|||
* Creates an undefined scheduler choice |
|||
*/ |
|||
PreSchedulerChoice(); |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
void addChoice(uint_fast64_t choiceIndex, ValueType probToSatisfy); |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
bool isEmpty() const; |
|||
|
|||
/* |
|||
* |
|||
*/ |
|||
std::vector<std::tuple<ValueType, uint_fast64_t>> const& getChoiceMap() const; |
|||
|
|||
private: |
|||
// For now we only consider shields with deterministic choices. |
|||
//std::map<ValueType, storm::storage::Distribution<ValueType, uint_fast64_t>> choiceMap; |
|||
std::vector<std::tuple<ValueType, uint_fast64_t>> choiceMap; |
|||
}; |
|||
|
|||
template<typename ValueType> |
|||
std::ostream& operator<<(std::ostream& out, PreSchedulerChoice<ValueType> const& schedulerChoice); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue