|
|
@ -19,23 +19,12 @@ namespace storm { |
|
|
|
template <typename ValueType> |
|
|
|
void BoundedGloballyGameViHelper<ValueType>::prepareSolversAndMultipliers(const Environment& env) { |
|
|
|
_multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, _transitionMatrix); |
|
|
|
/*
|
|
|
|
_x1IsCurrent = false; |
|
|
|
*/ |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
void BoundedGloballyGameViHelper<ValueType>::performValueIteration(Environment const& env, std::vector<ValueType>& x, storm::solver::OptimizationDirection const dir, uint64_t upperBound) { |
|
|
|
prepareSolversAndMultipliers(env); |
|
|
|
/*
|
|
|
|
_x1.assign(_transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>()); |
|
|
|
*/ |
|
|
|
_x1 = x; |
|
|
|
_x2 = _x1; |
|
|
|
|
|
|
|
/* STORM_LOG_DEBUG("_b = " << _b);
|
|
|
|
STORM_LOG_DEBUG("_x1 = " << _x1); |
|
|
|
STORM_LOG_DEBUG("_x2 = " << _x2);*/ |
|
|
|
_x = x; |
|
|
|
|
|
|
|
if (this->isProduceSchedulerSet()) { |
|
|
|
if (!this->_producedOptimalChoices.is_initialized()) { |
|
|
@ -46,24 +35,9 @@ namespace storm { |
|
|
|
|
|
|
|
for (uint64_t iter = 0; iter < upperBound; iter++) { |
|
|
|
performIterationStep(env, dir); |
|
|
|
/* STORM_LOG_DEBUG("After iteration " << iter << ":");
|
|
|
|
STORM_LOG_DEBUG("_x1 = " << _x1); |
|
|
|
STORM_LOG_DEBUG("_x2 = " << _x2);*/ |
|
|
|
|
|
|
|
/* if (storm::utility::resources::isTerminate()) {
|
|
|
|
break; |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
x = xNew(); |
|
|
|
*/ |
|
|
|
x = _x1; |
|
|
|
|
|
|
|
/* if (isProduceSchedulerSet()) {
|
|
|
|
// We will be doing one more iteration step and track scheduler choices this time.
|
|
|
|
performIterationStep(env, dir, &_producedOptimalChoices.get()); |
|
|
|
}*/ |
|
|
|
x = _x; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
@ -71,27 +45,15 @@ namespace storm { |
|
|
|
if (!_multiplier) { |
|
|
|
prepareSolversAndMultipliers(env); |
|
|
|
} |
|
|
|
/* _x1IsCurrent = !_x1IsCurrent;*/ |
|
|
|
|
|
|
|
// multiplyandreducegaussseidel
|
|
|
|
// Ax + b
|
|
|
|
if (choices == nullptr) { |
|
|
|
_multiplier->multiplyAndReduce(env, dir, _x1, nullptr, _x1, nullptr, &_statesOfCoalition); |
|
|
|
_multiplier->multiplyAndReduce(env, dir, _x, nullptr, _x, nullptr, &_statesOfCoalition); |
|
|
|
} else { |
|
|
|
// Also keep track of the choices made.
|
|
|
|
_multiplier->multiplyAndReduce(env, dir, _x1, nullptr, _x1, choices, &_statesOfCoalition); |
|
|
|
_multiplier->multiplyAndReduce(env, dir, _x, nullptr, _x, choices, &_statesOfCoalition); |
|
|
|
} |
|
|
|
|
|
|
|
/* // compare applyPointwise
|
|
|
|
storm::utility::vector::applyPointwise<ValueType, ValueType, ValueType>(xOld(), xNew(), xNew(), [&dir] (ValueType const& a, ValueType const& b) -> ValueType { |
|
|
|
if(storm::solver::maximize(dir)) { |
|
|
|
if(a > b) return a; |
|
|
|
else return b; |
|
|
|
} else { |
|
|
|
if(a > b) return a; |
|
|
|
else return b; |
|
|
|
} |
|
|
|
});*/ |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
@ -142,26 +104,6 @@ namespace storm { |
|
|
|
return scheduler; |
|
|
|
} |
|
|
|
|
|
|
|
/* template <typename ValueType>
|
|
|
|
std::vector<ValueType>& BoundedGloballyGameViHelper<ValueType>::xNew() { |
|
|
|
return _x1IsCurrent ? _x1 : _x2; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
std::vector<ValueType> const& BoundedGloballyGameViHelper<ValueType>::xNew() const { |
|
|
|
return _x1IsCurrent ? _x1 : _x2; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
std::vector<ValueType>& BoundedGloballyGameViHelper<ValueType>::xOld() { |
|
|
|
return _x1IsCurrent ? _x2 : _x1; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
std::vector<ValueType> const& BoundedGloballyGameViHelper<ValueType>::xOld() const { |
|
|
|
return _x1IsCurrent ? _x2 : _x1; |
|
|
|
}*/ |
|
|
|
|
|
|
|
template class BoundedGloballyGameViHelper<double>; |
|
|
|
#ifdef STORM_HAVE_CARL
|
|
|
|
template class BoundedGloballyGameViHelper<storm::RationalNumber>; |
|
|
|