988 std::set<storm::expressions::Variable>
const& rowMetaVariables, std::set<storm::expressions::Variable>
const& columnMetaVariables,
989 std::set<storm::expressions::Variable>
const& groupMetaVariables,
storm::dd::Odd const& rowOdd,
storm::dd::Odd const& columnOdd)
const {
990 std::vector<uint_fast64_t> ddRowVariableIndices;
991 std::vector<uint_fast64_t> ddColumnVariableIndices;
992 std::vector<uint_fast64_t> ddGroupVariableIndices;
993 std::set<storm::expressions::Variable> rowAndColumnMetaVariables;
995 for (
auto const& variable : rowMetaVariables) {
997 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
998 ddRowVariableIndices.push_back(ddVariable.getIndex());
1000 rowAndColumnMetaVariables.insert(variable);
1002 std::sort(ddRowVariableIndices.begin(), ddRowVariableIndices.end());
1003 for (
auto const& variable : columnMetaVariables) {
1005 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1006 ddColumnVariableIndices.push_back(ddVariable.getIndex());
1008 rowAndColumnMetaVariables.insert(variable);
1010 std::sort(ddColumnVariableIndices.begin(), ddColumnVariableIndices.end());
1011 for (
auto const& variable : groupMetaVariables) {
1013 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1014 ddGroupVariableIndices.push_back(ddVariable.getIndex());
1017 std::sort(ddGroupVariableIndices.begin(), ddGroupVariableIndices.end());
1022 rowGroupIndices.resize(rowGroupIndices.size() + 1);
1023 uint_fast64_t tmp = 0;
1024 uint_fast64_t tmp2 = 0;
1025 for (uint_fast64_t i = 1; i < rowGroupIndices.size(); ++i) {
1026 tmp2 = rowGroupIndices[i];
1027 rowGroupIndices[i] = rowGroupIndices[i - 1] + tmp;
1028 std::swap(tmp, tmp2);
1030 rowGroupIndices[0] = 0;
1033 std::vector<std::vector<ValueType>> explicitVectors(vectors.size());
1034 for (
auto& v : explicitVectors) {
1035 v.resize(rowGroupIndices.back());
1039 std::vector<std::vector<Add<LibraryType, ValueType>>> groups;
1040 if (vectors.size() == 1) {
1043 internalAdd.splitIntoGroups(vectors.front(), ddGroupVariableIndices);
1044 for (
auto const& internalAdd : internalAddGroups) {
1049 std::vector<InternalAdd<LibraryType, ValueType>> internalVectors;
1051 internalVectors.push_back(v.getInternalAdd());
1053 std::vector<std::vector<InternalAdd<LibraryType, ValueType>>> internalAddGroups = internalAdd.splitIntoGroups(internalVectors, ddGroupVariableIndices);
1054 for (
auto const& internalAddGroup : internalAddGroups) {
1055 STORM_LOG_ASSERT(internalAddGroup.size() == vectors.size() + 1,
"Unexpected group size.");
1056 std::vector<Add<LibraryType, ValueType>> group;
1057 for (uint64_t vectorIndex = 0; vectorIndex < vectors.size(); ++vectorIndex) {
1062 groups.push_back(std::move(group));
1067 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>> columnsAndValues(this->getNonZeroCount());
1070 std::vector<uint_fast64_t> rowIndications(rowGroupIndices.back() + 1);
1072 std::vector<InternalAdd<LibraryType, uint_fast64_t>> statesWithGroupEnabled(groups.size());
1074 for (uint_fast64_t i = 0; i < groups.size(); ++i) {
1075 std::vector<Add<LibraryType, ValueType>>
const& group = groups[i];
1078 std::vector<uint64_t> tmpRowIndications = matrixDdNotZero.template toAdd<uint_fast64_t>().sumAbstract(columnMetaVariables).
toVector(rowOdd);
1079 for (uint64_t offset = 0; offset < tmpRowIndications.size(); ++offset) {
1080 rowIndications[rowGroupIndices[offset]] += tmpRowIndications[offset];
1084 for (uint64_t vectorIndex = 0; vectorIndex < vectors.size(); ++vectorIndex) {
1085 vectorDdNotZero |= group[vectorIndex].notZero();
1086 group[vectorIndex].internalAdd.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, explicitVectors[vectorIndex],
1087 std::plus<ValueType>());
1090 statesWithGroupEnabled[i] = (matrixDdNotZero.
existsAbstract(columnMetaVariables) || vectorDdNotZero).
template toAdd<uint_fast64_t>();
1091 stateToRowGroupCount += statesWithGroupEnabled[i];
1092 statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
1096 stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
1101 for (uint_fast64_t i = 1; i < rowIndications.size(); ++i) {
1102 tmp2 = rowIndications[i];
1103 rowIndications[i] = rowIndications[i - 1] + tmp;
1104 std::swap(tmp, tmp2);
1106 rowIndications[0] = 0;
1109 for (uint_fast64_t i = 0; i < groups.size(); ++i) {
1110 auto const& dd = groups[i].back();
1112 dd.internalAdd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices,
1114 statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
1118 stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
1121 for (uint_fast64_t i = rowIndications.size() - 1; i > 0; --i) {
1122 rowIndications[i] = rowIndications[i - 1];
1124 rowIndications[0] = 0;
1126 return std::make_pair(
1128 std::move(explicitVectors));