991 std::set<storm::expressions::Variable>
const& rowMetaVariables, std::set<storm::expressions::Variable>
const& columnMetaVariables,
992 std::set<storm::expressions::Variable>
const& groupMetaVariables,
storm::dd::Odd const& rowOdd,
storm::dd::Odd const& columnOdd)
const {
993 std::vector<uint_fast64_t> ddRowVariableIndices;
994 std::vector<uint_fast64_t> ddColumnVariableIndices;
995 std::vector<uint_fast64_t> ddGroupVariableIndices;
996 std::set<storm::expressions::Variable> rowAndColumnMetaVariables;
998 for (
auto const& variable : rowMetaVariables) {
1000 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1001 ddRowVariableIndices.push_back(ddVariable.getIndex());
1003 rowAndColumnMetaVariables.insert(variable);
1005 std::sort(ddRowVariableIndices.begin(), ddRowVariableIndices.end());
1006 for (
auto const& variable : columnMetaVariables) {
1008 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1009 ddColumnVariableIndices.push_back(ddVariable.getIndex());
1011 rowAndColumnMetaVariables.insert(variable);
1013 std::sort(ddColumnVariableIndices.begin(), ddColumnVariableIndices.end());
1014 for (
auto const& variable : groupMetaVariables) {
1016 for (
auto const& ddVariable : metaVariable.getDdVariables()) {
1017 ddGroupVariableIndices.push_back(ddVariable.getIndex());
1020 std::sort(ddGroupVariableIndices.begin(), ddGroupVariableIndices.end());
1025 rowGroupIndices.resize(rowGroupIndices.size() + 1);
1026 uint_fast64_t tmp = 0;
1027 uint_fast64_t tmp2 = 0;
1028 for (uint_fast64_t i = 1; i < rowGroupIndices.size(); ++i) {
1029 tmp2 = rowGroupIndices[i];
1030 rowGroupIndices[i] = rowGroupIndices[i - 1] + tmp;
1031 std::swap(tmp, tmp2);
1033 rowGroupIndices[0] = 0;
1036 std::vector<std::vector<ValueType>> explicitVectors(vectors.size());
1037 for (
auto& v : explicitVectors) {
1038 v.resize(rowGroupIndices.back());
1042 std::vector<std::vector<Add<LibraryType, ValueType>>> groups;
1043 if (vectors.size() == 1) {
1046 internalAdd.splitIntoGroups(vectors.front(), ddGroupVariableIndices);
1047 for (
auto const& internalAdd : internalAddGroups) {
1052 std::vector<InternalAdd<LibraryType, ValueType>> internalVectors;
1054 internalVectors.push_back(v.getInternalAdd());
1056 std::vector<std::vector<InternalAdd<LibraryType, ValueType>>> internalAddGroups = internalAdd.splitIntoGroups(internalVectors, ddGroupVariableIndices);
1057 for (
auto const& internalAddGroup : internalAddGroups) {
1058 STORM_LOG_ASSERT(internalAddGroup.size() == vectors.size() + 1,
"Unexpected group size.");
1059 std::vector<Add<LibraryType, ValueType>> group;
1060 for (uint64_t vectorIndex = 0; vectorIndex < vectors.size(); ++vectorIndex) {
1065 groups.push_back(std::move(group));
1070 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>> columnsAndValues(this->getNonZeroCount());
1073 std::vector<uint_fast64_t> rowIndications(rowGroupIndices.back() + 1);
1075 std::vector<InternalAdd<LibraryType, uint_fast64_t>> statesWithGroupEnabled(groups.size());
1077 for (uint_fast64_t i = 0; i < groups.size(); ++i) {
1078 std::vector<Add<LibraryType, ValueType>>
const& group = groups[i];
1081 std::vector<uint64_t> tmpRowIndications = matrixDdNotZero.template toAdd<uint_fast64_t>().sumAbstract(columnMetaVariables).
toVector(rowOdd);
1082 for (uint64_t offset = 0; offset < tmpRowIndications.size(); ++offset) {
1083 rowIndications[rowGroupIndices[offset]] += tmpRowIndications[offset];
1087 for (uint64_t vectorIndex = 0; vectorIndex < vectors.size(); ++vectorIndex) {
1088 vectorDdNotZero |= group[vectorIndex].notZero();
1089 group[vectorIndex].internalAdd.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, explicitVectors[vectorIndex],
1090 std::plus<ValueType>());
1093 statesWithGroupEnabled[i] = (matrixDdNotZero.
existsAbstract(columnMetaVariables) || vectorDdNotZero).
template toAdd<uint_fast64_t>();
1094 stateToRowGroupCount += statesWithGroupEnabled[i];
1095 statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
1099 stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
1104 for (uint_fast64_t i = 1; i < rowIndications.size(); ++i) {
1105 tmp2 = rowIndications[i];
1106 rowIndications[i] = rowIndications[i - 1] + tmp;
1107 std::swap(tmp, tmp2);
1109 rowIndications[0] = 0;
1112 for (uint_fast64_t i = 0; i < groups.size(); ++i) {
1113 auto const& dd = groups[i].back();
1115 dd.internalAdd.toMatrixComponents(rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, ddRowVariableIndices, ddColumnVariableIndices,
1117 statesWithGroupEnabled[i].composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::plus<uint_fast64_t>());
1121 stateToRowGroupCount.composeWithExplicitVector(rowOdd, ddRowVariableIndices, rowGroupIndices, std::minus<uint_fast64_t>());
1124 for (uint_fast64_t i = rowIndications.size() - 1; i > 0; --i) {
1125 rowIndications[i] = rowIndications[i - 1];
1127 rowIndications[0] = 0;
1129 return std::make_pair(
1131 std::move(explicitVectors));