995 std::set<storm::expressions::Variable>
const& rowMetaVariables, std::set<storm::expressions::Variable>
const& columnMetaVariables,
996 std::set<storm::expressions::Variable>
const& groupMetaVariables,
storm::dd::Odd const& rowOdd,
storm::dd::Odd const& columnOdd)
const {
997 std::vector<uint_fast64_t> ddRowVariableIndices;
998 std::vector<uint_fast64_t> ddColumnVariableIndices;
999 std::vector<uint_fast64_t> ddGroupVariableIndices;
1000 std::set<storm::expressions::Variable> rowAndColumnMetaVariables;
1002 for (
auto const& variable : rowMetaVariables) {
1004 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1005 ddRowVariableIndices.push_back(ddVariable.getIndex());
1007 rowAndColumnMetaVariables.insert(variable);
1009 std::sort(ddRowVariableIndices.begin(), ddRowVariableIndices.end());
1010 for (
auto const& variable : columnMetaVariables) {
1012 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1013 ddColumnVariableIndices.push_back(ddVariable.getIndex());
1015 rowAndColumnMetaVariables.insert(variable);
1017 std::sort(ddColumnVariableIndices.begin(), ddColumnVariableIndices.end());
1018 for (
auto const& variable : groupMetaVariables) {
1020 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1021 ddGroupVariableIndices.push_back(ddVariable.getIndex());
1024 std::sort(ddGroupVariableIndices.begin(), ddGroupVariableIndices.end());
1029 rowGroupIndices.resize(rowGroupIndices.size() + 1);
1030 uint_fast64_t tmp = 0;
1031 uint_fast64_t tmp2 = 0;
1032 for (uint_fast64_t i = 1; i < rowGroupIndices.size(); ++i) {
1033 tmp2 = rowGroupIndices[i];
1034 rowGroupIndices[i] = rowGroupIndices[i - 1] + tmp;
1035 std::swap(tmp, tmp2);
1037 rowGroupIndices[0] = 0;
1040 std::vector<std::vector<ValueType>> explicitVectors(vectors.size());
1041 for (
auto& v : explicitVectors) {
1042 v.resize(rowGroupIndices.back());
1046 std::vector<std::vector<Add<LibraryType, ValueType>>> groups;
1047 if (vectors.size() == 1) {
1050 internalAdd.splitIntoGroups(vectors.front(), ddGroupVariableIndices);
1051 for (
auto const& internalAdd : internalAddGroups) {
1056 std::vector<InternalAdd<LibraryType, ValueType>> internalVectors;
1058 internalVectors.push_back(v.getInternalAdd());
1060 std::vector<std::vector<InternalAdd<LibraryType, ValueType>>> internalAddGroups = internalAdd.splitIntoGroups(internalVectors, ddGroupVariableIndices);
1061 for (
auto const& internalAddGroup : internalAddGroups) {
1062 STORM_LOG_ASSERT(internalAddGroup.size() == vectors.size() + 1,
"Unexpected group size.");
1063 std::vector<Add<LibraryType, ValueType>> group;
1064 for (uint64_t vectorIndex = 0; vectorIndex < vectors.size(); ++vectorIndex) {
1069 groups.push_back(std::move(group));
1074 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>> columnsAndValues(this->getNonZeroCount());
1077 std::vector<uint_fast64_t> rowIndications(rowGroupIndices.back() + 1);
1079 std::vector<InternalAdd<LibraryType, uint_fast64_t>> statesWithGroupEnabled(groups.size());
1081 for (uint_fast64_t i = 0; i < groups.size(); ++i) {
1082 std::vector<Add<LibraryType, ValueType>>
const& group = groups[i];
1085 std::vector<uint64_t> tmpRowIndications = matrixDdNotZero.template toAdd<uint_fast64_t>().sumAbstract(columnMetaVariables).
toVector(rowOdd);
1086 for (uint64_t offset = 0; offset < tmpRowIndications.size(); ++offset) {
1087 rowIndications[rowGroupIndices[offset]] += tmpRowIndications[offset];
1091 for (uint64_t vectorIndex = 0; vectorIndex < vectors.size(); ++vectorIndex) {
1092 vectorDdNotZero |= group[vectorIndex].notZero();
1093 group[vectorIndex].internalAdd.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, explicitVectors[vectorIndex],
1094 std::plus<ValueType>());
1097 statesWithGroupEnabled[i] = (matrixDdNotZero.
existsAbstract(columnMetaVariables) || vectorDdNotZero).
template toAdd<uint_fast64_t>();
1098 stateToRowGroupCount += statesWithGroupEnabled[i];
1099 statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
1103 stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
1108 for (uint_fast64_t i = 1; i < rowIndications.size(); ++i) {
1109 tmp2 = rowIndications[i];
1110 rowIndications[i] = rowIndications[i - 1] + tmp;
1111 std::swap(tmp, tmp2);
1113 rowIndications[0] = 0;
1116 for (uint_fast64_t i = 0; i < groups.size(); ++i) {
1117 auto const& dd = groups[i].back();
1119 dd.internalAdd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices,
1121 statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
1125 stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
1128 for (uint_fast64_t i = rowIndications.size() - 1; i > 0; --i) {
1129 rowIndications[i] = rowIndications[i - 1];
1131 rowIndications[0] = 0;
1133 return std::make_pair(
1135 std::move(explicitVectors));