|
@ -204,11 +204,21 @@ namespace storm { |
|
|
|
|
|
|
|
|
template <typename ModelType, typename GeometryValueType> |
|
|
template <typename ModelType, typename GeometryValueType> |
|
|
std::vector<std::vector<storm::expressions::Variable>> DeterministicSchedsLpChecker<ModelType, GeometryValueType>::createEcVariables(std::vector<storm::expressions::Expression> const& choiceVars) { |
|
|
std::vector<std::vector<storm::expressions::Variable>> DeterministicSchedsLpChecker<ModelType, GeometryValueType>::createEcVariables(std::vector<storm::expressions::Expression> const& choiceVars) { |
|
|
|
|
|
|
|
|
|
|
|
// Get the choices that do not induce a value (i.e. reward) for all objectives
|
|
|
|
|
|
storm::storage::BitVector choicesWithValueZero(model.getNumberOfChoices(), true); |
|
|
|
|
|
for (auto const& objHelper : objectiveHelper) { |
|
|
|
|
|
for (auto const& value : objHelper.getChoiceValueOffsets()) { |
|
|
|
|
|
STORM_LOG_ASSERT(!storm::utility::isZero(value.second), "Expected non-zero choice-value offset."); |
|
|
|
|
|
choicesWithValueZero.set(value.first, false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
storm::storage::MaximalEndComponentDecomposition<ValueType> mecs(model.getTransitionMatrix(), model.getBackwardTransitions(), storm::storage::BitVector(model.getNumberOfStates(), true), choicesWithValueZero); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto one = lpModel->getConstant(storm::utility::one<ValueType>()); |
|
|
auto one = lpModel->getConstant(storm::utility::one<ValueType>()); |
|
|
std::vector<std::vector<storm::expressions::Variable>> result(model.getNumberOfStates()); |
|
|
|
|
|
storm::storage::MaximalEndComponentDecomposition<ValueType> mecs(model); |
|
|
|
|
|
uint64_t ecCounter = 0; |
|
|
uint64_t ecCounter = 0; |
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::vector<storm::expressions::Variable>> result(model.getNumberOfStates()); |
|
|
for (auto const& mec : mecs) { |
|
|
for (auto const& mec : mecs) { |
|
|
// Create a submatrix for the current mec as well as a mapping to map back to the original states.
|
|
|
// Create a submatrix for the current mec as well as a mapping to map back to the original states.
|
|
|
storm::storage::BitVector mecStatesAsBitVector(model.getNumberOfStates(), false); |
|
|
storm::storage::BitVector mecStatesAsBitVector(model.getNumberOfStates(), false); |
|
@ -228,30 +238,6 @@ namespace storm { |
|
|
// Also assert that not every state takes an ec choice.
|
|
|
// Also assert that not every state takes an ec choice.
|
|
|
auto subEcs = getSubEndComponents(mecTransitions); |
|
|
auto subEcs = getSubEndComponents(mecTransitions); |
|
|
for (auto const& subEc : subEcs) { |
|
|
for (auto const& subEc : subEcs) { |
|
|
// get the choices of the current EC with some non-zero value (i.e. reward).
|
|
|
|
|
|
// std::cout << "sub ec choices of ec" << ecCounter << ": " << subEc.second << std::endl;
|
|
|
|
|
|
storm::storage::BitVector subEcChoicesWithValueZero = subEc.second; |
|
|
|
|
|
for (auto const& localSubEcChoiceIndex : subEc.second) { |
|
|
|
|
|
uint64_t subEcChoice = toGlobalChoiceIndexMapping[localSubEcChoiceIndex]; |
|
|
|
|
|
for (auto const& objHelper : objectiveHelper) { |
|
|
|
|
|
if (objHelper.getChoiceValueOffsets().count(subEcChoice) > 0) { |
|
|
|
|
|
STORM_LOG_ASSERT(!storm::utility::isZero(objHelper.getChoiceValueOffsets().at(subEcChoice)), "Expected non-zero choice-value offset."); |
|
|
|
|
|
subEcChoicesWithValueZero.set(localSubEcChoiceIndex, false); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check whether each state has at least one zero-valued choice
|
|
|
|
|
|
bool zeroValueSubEc = true; |
|
|
|
|
|
for (auto const& state : subEc.first) { |
|
|
|
|
|
if (subEcChoicesWithValueZero.getNextSetIndex(mecTransitions.getRowGroupIndices()[state]) >= mecTransitions.getRowGroupIndices()[state + 1]) { |
|
|
|
|
|
zeroValueSubEc = false; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (zeroValueSubEc) { |
|
|
|
|
|
// Create a variable that is one iff upon entering this subEC no more choice value is collected.
|
|
|
// Create a variable that is one iff upon entering this subEC no more choice value is collected.
|
|
|
auto ecVar = lpModel->addBoundedIntegerVariable("ec" + std::to_string(ecCounter++), storm::utility::zero<ValueType>(), storm::utility::one<ValueType>()); |
|
|
auto ecVar = lpModel->addBoundedIntegerVariable("ec" + std::to_string(ecCounter++), storm::utility::zero<ValueType>(), storm::utility::one<ValueType>()); |
|
|
// assign this variable to every state in the ec
|
|
|
// assign this variable to every state in the ec
|
|
@ -262,7 +248,7 @@ namespace storm { |
|
|
// Create the sum over all choice vars that induce zero choice value
|
|
|
// Create the sum over all choice vars that induce zero choice value
|
|
|
std::vector<storm::expressions::Expression> ecChoiceVars; |
|
|
std::vector<storm::expressions::Expression> ecChoiceVars; |
|
|
uint64_t numSubEcStatesWithMultipleChoices = subEc.first.getNumberOfSetBits(); |
|
|
uint64_t numSubEcStatesWithMultipleChoices = subEc.first.getNumberOfSetBits(); |
|
|
for (auto const& localSubEcChoiceIndex : subEcChoicesWithValueZero) { |
|
|
|
|
|
|
|
|
for (auto const& localSubEcChoiceIndex : subEc.second) { |
|
|
uint64_t subEcChoice = toGlobalChoiceIndexMapping[localSubEcChoiceIndex]; |
|
|
uint64_t subEcChoice = toGlobalChoiceIndexMapping[localSubEcChoiceIndex]; |
|
|
if (choiceVars[subEcChoice].isInitialized()) { |
|
|
if (choiceVars[subEcChoice].isInitialized()) { |
|
|
ecChoiceVars.push_back(choiceVars[subEcChoice]); |
|
|
ecChoiceVars.push_back(choiceVars[subEcChoice]); |
|
@ -284,8 +270,6 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
STORM_LOG_TRACE("Found " << ecCounter << " end components."); |
|
|
STORM_LOG_TRACE("Found " << ecCounter << " end components."); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|