20 : NOT_IN_EC(
std::numeric_limits<uint64_t>::max()),
21 eliminatedEndComponents(!endComponentDecomposition.empty()),
22 numberOfMaybeStatesInEc(0),
23 numberOfMaybeStatesNotInEc(0),
24 numberOfEc(endComponentDecomposition.size()) {
31 uint64_t mecIndex = 0;
32 for (
auto const& mec : endComponentDecomposition) {
33 for (
auto const& stateActions : mec) {
34 maybeStateToEc[maybeStatesBefore[stateActions.first]] = mecIndex;
35 ++numberOfMaybeStatesInEc;
41 numberOfMaybeStatesNotInEc = maybeStateToEc.size() - numberOfMaybeStatesInEc;
44 maybeStatesNotInEcBefore = std::vector<uint64_t>(maybeStateToEc.size());
47 auto resultIt = maybeStatesNotInEcBefore.begin();
48 for (
auto const& e : maybeStateToEc) {
106 std::vector<ValueType>* columnSumVector, std::vector<ValueType>* summandResultVector,
bool gatherExitChoices) {
109 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
111 "We do not support the elimination of end components and the creation of an adequate equation system with interval models.");
115 uint64_t numberOfStates = result.numberOfMaybeStatesNotInEc + result.numberOfEc;
117 STORM_LOG_TRACE(
"Creating " << numberOfStates <<
" states from " << result.numberOfMaybeStatesNotInEc <<
" states not in ECs and "
118 << result.numberOfMaybeStatesInEc <<
" states in " << result.numberOfEc <<
" ECs.");
122 STORM_LOG_ASSERT((sumColumns && columnSumVector) || (!sumColumns && !columnSumVector),
123 "Expecting a bit vector for which columns to sum iff there is a column sum result vector.");
124 if (columnSumVector) {
126 columnSumVector->resize(0);
128 STORM_LOG_ASSERT((summand && summandResultVector) || (!summand && !summandResultVector),
"Expecting summand iff there is a summand result vector.");
129 if (summandResultVector) {
131 summandResultVector->resize(0);
133 std::vector<std::pair<uint64_t, ValueType>> ecValuePairs;
136 uint64_t currentRow = 0;
137 for (
auto state : maybeStates) {
142 if (selectedChoices && !selectedChoices->
get(row)) {
146 ecValuePairs.clear();
149 summandResultVector->emplace_back((*summand)[row]);
151 if (columnSumVector) {
152 columnSumVector->emplace_back(storm::utility::zero<ValueType>());
154 for (
auto const& e : transitionMatrix.
getRow(row)) {
155 if (sumColumns && sumColumns->
get(e.getColumn())) {
156 columnSumVector->back() += e.getValue();
157 }
else if (maybeStates.
get(e.getColumn())) {
160 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
163 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
168 if (!ecValuePairs.empty()) {
169 std::sort(ecValuePairs.begin(), ecValuePairs.end());
171 for (
auto const& e : ecValuePairs) {
172 builder.
addNextValue(currentRow, result.numberOfMaybeStatesNotInEc + e.first, e.second);
182 for (
auto const& mec : endComponentDecomposition) {
184 std::vector<uint64_t> exitChoices;
185 for (
auto const& stateActions : mec) {
186 uint64_t
const& state = stateActions.first;
189 if (stateActions.second.find(row) != stateActions.second.end()) {
194 if (selectedChoices && !selectedChoices->
get(row)) {
198 ecValuePairs.clear();
201 summandResultVector->emplace_back((*summand)[row]);
203 if (columnSumVector) {
204 columnSumVector->emplace_back(storm::utility::zero<ValueType>());
206 for (
auto const& e : transitionMatrix.
getRow(row)) {
207 if (sumColumns && sumColumns->
get(e.getColumn())) {
208 columnSumVector->back() += e.getValue();
209 }
else if (maybeStates.
get(e.getColumn())) {
212 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
215 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
220 if (!ecValuePairs.empty()) {
221 std::sort(ecValuePairs.begin(), ecValuePairs.end());
223 for (
auto const& e : ecValuePairs) {
228 if (gatherExitChoices) {
229 exitChoices.push_back(row);
235 if (gatherExitChoices) {
236 result.ecToExitChoicesBefore.push_back(std::move(exitChoices));
240 submatrix = builder.
build(currentRow);
251 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
253 "We do not support the elimination of end components and the creation of an adequate equation system with interval models.");
258 uint64_t numberOfStates = result.numberOfMaybeStatesNotInEc + result.numberOfEc;
260 STORM_LOG_TRACE(
"Found " << numberOfStates <<
" states, " << result.numberOfMaybeStatesNotInEc <<
" not in ECs, " << result.numberOfMaybeStatesInEc
261 <<
" in ECs and " << result.numberOfEc <<
" ECs.");
265 subvector.resize(numberOfStates);
267 std::vector<std::pair<uint64_t, ValueType>> ecValuePairs;
270 uint64_t currentRow = 0;
271 for (
auto state : maybeStates) {
276 subvector[currentRow] = rhsVector[row];
278 ecValuePairs.clear();
279 for (
auto const& e : transitionMatrix.
getRow(row)) {
280 if (maybeStates.
get(e.getColumn())) {
283 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
286 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
291 if (!ecValuePairs.empty()) {
292 std::sort(ecValuePairs.begin(), ecValuePairs.end());
294 for (
auto const& e : ecValuePairs) {
295 builder.
addNextValue(currentRow, result.numberOfMaybeStatesNotInEc + e.first, e.second);
305 for (
auto const& mec : endComponentDecomposition) {
307 std::vector<uint64_t> exitChoices;
308 for (
auto const& stateActions : mec) {
309 uint64_t
const& state = stateActions.first;
312 if (stateActions.second.find(row) != stateActions.second.end()) {
317 subvector[currentRow] = rhsVector[row];
319 ecValuePairs.clear();
320 for (
auto const& e : transitionMatrix.
getRow(row)) {
321 if (maybeStates.
get(e.getColumn())) {
324 builder.
addNextValue(currentRow, maybeStatesNotInEcBefore[result.maybeStatesBefore[e.getColumn()]], e.getValue());
327 ecValuePairs.emplace_back(result.
getEc(e.getColumn()), e.getValue());
332 if (!ecValuePairs.empty()) {
333 std::sort(ecValuePairs.begin(), ecValuePairs.end());
335 for (
auto const& e : ecValuePairs) {
340 if (gatherExitChoices) {
341 exitChoices.push_back(row);
347 if (gatherExitChoices) {
348 result.ecToExitChoicesBefore.push_back(std::move(exitChoices));
352 submatrix = builder.
build();
379 std::vector<uint64_t>
const& fromResult) {
383 auto notInEcResultIt = fromResult.begin();
384 for (
auto state : maybeStates) {
385 if (this->isStateInEc(state)) {
386 STORM_LOG_ASSERT(this->getRowGroupAfterElimination(state) >= this->getNumberOfMaybeStatesNotInEc(),
387 "Expected introduced EC states to be located at the end of the matrix.");
388 STORM_LOG_ASSERT(!ecToExitChoicesBefore.empty(),
"No EC exit choices available. End Components have probably been build without.");
389 uint64_t ec = getEc(state);
390 auto const& exitChoices = ecToExitChoicesBefore[ec];
391 uint64_t afterEliminationChoice = fromResult[this->getRowGroupAfterElimination(state)];
392 uint64_t beforeEliminationGlobalChoiceIndex = exitChoices[afterEliminationChoice];
393 bool noChoice =
true;
397 if (globalChoice == beforeEliminationGlobalChoiceIndex) {
402 if (std::find(exitChoices.begin(), exitChoices.end(), globalChoice) == exitChoices.end()) {
403 ecStayChoices.
set(globalChoice,
true);
407 maybeStatesWithoutChoice.
set(state, noChoice);
409 scheduler.
setChoice(*notInEcResultIt, state);
414 STORM_LOG_ASSERT(notInEcResultIt == fromResult.begin() + this->getNumberOfMaybeStatesNotInEc(),
"Mismatching iterators.");
417 auto maybeStatesWithChoice = maybeStates & ~maybeStatesWithoutChoice;
419 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...