Browse Source

Fix TODOs

tempestpy_adaptions
Jip Spel 3 years ago
parent
commit
d77c285faf
  1. 6
      src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp
  2. 39
      src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp

6
src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp

@ -175,8 +175,7 @@ namespace storm {
// Group staat voor de states?
for (uint_fast64_t group = 0; group < this->A->getRowGroupCount(); ++group) {
uint_fast64_t currentChoice = scheduler[group];
// TODO: remove, as this should already be fixed by implementation to determine matrix/vector
if (!this->choiceFixedForState || (this->choiceFixedForState && !(this->choiceFixedForState.get()[group]))) {
assert (!this->choiceFixedForState || (this->choiceFixedForState && (!(this->choiceFixedForState.get()[group]) || this->A->getRowGroupSize(group) == 1)));
for (uint_fast64_t choice = this->A->getRowGroupIndices()[group];
choice < this->A->getRowGroupIndices()[group + 1]; ++choice) {
// If the choice is the currently selected one, we can skip it.
@ -200,9 +199,6 @@ namespace storm {
x[group] = std::move(choiceValue);
}
}
} else {
STORM_LOG_INFO("Ignoring state" << group << " as the choice of this state is fixed");
}
}
// If the scheduler did not improve, we are done.

39
src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp

@ -89,14 +89,12 @@ namespace storm {
progress.startNewMeasurement(0);
for (auto const& scc : *this->sortedSccDecomposition) {
if (scc.size() == 1) {
// TODO: directly use localMonRes on this
returnValue = solveTrivialScc(*scc.begin(), dir, x, b) && returnValue;
} else {
STORM_LOG_TRACE("Solving SCC of size " << scc.size() << ".");
sccRowGroupsAsBitVector.clear();
sccRowsAsBitVector.clear();
for (auto const& group : scc) { // Group refers to state
bool allIgnored = true;
sccRowGroupsAsBitVector.set(group, true);
if (!this->choiceFixedForState || !this->choiceFixedForState.get()[group]) {
@ -150,38 +148,12 @@ namespace storm {
ValueType& xi = globalX[sccState];
bool firstRow = true;
uint64_t bestRow;
if (this->choiceFixedForState && this->choiceFixedForState.get()[sccState]) {
assert (this->hasInitialScheduler());
uint64_t row = this->A->getRowGroupIndices()[sccState] + this->initialScheduler.get()[sccState];
ValueType rowValue = globalB[row];
bool hasDiagonalEntry = false;
ValueType denominator;
for (auto const &entry : this->A->getRow(row)) {
if (entry.getColumn() == sccState) {
hasDiagonalEntry = true;
denominator = storm::utility::one<ValueType>() - entry.getValue();
} else {
rowValue += entry.getValue() * globalX[entry.getColumn()];
}
}
if (hasDiagonalEntry) {
STORM_LOG_WARN_COND_DEBUG( storm::NumberTraits<ValueType>::IsExact || !storm::utility::isAlmostZero(denominator) ||
storm::utility::isZero(denominator), "State " << sccState << " has a selfloop with probability '1-(" << denominator << ")'. This could be an indication for numerical issues.");
assert (!storm::utility::isZero(denominator));
rowValue /= denominator;
}
if (minimize(dir)) {
xi = std::move(rowValue);
} else {
xi = std::move(rowValue);
}
STORM_LOG_INFO("Ignoring state" << sccState << " as the choice is fixed, current probability for this state is: " << this->schedulerChoices.get()[sccState]);
} else {
assert (!this->choiceFixedForState || !this->choiceFixedForState.get()[sccState] || (this->hasInitialScheduler() && this->A->getRowGroupSize(sccState) == 1));
for (uint64_t row = this->A->getRowGroupIndices()[sccState]; row < this->A->getRowGroupIndices()[sccState + 1]; ++row) {
ValueType rowValue = globalB[row];
bool hasDiagonalEntry = false;
ValueType denominator;
for (auto const &entry : this->A->getRow(row)) {
for (auto const& entry : this->A->getRow(row)) {
if (entry.getColumn() == sccState) {
hasDiagonalEntry = true;
denominator = storm::utility::one<ValueType>() - entry.getValue();
@ -191,8 +163,7 @@ namespace storm {
}
if (hasDiagonalEntry) {
STORM_LOG_WARN_COND_DEBUG(
storm::NumberTraits<ValueType>::IsExact || !storm::utility::isAlmostZero(denominator) ||
storm::utility::isZero(denominator),
storm::NumberTraits<ValueType>::IsExact || !storm::utility::isAlmostZero(denominator) || storm::utility::isZero(denominator),
"State " << sccState << " has a selfloop with probability '1-(" << denominator
<< ")'. This could be an indication for numerical issues.");
if (storm::utility::isZero(denominator)) {
@ -226,8 +197,6 @@ namespace storm {
this->schedulerChoices.get()[sccState] = bestRow - this->A->getRowGroupIndices()[sccState];
}
STORM_LOG_THROW(!firstRow, storm::exceptions::UnexpectedException, "Empty row group in MinMax equation system.");
}
//std::cout << "Solved trivial scc " << sccState << " with result " << globalX[sccState] << std::endl;
return true;
}
@ -301,8 +270,6 @@ namespace storm {
}
// std::cout << "Matrix is " << sccA << std::endl;
this->sccSolver->setMatrix(std::move(sccA));
// x Vector

Loading…
Cancel
Save