Browse Source
Further step towards refactored ExplicitModelAdapter.
Further step towards refactored ExplicitModelAdapter.
Former-commit-id: 8abc07a366
tempestpy_adaptions
dehnert
11 years ago
16 changed files with 445 additions and 221 deletions
-
295src/adapters/ExplicitModelAdapter.h
-
8src/models/AbstractDeterministicModel.h
-
8src/models/AbstractModel.h
-
8src/models/AbstractNondeterministicModel.h
-
7src/models/AtomicPropositionsLabeling.h
-
4src/models/Ctmc.h
-
4src/models/Ctmdp.h
-
4src/models/Dtmc.h
-
4src/models/Mdp.h
-
4src/parser/DeterministicModelParser.cpp
-
4src/parser/NondeterministicModelParser.cpp
-
2src/storage/BitVector.h
-
79src/storage/LabeledProbabilities.h
-
180src/storage/LabeledValues.h
-
4src/storm.cpp
-
51src/utility/ConstTemplates.h
@ -1,79 +0,0 @@ |
|||
/* |
|||
* LabeledProbabilities.h |
|||
* |
|||
* Created on: 26.09.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_STORAGE_LABELEDPROBABILITIES_H |
|||
#define STORM_STORAGE_LABELEDPROBABILITIES_H |
|||
|
|||
namespace storm { |
|||
namespace storage { |
|||
|
|||
// This class provides the functionality to store a list of probabilities, each of which is labeled with a list |
|||
// of labels. |
|||
template<class Container, class ValueType> |
|||
class LabeledProbabilities { |
|||
public: |
|||
/*! |
|||
* Default-constructs an empty object. |
|||
*/ |
|||
LabeledProbabilities() : probabilityLabelList() { |
|||
// Intentionally left empty. |
|||
} |
|||
|
|||
/*! |
|||
* Adds a probability to the list of labeled probabilities. |
|||
* |
|||
* @return A reference to the list of labels that is associated with the given probability. |
|||
*/ |
|||
Container<uint_fast64_t>& addProbability(ValueType probability) { |
|||
probabilityLabelList.emplace_back(probability, Container<uint_fast64_t>()); |
|||
return probabilityLabelList.back().second; |
|||
} |
|||
|
|||
/*! |
|||
* Returns an iterator pointing to the first labeled probability. |
|||
* |
|||
* @return An iterator pointing to the first labeled probability. |
|||
*/ |
|||
Container<std::pair<ValueType, Container<uint_fast64_t>>>::iterator begin() { |
|||
return probabilityLabelList.begin(); |
|||
} |
|||
|
|||
/*! |
|||
* Returns an iterator pointing past the last labeled probability. |
|||
* |
|||
* @return An iterator pointing past the last labeled probability. |
|||
*/ |
|||
Container<std::pair<ValueType, Container<uint_fast64_t>>>::const_iterator end() { |
|||
return probabilityLabelList.end(); |
|||
} |
|||
|
|||
/*! |
|||
* Returns a const iterator pointing to the first labeled probability. |
|||
* |
|||
* @return A const iterator pointing to the first labeled probability. |
|||
*/ |
|||
Container<std::pair<ValueType, Container<uint_fast64_t>>>::const_iterator begin() const { |
|||
return probabilityLabelList.begin(); |
|||
} |
|||
|
|||
/*! |
|||
* Returns a const iterator pointing past the last labeled probability. |
|||
* |
|||
* @return A const iterator pointing past the last labeled probability. |
|||
*/ |
|||
Container<std::pair<ValueType, Container<uint_fast64_t>>>::const_iterator end() const { |
|||
return probabilityLabelList.end(); |
|||
} |
|||
|
|||
private: |
|||
// The actual storage used to store the list of probabilities and the associated labels. |
|||
Container<std::pair<ValueType, Container<uint_fast64_t>>> probabilityLabelList; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_LABELEDPROBABILITIES_H */ |
@ -0,0 +1,180 @@ |
|||
/* |
|||
* LabeledValues.h |
|||
* |
|||
* Created on: 26.09.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_STORAGE_LABELEDVALUES_H |
|||
#define STORM_STORAGE_LABELEDVALUES_H |
|||
|
|||
#include <list> |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
template<class ValueType> |
|||
static ValueType constGetZero(); |
|||
} |
|||
|
|||
namespace storage { |
|||
// This class provides the functionality to store a list of values, each of which is labeled with possibly several |
|||
// labels. |
|||
template<class ValueType> |
|||
class LabeledValues { |
|||
public: |
|||
/*! |
|||
* Default-constructs an empty object. |
|||
*/ |
|||
LabeledValues() : valueLabelList() { |
|||
// Intentionally left empty. |
|||
} |
|||
|
|||
/*! |
|||
* Constructs an object that stores the single probability value without any label. |
|||
* |
|||
* @param value The probability to sto |
|||
*/ |
|||
LabeledValues(ValueType value) : valueLabelList() { |
|||
addValue(value); |
|||
} |
|||
|
|||
/*! |
|||
* Adds an (unlabeled) value to the list of labeled values. |
|||
* |
|||
* @param value The value to add. |
|||
* @return A reference to the list of labels that is associated with the given value. |
|||
*/ |
|||
std::set<uint_fast64_t>& addValue(ValueType value) { |
|||
valueLabelList.emplace_back(value, std::set<uint_fast64_t>()); |
|||
return valueLabelList.back().second; |
|||
} |
|||
|
|||
/*! |
|||
* Adds a labeled value to the list of labeled values. |
|||
* |
|||
* @param value The value to add. |
|||
* @param labels The labels to associate with this value. |
|||
* @return A reference to the list of labels that is associated with the given value. |
|||
*/ |
|||
std::set<uint_fast64_t>& addValue(ValueType value, std::set<uint_fast64_t> const& labels) { |
|||
valueLabelList.emplace_back(value, labels); |
|||
return valueLabelList.back().second; |
|||
} |
|||
|
|||
/*! |
|||
* Returns an iterator pointing to the first labeled probability. |
|||
* |
|||
* @return An iterator pointing to the first labeled probability. |
|||
*/ |
|||
typename std::list<std::pair<ValueType, std::set<uint_fast64_t>>>::iterator begin() { |
|||
return valueLabelList.begin(); |
|||
} |
|||
|
|||
/*! |
|||
* Returns an iterator pointing past the last labeled probability. |
|||
* |
|||
* @return An iterator pointing past the last labeled probability. |
|||
*/ |
|||
typename std::list<std::pair<ValueType, std::set<uint_fast64_t>>>::const_iterator end() { |
|||
return valueLabelList.end(); |
|||
} |
|||
|
|||
/*! |
|||
* Returns a const iterator pointing to the first labeled probability. |
|||
* |
|||
* @return A const iterator pointing to the first labeled probability. |
|||
*/ |
|||
typename std::list<std::pair<ValueType, std::set<uint_fast64_t>>>::const_iterator begin() const { |
|||
return valueLabelList.begin(); |
|||
} |
|||
|
|||
/*! |
|||
* Returns a const iterator pointing past the last labeled probability. |
|||
* |
|||
* @return A const iterator pointing past the last labeled probability. |
|||
*/ |
|||
typename std::list<std::pair<ValueType, std::set<uint_fast64_t>>>::const_iterator end() const { |
|||
return valueLabelList.end(); |
|||
} |
|||
|
|||
/*! |
|||
* Inserts the contents of this object to the given output stream. |
|||
* |
|||
* @param out The stream in which to insert the contents. |
|||
*/ |
|||
friend std::ostream& operator<<(std::ostream& out, LabeledValues const& labeledValues) { |
|||
out << "["; |
|||
for (auto const& element : labeledValues) { |
|||
out << element.first << "("; |
|||
for (auto const& label : element.second) { |
|||
out << label << ", "; |
|||
} |
|||
out << ")"; |
|||
} |
|||
out << "]"; |
|||
return out; |
|||
} |
|||
|
|||
/*! |
|||
* Adds all labeled probabilities of the given object to the current one. |
|||
* |
|||
* @param labeledProbabilities The labeled probabilities to add to the object. |
|||
*/ |
|||
LabeledValues<ValueType>& operator+=(LabeledValues<ValueType> const& labeledValues) { |
|||
for (auto const& valueLabelListPair : labeledValues) { |
|||
this->valueLabelList.push_back(valueLabelListPair); |
|||
} |
|||
return *this; |
|||
} |
|||
|
|||
/*! |
|||
* Converts the object into the value type by returning the sum. |
|||
* |
|||
* @return The sum of the values. |
|||
*/ |
|||
operator ValueType() const { |
|||
return this->getSum(); |
|||
} |
|||
|
|||
/*! |
|||
* Retrieves the number of separate entries in this object. |
|||
* |
|||
* @return The number of separate entries in this object. |
|||
*/ |
|||
size_t size() const { |
|||
return this->valueLabelList.size(); |
|||
} |
|||
|
|||
private: |
|||
// The actual storage used to store the list of values and the associated labels. |
|||
std::list<std::pair<ValueType, std::set<uint_fast64_t>>> valueLabelList; |
|||
|
|||
/*! |
|||
* Returns the sum of the values. |
|||
* |
|||
* @return The sum of the values. |
|||
*/ |
|||
ValueType getSum() const { |
|||
ValueType sum = storm::utility::constGetZero<ValueType>(); |
|||
for (auto const& valueLabelListPair : *this) { |
|||
sum += valueLabelListPair.first; |
|||
} |
|||
return sum; |
|||
} |
|||
}; |
|||
|
|||
/*! |
|||
* Computes the hash value of a given labeled probabilities object. |
|||
* |
|||
* @param labeledProbabilities The labeled probabilities object for which to compute the hash value. |
|||
* @return A hash value for the labeled probabilities object. |
|||
*/ |
|||
template<typename ValueType> |
|||
std::size_t hash_value(LabeledValues<ValueType> const& labeledValues) { |
|||
return labeledValues.size(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_LABELEDVALUES_H */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue