Browse Source

added bunch of debug output for aliasing problem

tempestpy_adaptions
dehnert 7 years ago
parent
commit
d612337ebf
  1. 11
      src/storm/solver/EigenLinearEquationSolver.cpp
  2. 23
      src/storm/solver/NativeLinearEquationSolver.cpp
  3. 10
      src/storm/storage/SparseMatrix.cpp

11
src/storm/solver/EigenLinearEquationSolver.cpp

@ -143,6 +143,8 @@ namespace storm {
template<typename ValueType> template<typename ValueType>
void EigenLinearEquationSolver<ValueType>::setMatrix(storm::storage::SparseMatrix<ValueType> const& A) { void EigenLinearEquationSolver<ValueType>::setMatrix(storm::storage::SparseMatrix<ValueType> const& A) {
std::cout << A << std::endl;
eigenA = storm::adapters::EigenAdapter::toEigenSparseMatrix<ValueType>(A); eigenA = storm::adapters::EigenAdapter::toEigenSparseMatrix<ValueType>(A);
this->clearCache(); this->clearCache();
} }
@ -358,7 +360,14 @@ namespace storm {
StormEigen::SparseLU<StormEigen::SparseMatrix<storm::RationalNumber>, StormEigen::COLAMDOrdering<int>> solver; StormEigen::SparseLU<StormEigen::SparseMatrix<storm::RationalNumber>, StormEigen::COLAMDOrdering<int>> solver;
solver.compute(*eigenA); solver.compute(*eigenA);
solver._solve_impl(eigenB, eigenX); solver._solve_impl(eigenB, eigenX);
std::cout << "solution" << std::endl;
uint64_t pos = 0;
for (auto const& e : x) {
std::cout << "[" << pos << "] " << e << std::endl;
++pos;
}
return solver.info() == StormEigen::ComputationInfo::Success; return solver.info() == StormEigen::ComputationInfo::Success;
} }

23
src/storm/solver/NativeLinearEquationSolver.cpp

@ -146,12 +146,15 @@ namespace storm {
localA.reset(); localA.reset();
this->A = &A; this->A = &A;
clearCache(); clearCache();
std::cout << *this->A << std::endl;
} }
template<typename ValueType> template<typename ValueType>
void NativeLinearEquationSolver<ValueType>::setMatrix(storm::storage::SparseMatrix<ValueType>&& A) { void NativeLinearEquationSolver<ValueType>::setMatrix(storm::storage::SparseMatrix<ValueType>&& A) {
localA = std::make_unique<storm::storage::SparseMatrix<ValueType>>(std::move(A)); localA = std::make_unique<storm::storage::SparseMatrix<ValueType>>(std::move(A));
this->A = localA.get(); this->A = localA.get();
std::cout << *this->A << std::endl;
clearCache(); clearCache();
} }
@ -698,7 +701,25 @@ namespace storm {
typename NativeLinearEquationSolver<ImpreciseType>::PowerIterationResult result = impreciseSolver.performPowerIteration(currentX, newX, b, storm::utility::convertNumber<ImpreciseType, ValueType>(precision), this->getSettings().getRelativeTerminationCriterion(), SolverGuarantee::LessOrEqual, overallIterations); typename NativeLinearEquationSolver<ImpreciseType>::PowerIterationResult result = impreciseSolver.performPowerIteration(currentX, newX, b, storm::utility::convertNumber<ImpreciseType, ValueType>(precision), this->getSettings().getRelativeTerminationCriterion(), SolverGuarantee::LessOrEqual, overallIterations);
// At this point, the result of the imprecise value iteration is stored in the (imprecise) current x. // At this point, the result of the imprecise value iteration is stored in the (imprecise) current x.
std::cout << "solution" << std::endl;
uint64_t pos = 0;
for (auto const& e : *currentX) {
std::cout << "[" << pos << "] " << e << std::endl;
++pos;
}
std::cout << "rational b" << std::endl;
pos = 0;
for (auto const& e : rationalB) {
std::cout << "[" << pos << "] " << e << std::endl;
++pos;
}
std::cout << "b" << std::endl;
pos = 0;
for (auto const& e : b) {
std::cout << "[" << pos << "] " << e << std::endl;
++pos;
}
++valueIterationInvocations; ++valueIterationInvocations;
STORM_LOG_TRACE("Completed " << valueIterationInvocations << " power iteration invocations, the last one with precision " << precision << " completed in " << result.iterations << " iterations."); STORM_LOG_TRACE("Completed " << valueIterationInvocations << " power iteration invocations, the last one with precision " << precision << " completed in " << result.iterations << " iterations.");

10
src/storm/storage/SparseMatrix.cpp

@ -1403,17 +1403,21 @@ namespace storm {
summandIterator = summand->end() - 1; summandIterator = summand->end() - 1;
} }
for (; resultIterator != resultIteratorEnd; --rowIterator, --resultIterator) {
for (; resultIterator != resultIteratorEnd; --rowIterator, --resultIterator, --summandIterator) {
if (summand) { if (summand) {
*resultIterator = *summandIterator; *resultIterator = *summandIterator;
--summandIterator;
std::cout << "row[" << std::distance(rowIndications.begin(), rowIterator) << "]: " << *resultIterator << " because of summand" << std::endl;
} else { } else {
*resultIterator = storm::utility::zero<ValueType>(); *resultIterator = storm::utility::zero<ValueType>();
} }
for (ite = this->begin() + *rowIterator - 1; it != ite; --it) { for (ite = this->begin() + *rowIterator - 1; it != ite; --it) {
*resultIterator += it->getValue() * vector[it->getColumn()];
std::cout << "row[" << std::distance(rowIndications.begin(), rowIterator) << "]: " << *resultIterator << std::endl;
std::cout << "row[" << std::distance(rowIndications.begin(), rowIterator) << "]: op " << *resultIterator << " + " << (it->getValue() * vector[it->getColumn()]) << " (= " << it->getValue() << " * " << vector[it->getColumn()] << ") = " << (*resultIterator + (it->getValue() * vector[it->getColumn()])) << std::endl;
*resultIterator = *resultIterator + (it->getValue() * vector[it->getColumn()]);
// std::cout << "row[" << std::distance(rowIndications.begin(), rowIterator) << "]: " << *resultIterator << " because of " << it->getValue() << " * " << vector[it->getColumn()] << " = " << (it->getValue() * vector[it->getColumn()]) << std::endl;
} }
std::cout << "row[" << std::distance(rowIndications.begin(), rowIterator) << "] final value " << *resultIterator << std::endl;
} }
} }

Loading…
Cancel
Save