13template<
typename ParametricType>
18template<
typename ParametricType>
20 : lowerBoundaries(lowerBoundaries), upperBoundaries(upperBoundaries) {
24template<
typename ParametricType>
26 : lowerBoundaries(lowerBoundaries), upperBoundaries(upperBoundaries) {
30template<
typename ParametricType>
33 for (
auto const& variableWithLowerBoundary : this->lowerBoundaries) {
34 auto variableWithUpperBoundary = this->upperBoundaries.find(variableWithLowerBoundary.first);
35 STORM_LOG_THROW((variableWithUpperBoundary != upperBoundaries.end()), storm::exceptions::InvalidArgumentException,
36 "Could not create region. No upper boundary specified for Variable " << variableWithLowerBoundary.first);
37 STORM_LOG_THROW((variableWithLowerBoundary.second <= variableWithUpperBoundary->second), storm::exceptions::InvalidArgumentException,
38 "Could not create region. The lower boundary for " << variableWithLowerBoundary.first <<
" is larger then the upper boundary");
39 this->variables.insert(variableWithLowerBoundary.first);
40 this->sortedOnDifference.insert({variableWithLowerBoundary.second - variableWithUpperBoundary->second, variableWithLowerBoundary.first});
42 for (
auto const& variableWithBoundary : this->upperBoundaries) {
43 STORM_LOG_THROW((this->variables.find(variableWithBoundary.first) != this->variables.end()), storm::exceptions::InvalidArgumentException,
44 "Could not create region. No lower boundary specified for Variable " << variableWithBoundary.first);
46 this->splitThreshold = variables.size();
49template<
typename ParametricType>
51 return this->variables;
54template<
typename ParametricType>
57 return this->sortedOnDifference;
60template<
typename ParametricType>
62 auto const& result = lowerBoundaries.find(variable);
63 STORM_LOG_THROW(result != lowerBoundaries.end(), storm::exceptions::InvalidArgumentException,
64 "Tried to find a lower boundary for variable " << variable <<
" which is not specified by this region");
65 return (*result).second;
68template<
typename ParametricType>
70 for (
auto itr = lowerBoundaries.begin(); itr != lowerBoundaries.end(); ++itr) {
71 if (itr->first.name().compare(varName) == 0) {
76 "Tried to find a lower boundary for variableName " << varName <<
" which is not specified by this region");
79template<
typename ParametricType>
81 auto const& result = upperBoundaries.find(variable);
82 STORM_LOG_THROW(result != upperBoundaries.end(), storm::exceptions::InvalidArgumentException,
83 "Tried to find an upper boundary for variable " << variable <<
" which is not specified by this region");
84 return (*result).second;
87template<
typename ParametricType>
89 for (
auto itr = upperBoundaries.begin(); itr != upperBoundaries.end(); ++itr) {
90 if (itr->first.name().compare(varName) == 0) {
95 "Tried to find an upper boundary for variableName " << varName <<
" which is not specified by this region");
98template<
typename ParametricType>
100 return getUpperBoundary(variable) - getLowerBoundary(variable);
103template<
typename ParametricType>
105 return getUpperBoundary(varName) - getLowerBoundary(varName);
108template<
typename ParametricType>
110 return upperBoundaries;
113template<
typename ParametricType>
115 return lowerBoundaries;
118template<
typename ParametricType>
120 std::set<VariableType>
const& consideredVariables)
const {
121 std::size_t
const numOfVariables = consideredVariables.size();
122 STORM_LOG_THROW(numOfVariables <= std::numeric_limits<std::size_t>::digits, storm::exceptions::OutOfRangeException,
123 "Number of variables " << numOfVariables <<
" is too high.");
124 std::size_t
const numOfVertices = std::pow(2, numOfVariables);
125 std::vector<Valuation> resultingVector(numOfVertices);
127 for (uint_fast64_t vertexId = 0; vertexId < numOfVertices; ++vertexId) {
131 uint_fast64_t variableIndex = 0;
133 for (
auto variable : consideredVariables) {
134 if ((vertexId >> variableIndex) % 2 == 0) {
135 resultingVector[vertexId].insert(std::pair<VariableType, CoefficientType>(variable, getLowerBoundary(variable)));
137 resultingVector[vertexId].insert(std::pair<VariableType, CoefficientType>(variable, getUpperBoundary(variable)));
142 return resultingVector;
145template<
typename ParametricType>
147 return this->getLowerBoundaries();
150template<
typename ParametricType>
153 for (
auto const& variable : this->variables) {
154 result.insert(
typename Valuation::value_type(variable, (this->getLowerBoundary(variable) + this->getUpperBoundary(variable)) / 2));
159template<
typename ParametricType>
162 for (
auto const& variable : this->variables) {
163 result *= (this->getUpperBoundary(variable) - this->getLowerBoundary(variable));
168template<
typename ParametricType>
170 return split(splittingPoint, regionVector, variables);
173template<
typename ParametricType>
175 const std::set<VariableType>& consideredVariables)
const {
176 auto vertices = getVerticesOfRegion(consideredVariables);
178 for (
auto const& vertex : vertices) {
180 Valuation subLower, subUpper;
181 for (
auto variableBound : this->lowerBoundaries) {
182 VariableType variable = variableBound.first;
183 auto vertexEntry = vertex.find(variable);
184 if (vertexEntry != vertex.end()) {
185 auto splittingPointEntry = splittingPoint.find(variable);
186 subLower.insert(
typename Valuation::value_type(variable, std::min(vertexEntry->second, splittingPointEntry->second)));
187 subUpper.insert(
typename Valuation::value_type(variable, std::max(vertexEntry->second, splittingPointEntry->second)));
189 subLower.insert(
typename Valuation::value_type(variable, getLowerBoundary(variable)));
190 subUpper.insert(
typename Valuation::value_type(variable, getUpperBoundary(variable)));
194 ParameterRegion<ParametricType> subRegion(std::move(subLower), std::move(subUpper));
197 regionVector.push_back(std::move(subRegion));
202template<
typename ParametricType>
204 std::stringstream regionstringstream;
205 if (boundariesAsDouble) {
206 for (
auto var : this->getVariables()) {
207 regionstringstream << storm::utility::convertNumber<double>(this->getLowerBoundary(var));
208 regionstringstream <<
"<=";
209 regionstringstream << var;
210 regionstringstream <<
"<=";
211 regionstringstream << storm::utility::convertNumber<double>(this->getUpperBoundary(var));
212 regionstringstream <<
",";
215 for (
auto var : this->getVariables()) {
216 regionstringstream << this->getLowerBoundary(var);
217 regionstringstream <<
"<=";
218 regionstringstream << var;
219 regionstringstream <<
"<=";
220 regionstringstream << this->getUpperBoundary(var);
221 regionstringstream <<
",";
224 std::string regionstring = regionstringstream.str();
226 regionstring = regionstring.substr(0, regionstring.length() - 1) +
";";
230template<
typename ParametricType>
232 auto varsRegion = getVariables();
234 for (
auto var : varsRegion) {
235 if (std::find(varsSubRegion.begin(), varsSubRegion.end(), var) != varsSubRegion.end()) {
236 if (getLowerBoundary(var) > subRegion.
getLowerBoundary(var) || getUpperBoundary(var) < getUpperBoundary(var)) {
246template<
typename ParametricType>
249 auto val = this->getCenterPoint();
253 val[monResEntry.first] =
storm::solver::minimize(dir) ? getLowerBoundary(monResEntry.first) : getUpperBoundary(monResEntry.first);
255 val[monResEntry.first] =
storm::solver::maximize(dir) ? getLowerBoundary(monResEntry.first) : getUpperBoundary(monResEntry.first);
262template<
typename ParametricType>
264 std::set<VariableType>
const& monIncrParameters,
265 std::set<VariableType>
const& monDecrParameters)
const {
266 auto val = this->getCenterPoint();
267 for (
auto var : monIncrParameters) {
270 for (
auto var : monDecrParameters) {
277template<
typename ParametricType>
282template<
typename ParametricType>
287template<
typename ParametricType>
293#ifdef STORM_HAVE_CARL
294template class ParameterRegion<storm::RationalFunction>;
295template std::ostream&
operator<<(std::ostream& out, ParameterRegion<storm::RationalFunction>
const& region);
std::map< VariableType, Monotonicity > getMonotonicityResult() const
Returns the results so far.
bool isDoneForVar(VariableType) const
storm::utility::parametric::CoefficientType< ParametricType >::type CoefficientType
std::set< VariableType > const & getVariables() const
Valuation getCenterPoint() const
Returns the center point of this region.
CoefficientType area() const
Returns the area of this region.
void setBoundParent(CoefficientType bound)
std::string toString(bool boundariesAsDouble=false) const
storm::utility::parametric::Valuation< ParametricType > Valuation
Valuation const & getLowerBoundaries() const
CoefficientType getDifference(const std::string varName) const
storm::utility::parametric::VariableType< ParametricType >::type VariableType
Valuation getPoint(storm::solver::OptimizationDirection dir, storm::analysis::MonotonicityResult< VariableType > &monRes) const
CoefficientType const & getLowerBoundary(VariableType const &variable) const
CoefficientType getBoundParent()
void split(Valuation const &splittingPoint, std::vector< ParameterRegion< ParametricType > > ®ionVector) const
Splits the region at the given point and inserts the resulting subregions at the end of the given vec...
bool isSubRegion(ParameterRegion< ParametricType > region)
CoefficientType const & getUpperBoundary(VariableType const &variable) const
Valuation getSomePoint() const
Returns some point that lies within this region.
Valuation const & getUpperBoundaries() const
std::multimap< CoefficientType, VariableType > const & getVariablesSorted() const
std::vector< Valuation > getVerticesOfRegion(std::set< VariableType > const &consideredVariables) const
Returns a vector of all possible combinations of lower and upper bounds of the given variables.
#define STORM_LOG_THROW(cond, exception, message)
bool constexpr maximize(OptimizationDirection d)
bool constexpr minimize(OptimizationDirection d)
std::ostream & operator<<(std::ostream &out, ParameterRegion< ParametricType > const ®ion)
bool isZero(ValueType const &a)