|
|
@ -158,15 +158,10 @@ namespace storm { |
|
|
|
|
|
|
|
template <class SparseModelType> |
|
|
|
void SparsePcaaWeightVectorChecker<SparseModelType>::unboundedIndividualPhase(std::vector<ValueType> const& weightVector) { |
|
|
|
|
|
|
|
if(objectivesWithNoUpperTimeBound.getNumberOfSetBits()==1) { |
|
|
|
auto objIndex = *objectivesWithNoUpperTimeBound.begin(); |
|
|
|
objectiveResults[objIndex] = weightedResult; |
|
|
|
if(!storm::utility::isZero(weightVector[objIndex])) { |
|
|
|
storm::utility::vector::scaleVectorInPlace(objectiveResults[objIndex], storm::utility::one<ValueType>()/weightVector[objIndex]); |
|
|
|
} |
|
|
|
if(objectivesWithNoUpperTimeBound.getNumberOfSetBits() == 1 && storm::utility::isOne(weightVector[*objectivesWithNoUpperTimeBound.begin()])) { |
|
|
|
objectiveResults[*objectivesWithNoUpperTimeBound.begin()] = weightedResult; |
|
|
|
for (uint_fast64_t objIndex2 = 0; objIndex2 < objectives.size(); ++objIndex2) { |
|
|
|
if(objIndex != objIndex2) { |
|
|
|
if(*objectivesWithNoUpperTimeBound.begin() != objIndex2) { |
|
|
|
objectiveResults[objIndex2] = std::vector<ValueType>(model.getNumberOfStates(), storm::utility::zero<ValueType>()); |
|
|
|
} |
|
|
|
} |
|
|
@ -187,26 +182,37 @@ namespace storm { |
|
|
|
offsetsToUpperBound[objIndex] = storm::utility::zero<ValueType>(); |
|
|
|
storm::utility::vector::selectVectorValues(deterministicStateRewards, this->scheduler.getChoices(), model.getTransitionMatrix().getRowGroupIndices(), discreteActionRewards[objIndex]); |
|
|
|
storm::storage::BitVector statesWithRewards = ~storm::utility::vector::filterZero(deterministicStateRewards); |
|
|
|
// As target states, we pick the states from which no reward is reachable.
|
|
|
|
storm::storage::BitVector targetStates = ~storm::utility::graph::performProbGreater0(deterministicBackwardTransitions, storm::storage::BitVector(deterministicMatrix.getRowCount(), true), statesWithRewards); |
|
|
|
// As maybestates we pick the states from which a state with reward is reachable
|
|
|
|
storm::storage::BitVector maybeStates = storm::utility::graph::performProbGreater0(deterministicBackwardTransitions, storm::storage::BitVector(deterministicMatrix.getRowCount(), true), statesWithRewards); |
|
|
|
|
|
|
|
// Compute the estimate for this objective
|
|
|
|
if (!storm::utility::isZero(weightVector[objIndex])) { |
|
|
|
objectiveResults[objIndex] = weightedSumOfUncheckedObjectives; |
|
|
|
storm::utility::vector::scaleVectorInPlace(objectiveResults[objIndex], storm::utility::one<ValueType>() / sumOfWeightsOfUncheckedObjectives); |
|
|
|
} |
|
|
|
|
|
|
|
// Make sure that the objectiveResult is initialized in some way
|
|
|
|
// Make sure that the objectiveResult is initialized correctly
|
|
|
|
objectiveResults[objIndex].resize(model.getNumberOfStates(), storm::utility::zero<ValueType>()); |
|
|
|
|
|
|
|
// Invoke the linear equation solver
|
|
|
|
objectiveResults[objIndex] = storm::modelchecker::helper::SparseDtmcPrctlHelper<ValueType>::computeReachabilityRewards(deterministicMatrix, |
|
|
|
deterministicBackwardTransitions, |
|
|
|
deterministicStateRewards, |
|
|
|
targetStates, |
|
|
|
false, //no qualitative checking,
|
|
|
|
linearEquationSolverFactory, |
|
|
|
objectiveResults[objIndex]); |
|
|
|
if (!maybeStates.empty()) { |
|
|
|
storm::storage::SparseMatrix<ValueType> submatrix = deterministicMatrix.getSubmatrix( |
|
|
|
true, maybeStates, maybeStates, true); |
|
|
|
// Converting the matrix from the fixpoint notation to the form needed for the equation
|
|
|
|
// system. That is, we go from x = A*x + b to (I-A)x = b.
|
|
|
|
submatrix.convertToEquationSystem(); |
|
|
|
|
|
|
|
// Prepare solution vector and rhs of the equation system.
|
|
|
|
std::vector<ValueType> x = storm::utility::vector::filterVector(objectiveResults[objIndex], maybeStates); |
|
|
|
std::vector<ValueType> b = storm::utility::vector::filterVector(deterministicStateRewards, maybeStates); |
|
|
|
|
|
|
|
// Now solve the resulting equation system.
|
|
|
|
std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> solver = linearEquationSolverFactory.create(std::move(submatrix)); |
|
|
|
solver->solveEquations(x, b); |
|
|
|
|
|
|
|
// Set the result for this objective accordingly
|
|
|
|
storm::utility::vector::setVectorValues<ValueType>(objectiveResults[objIndex], maybeStates, x); |
|
|
|
storm::utility::vector::setVectorValues<ValueType>(objectiveResults[objIndex], ~maybeStates, storm::utility::zero<ValueType>()); |
|
|
|
} |
|
|
|
|
|
|
|
// Update the estimate for the next objectives.
|
|
|
|
if (!storm::utility::isZero(weightVector[objIndex])) { |
|
|
|
storm::utility::vector::addScaledVector(weightedSumOfUncheckedObjectives, objectiveResults[objIndex], -weightVector[objIndex]); |
|
|
|