|
|
@ -32,12 +32,9 @@ namespace storm { |
|
|
|
template <storm::dd::DdType Type, typename ValueType> |
|
|
|
class DdPrismModelBuilder<Type, ValueType>::GenerationInformation { |
|
|
|
public: |
|
|
|
GenerationInformation(storm::prism::Program const& program) : program(program), manager(std::make_shared<storm::dd::DdManager<Type>>()), rowMetaVariables(), variableToRowMetaVariableMap(std::make_shared<std::map<storm::expressions::Variable, storm::expressions::Variable>>()), rowExpressionAdapter(std::make_shared<storm::adapters::AddExpressionAdapter<Type>>(manager, variableToRowMetaVariableMap)), columnMetaVariables(), variableToColumnMetaVariableMap((std::make_shared<std::map<storm::expressions::Variable, storm::expressions::Variable>>())), columnExpressionAdapter(std::make_shared<storm::adapters::AddExpressionAdapter<Type>>(manager, variableToColumnMetaVariableMap)), rowColumnMetaVariablePairs(), nondeterminismMetaVariables(), variableToIdentityMap(), allGlobalVariables(), moduleToIdentityMap() { |
|
|
|
GenerationInformation(storm::prism::Program const& program) : program(program), manager(std::make_shared<storm::dd::DdManager<Type>>()), rowMetaVariables(), variableToRowMetaVariableMap(std::make_shared<std::map<storm::expressions::Variable, storm::expressions::Variable>>()), rowExpressionAdapter(std::make_shared<storm::adapters::AddExpressionAdapter<Type, ValueType>>(manager, variableToRowMetaVariableMap)), columnMetaVariables(), variableToColumnMetaVariableMap((std::make_shared<std::map<storm::expressions::Variable, storm::expressions::Variable>>())), columnExpressionAdapter(std::make_shared<storm::adapters::AddExpressionAdapter<Type, ValueType>>(manager, variableToColumnMetaVariableMap)), rowColumnMetaVariablePairs(), nondeterminismMetaVariables(), variableToIdentityMap(), allGlobalVariables(), moduleToIdentityMap() { |
|
|
|
// Initializes variables and identity DDs.
|
|
|
|
createMetaVariablesAndIdentities(); |
|
|
|
|
|
|
|
rowExpressionAdapter = std::shared_ptr<storm::adapters::AddExpressionAdapter<Type>>(new storm::adapters::AddExpressionAdapter<Type>(manager, variableToRowMetaVariableMap)); |
|
|
|
columnExpressionAdapter = std::shared_ptr<storm::adapters::AddExpressionAdapter<Type>>(new storm::adapters::AddExpressionAdapter<Type>(manager, variableToColumnMetaVariableMap)); |
|
|
|
} |
|
|
|
|
|
|
|
// The program that is currently translated.
|
|
|
@ -49,12 +46,12 @@ namespace storm { |
|
|
|
// The meta variables for the row encoding.
|
|
|
|
std::set<storm::expressions::Variable> rowMetaVariables; |
|
|
|
std::shared_ptr<std::map<storm::expressions::Variable, storm::expressions::Variable>> variableToRowMetaVariableMap; |
|
|
|
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type>> rowExpressionAdapter; |
|
|
|
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> rowExpressionAdapter; |
|
|
|
|
|
|
|
// The meta variables for the column encoding.
|
|
|
|
std::set<storm::expressions::Variable> columnMetaVariables; |
|
|
|
std::shared_ptr<std::map<storm::expressions::Variable, storm::expressions::Variable>> variableToColumnMetaVariableMap; |
|
|
|
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type>> columnExpressionAdapter; |
|
|
|
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type, ValueType>> columnExpressionAdapter; |
|
|
|
|
|
|
|
// All pairs of row/column meta variables.
|
|
|
|
std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> rowColumnMetaVariablePairs; |
|
|
@ -794,7 +791,7 @@ namespace storm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
result.setValue(metaVariableNameToValueMap, 1); |
|
|
|
result.setValue(metaVariableNameToValueMap, ValueType(1)); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -835,7 +832,7 @@ namespace storm { |
|
|
|
|
|
|
|
for (uint_fast64_t currentChoices = 1; currentChoices <= maxChoices; ++currentChoices) { |
|
|
|
// Determine the set of states with exactly currentChoices choices.
|
|
|
|
equalsNumberOfChoicesDd = sumOfGuards.equals(generationInfo.manager->getConstant(static_cast<double>(currentChoices))); |
|
|
|
equalsNumberOfChoicesDd = sumOfGuards.equals(generationInfo.manager->getConstant(ValueType(currentChoices))); |
|
|
|
|
|
|
|
// If there is no such state, continue with the next possible number of choices.
|
|
|
|
if (equalsNumberOfChoicesDd.isZero()) { |
|
|
@ -1110,7 +1107,7 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
template <storm::dd::DdType Type, typename ValueType> |
|
|
|
storm::models::symbolic::StandardRewardModel<Type, double> DdPrismModelBuilder<Type, ValueType>::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& transitionMatrix, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& stateActionDd) { |
|
|
|
storm::models::symbolic::StandardRewardModel<Type, ValueType> DdPrismModelBuilder<Type, ValueType>::createRewardModelDecisionDiagrams(GenerationInformation& generationInfo, storm::prism::RewardModel const& rewardModel, ModuleDecisionDiagram const& globalModule, storm::dd::Add<Type, ValueType> const& transitionMatrix, storm::dd::Add<Type, ValueType> const& reachableStatesAdd, storm::dd::Add<Type, ValueType> const& stateActionDd) { |
|
|
|
|
|
|
|
// Start by creating the state reward vector.
|
|
|
|
boost::optional<storm::dd::Add<Type, ValueType>> stateRewards; |
|
|
@ -1222,7 +1219,7 @@ namespace storm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return storm::models::symbolic::StandardRewardModel<Type, double>(stateRewards, stateActionRewards, transitionRewards); |
|
|
|
return storm::models::symbolic::StandardRewardModel<Type, ValueType>(stateRewards, stateActionRewards, transitionRewards); |
|
|
|
} |
|
|
|
|
|
|
|
template <storm::dd::DdType Type, typename ValueType> |
|
|
@ -1394,7 +1391,7 @@ namespace storm { |
|
|
|
selectedRewardModels.push_back(preparedProgram->getRewardModel(0)); |
|
|
|
} |
|
|
|
|
|
|
|
std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, double>> rewardModels; |
|
|
|
std::unordered_map<std::string, storm::models::symbolic::StandardRewardModel<Type, ValueType>> rewardModels; |
|
|
|
for (auto const& rewardModel : selectedRewardModels) { |
|
|
|
rewardModels.emplace(rewardModel.get().getName(), createRewardModelDecisionDiagrams(generationInfo, rewardModel.get(), globalModule, transitionMatrix, reachableStatesAdd, stateActionDd)); |
|
|
|
} |
|
|
@ -1406,11 +1403,11 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
if (program.getModelType() == storm::prism::Program::ModelType::DTMC) { |
|
|
|
return std::shared_ptr<storm::models::symbolic::Model<Type>>(new storm::models::symbolic::Dtmc<Type>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); |
|
|
|
return std::shared_ptr<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Dtmc<Type, ValueType>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); |
|
|
|
} else if (program.getModelType() == storm::prism::Program::ModelType::CTMC) { |
|
|
|
return std::shared_ptr<storm::models::symbolic::Model<Type>>(new storm::models::symbolic::Ctmc<Type>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); |
|
|
|
return std::shared_ptr<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Ctmc<Type, ValueType>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, labelToExpressionMapping, rewardModels)); |
|
|
|
} else if (program.getModelType() == storm::prism::Program::ModelType::MDP) { |
|
|
|
return std::shared_ptr<storm::models::symbolic::Model<Type>>(new storm::models::symbolic::Mdp<Type>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, generationInfo.allNondeterminismVariables, labelToExpressionMapping, rewardModels)); |
|
|
|
return std::shared_ptr<storm::models::symbolic::Model<Type, ValueType>>(new storm::models::symbolic::Mdp<Type, ValueType>(generationInfo.manager, reachableStates, initialStates, deadlockStates, transitionMatrix, generationInfo.rowMetaVariables, generationInfo.rowExpressionAdapter, generationInfo.columnMetaVariables, generationInfo.columnExpressionAdapter, generationInfo.rowColumnMetaVariablePairs, generationInfo.allNondeterminismVariables, labelToExpressionMapping, rewardModels)); |
|
|
|
} else { |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Invalid model type."); |
|
|
|
} |
|
|
|