TimQu
7 years ago
3 changed files with 65 additions and 15 deletions
-
23src/storm/modelchecker/multiobjective/constraintbased/SparseCbAchievabilityQuery.cpp
-
29src/storm/utility/ExpressionHelper.cpp
-
28src/storm/utility/ExpressionHelper.h
@ -0,0 +1,29 @@ |
|||
#include "storm/utility/ExpressionHelper.h"
|
|||
#include "storm/utility/constants.h"
|
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
ExpressionHelper::ExpressionHelper(std::shared_ptr<storm::expressions::ExpressionManager> const& expressionManager) : manager(expressionManager) { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
storm::expressions::Expression ExpressionHelper::sum(std::vector<storm::expressions::Expression>&& summands) const { |
|||
if (summands.empty()) { |
|||
return manager->rational(storm::utility::zero<storm::RationalNumber>()); |
|||
} |
|||
// As the sum can potentially have many summands, we want to make sure that the formula tree is (roughly balanced)
|
|||
auto it = summands.begin(); |
|||
while (summands.size() > 1) { |
|||
if (it == summands.end() || it == summands.end() - 1) { |
|||
it = summands.begin(); |
|||
} |
|||
*it = *it + summands.back(); |
|||
summands.pop_back(); |
|||
++it; |
|||
} |
|||
return summands.front(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
#pragma once |
|||
|
|||
#include <vector> |
|||
#include <memory> |
|||
#include "storm/storage/expressions/Expression.h" |
|||
#include "storm/storage/expressions/ExpressionManager.h" |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
class ExpressionHelper { |
|||
|
|||
public: |
|||
ExpressionHelper(std::shared_ptr<storm::expressions::ExpressionManager> const& expressionManager); |
|||
|
|||
/*! |
|||
* Creates an expression that is the sum over all the given summands. |
|||
*/ |
|||
storm::expressions::Expression sum(std::vector<storm::expressions::Expression>&& summands) const; |
|||
|
|||
private: |
|||
|
|||
std::shared_ptr<storm::expressions::ExpressionManager> manager; |
|||
}; |
|||
|
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue