19 : NOT_IN_EC(
std::numeric_limits<uint64_t>::max()),
20 eliminatedEndComponents(!endComponentDecomposition.empty()),
21 numberOfMaybeStatesInEc(0),
22 numberOfMaybeStatesNotInEc(0),
23 numberOfEc(endComponentDecomposition.size()) {
30 uint64_t mecIndex = 0;
31 for (
auto const& mec : endComponentDecomposition) {
32 for (
auto const& stateActions : mec) {
33 maybeStateToEc[maybeStatesBefore[stateActions.first]] = mecIndex;
34 ++numberOfMaybeStatesInEc;
40 numberOfMaybeStatesNotInEc = maybeStateToEc.size() - numberOfMaybeStatesInEc;
43 maybeStatesNotInEcBefore = std::vector<uint64_t>(maybeStateToEc.size());
46 auto resultIt = maybeStatesNotInEcBefore.begin();
47 for (
auto const& e : maybeStateToEc) {
105 std::vector<ValueType>* columnSumVector, std::vector<ValueType>* summandResultVector,
bool gatherExitChoices) {
108 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
110 "We do not support the elimination of end components and the creation of an adequate equation system with interval models.");
114 uint64_t numberOfStates = result.numberOfMaybeStatesNotInEc + result.numberOfEc;
116 STORM_LOG_TRACE(
"Creating " << numberOfStates <<
" states from " << result.numberOfMaybeStatesNotInEc <<
" states not in ECs and "
117 << result.numberOfMaybeStatesInEc <<
" states in " << result.numberOfEc <<
" ECs.");
121 STORM_LOG_ASSERT((sumColumns && columnSumVector) || (!sumColumns && !columnSumVector),
122 "Expecting a bit vector for which columns to sum iff there is a column sum result vector.");
123 if (columnSumVector) {
125 columnSumVector->resize(0);
127 STORM_LOG_ASSERT((summand && summandResultVector) || (!summand && !summandResultVector),
"Expecting summand iff there is a summand result vector.");
128 if (summandResultVector) {
130 summandResultVector->resize(0);
132 std::vector<std::pair<uint64_t, ValueType>> ecValuePairs;
135 uint64_t currentRow = 0;
136 for (
auto state : maybeStates) {
141 if (selectedChoices && !selectedChoices->
get(row)) {
145 ecValuePairs.clear();
148 summandResultVector->emplace_back((*summand)[row]);
150 if (columnSumVector) {
151 columnSumVector->emplace_back(storm::utility::zero<ValueType>());
153 for (
auto const& e : transitionMatrix.
getRow(row)) {
154 if (sumColumns && sumColumns->
get(e.getColumn())) {
155 columnSumVector->back() += e.getValue();
156 }
else if (maybeStates.
get(e.getColumn())) {
159 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
162 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
167 if (!ecValuePairs.empty()) {
168 std::sort(ecValuePairs.begin(), ecValuePairs.end());
170 for (
auto const& e : ecValuePairs) {
171 builder.
addNextValue(currentRow, result.numberOfMaybeStatesNotInEc + e.first, e.second);
181 for (
auto const& mec : endComponentDecomposition) {
183 std::vector<uint64_t> exitChoices;
184 for (
auto const& stateActions : mec) {
185 uint64_t
const& state = stateActions.first;
188 if (stateActions.second.find(row) != stateActions.second.end()) {
193 if (selectedChoices && !selectedChoices->
get(row)) {
197 ecValuePairs.clear();
200 summandResultVector->emplace_back((*summand)[row]);
202 if (columnSumVector) {
203 columnSumVector->emplace_back(storm::utility::zero<ValueType>());
205 for (
auto const& e : transitionMatrix.
getRow(row)) {
206 if (sumColumns && sumColumns->
get(e.getColumn())) {
207 columnSumVector->back() += e.getValue();
208 }
else if (maybeStates.
get(e.getColumn())) {
211 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
214 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
219 if (!ecValuePairs.empty()) {
220 std::sort(ecValuePairs.begin(), ecValuePairs.end());
222 for (
auto const& e : ecValuePairs) {
227 if (gatherExitChoices) {
228 exitChoices.push_back(row);
234 if (gatherExitChoices) {
235 result.ecToExitChoicesBefore.push_back(std::move(exitChoices));
239 submatrix = builder.
build(currentRow);
250 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
252 "We do not support the elimination of end components and the creation of an adequate equation system with interval models.");
257 uint64_t numberOfStates = result.numberOfMaybeStatesNotInEc + result.numberOfEc;
259 STORM_LOG_TRACE(
"Found " << numberOfStates <<
" states, " << result.numberOfMaybeStatesNotInEc <<
" not in ECs, " << result.numberOfMaybeStatesInEc
260 <<
" in ECs and " << result.numberOfEc <<
" ECs.");
264 subvector.resize(numberOfStates);
266 std::vector<std::pair<uint64_t, ValueType>> ecValuePairs;
269 uint64_t currentRow = 0;
270 for (
auto state : maybeStates) {
275 subvector[currentRow] = rhsVector[row];
277 ecValuePairs.clear();
278 for (
auto const& e : transitionMatrix.
getRow(row)) {
279 if (maybeStates.
get(e.getColumn())) {
282 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
285 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
290 if (!ecValuePairs.empty()) {
291 std::sort(ecValuePairs.begin(), ecValuePairs.end());
293 for (
auto const& e : ecValuePairs) {
294 builder.
addNextValue(currentRow, result.numberOfMaybeStatesNotInEc + e.first, e.second);
304 for (
auto const& mec : endComponentDecomposition) {
306 std::vector<uint64_t> exitChoices;
307 for (
auto const& stateActions : mec) {
308 uint64_t
const& state = stateActions.first;
311 if (stateActions.second.find(row) != stateActions.second.end()) {
316 subvector[currentRow] = rhsVector[row];
318 ecValuePairs.clear();
319 for (
auto const& e : transitionMatrix.
getRow(row)) {
320 if (maybeStates.
get(e.getColumn())) {
323 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
326 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
331 if (!ecValuePairs.empty()) {
332 std::sort(ecValuePairs.begin(), ecValuePairs.end());
334 for (
auto const& e : ecValuePairs) {
339 if (gatherExitChoices) {
340 exitChoices.push_back(row);
346 if (gatherExitChoices) {
347 result.ecToExitChoicesBefore.push_back(std::move(exitChoices));
351 submatrix = builder.
build();
378 std::vector<uint64_t>
const& fromResult) {
382 auto notInEcResultIt = fromResult.begin();
383 for (
auto state : maybeStates) {
384 if (this->isStateInEc(state)) {
385 STORM_LOG_ASSERT(this->getRowGroupAfterElimination(state) >= this->getNumberOfMaybeStatesNotInEc(),
386 "Expected introduced EC states to be located at the end of the matrix.");
387 STORM_LOG_ASSERT(!ecToExitChoicesBefore.empty(),
"No EC exit choices available. End Components have probably been build without.");
388 uint64_t ec = getEc(state);
389 auto const& exitChoices = ecToExitChoicesBefore[ec];
390 uint64_t afterEliminationChoice = fromResult[this->getRowGroupAfterElimination(state)];
391 uint64_t beforeEliminationGlobalChoiceIndex = exitChoices[afterEliminationChoice];
392 bool noChoice =
true;
396 if (globalChoice == beforeEliminationGlobalChoiceIndex) {
401 if (std::find(exitChoices.begin(), exitChoices.end(), globalChoice) == exitChoices.end()) {
402 ecStayChoices.
set(globalChoice,
true);
406 maybeStatesWithoutChoice.
set(state, noChoice);
408 scheduler.
setChoice(*notInEcResultIt, state);
413 STORM_LOG_ASSERT(notInEcResultIt == fromResult.begin() + this->getNumberOfMaybeStatesNotInEc(),
"Mismatching iterators.");
416 auto maybeStatesWithChoice = maybeStates & ~maybeStatesWithoutChoice;
418 scheduler, ecStayChoices);
void computeSchedulerProb1E(storm::storage::BitVector const &prob1EStates, storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, storm::storage::Scheduler< SchedulerValueType > &scheduler, boost::optional< storm::storage::BitVector > const &rowFilter)
Computes a scheduler for the given prob1EStates such that in the induced system the given psiStates a...