Browse Source

Clean up

tempestpy_adaptions
Jip Spel 6 years ago
parent
commit
1364ec8729
  1. 16
      src/storm-pars-cli/storm-pars.cpp
  2. 32
      src/storm-pars/analysis/Lattice.cpp
  3. 4
      src/storm-pars/analysis/Lattice.h

16
src/storm-pars-cli/storm-pars.cpp

@ -511,12 +511,11 @@ namespace storm {
}
stateVector.push_back(state);
}
// Start creating the Lattice
storm::analysis::Lattice *lattice = new storm::analysis::Lattice(topStates, bottomStates, numberOfStates);
storm::storage::BitVector oldStates(numberOfStates);
// Create a copy of the states already present in the lattice.
storm::storage::BitVector seenStates = topStates|=bottomStates;
storm::storage::BitVector seenStates = topStates|= bottomStates;
while (oldStates != seenStates) {
// As long as new states are added to the lattice, continue.
@ -530,19 +529,13 @@ namespace storm {
&& seenStates[currentState->successor1]
&& seenStates[currentState->successor2]) {
// Check if the current state number has not been added, but its successors have been added.
if (currentState->successor1 == currentState->successor2) {
// If there is only one successor, the state should be added to the same Node as its successor
lattice->addToNode(currentState->stateNumber, lattice->getNode(currentState->successor1));
// Add stateNumber to the set with seen states.
seenStates.set(currentState->stateNumber);
} else {
// Otherwise, check how the two states compare, and add if the comparison is possible.
uint_fast64_t successor1 = currentState->successor1;
uint_fast64_t successor2 = currentState->successor2;
int compareResult = lattice->compare(successor1, successor2);
if (compareResult == 1 || compareResult == 2) {
// getNode will not return nullptr, as compare already checked this
if (compareResult == 2) {
// swap
auto temp = successor1;
@ -552,6 +545,7 @@ namespace storm {
// Additional check, if states have the same probability of reaching a given next state,
// then they should be at the same node
// TODO: can this be removed, e.g. adding a step to preprocessing, making this superfluous
// TODO: 1 prob. and same probs to same states should be removed from matrix
storm::analysis::Lattice::Node *above = lattice->getNode(successor1);
storm::analysis::Lattice::Node *below = lattice->getNode(successor2);
std::vector<storm::analysis::Lattice::Node *> states1 = above->below;
@ -588,7 +582,7 @@ namespace storm {
// TODO: what to do?
STORM_LOG_DEBUG("Failed to add" << currentState->stateNumber << "\n");
}
}
}
}
}

32
src/storm-pars/analysis/Lattice.cpp

@ -39,6 +39,7 @@ namespace storm {
Node *node1 = getNode(state1);
Node *node2 = getNode(state2);
if (node1 != nullptr && node2 != nullptr) {
if (node1 == node2) {
return 0;
}
@ -47,15 +48,15 @@ namespace storm {
return 1;
}
if (below(node1, node2)) {
if (above(node2, node1)) {
return 2;
}
}
return -1;
}
Lattice::Node *Lattice::getNode(uint_fast64_t stateNumber) {
// TODO: might return nullptr, what to do with it?
Node *node;
for (auto itr = nodes.begin(); itr != nodes.end(); ++itr) {
storm::storage::BitVector states = (*itr)->states;
@ -122,37 +123,14 @@ namespace storm {
}
bool Lattice::above(Node *node1, Node *node2) {
if (node1->below.empty()) {
return false;
}
if (std::find(node1->below.begin(), node1->below.end(), node2) != node1->below.end()) {
return true;
}
bool result = !node1->below.empty() && std::find(node1->below.begin(), node1->below.end(), node2) != node1->below.end();
bool result = false;
for (auto itr = node1->below.begin(); node1->below.end() != itr; ++itr) {
for (auto itr = node1->below.begin(); !result && node1->below.end() != itr; ++itr) {
result |= above(*itr, node2);
}
return result;
}
bool Lattice::below(Node *node1, Node *node2) {
if (node1->above.empty()) {
return false;
}
if (std::find(node1->above.begin(), node1->above.end(), node2) != node1->above.end()) {
return true;
}
bool result = false;
for (auto itr = node1->above.begin(); node1->above.end() != itr; ++itr) {
result |= below(*itr, node2);
}
return result;
}
void Lattice::remove(std::vector<Node *> *nodes, Node *node) {
auto index = std::find(nodes->begin(), nodes->end(), node);
if (index != nodes->end()) {

4
src/storm-pars/analysis/Lattice.h

@ -63,7 +63,7 @@ namespace storm {
*
* @param state The number of the state.
*
* @return The pointer to the node of the state.
* @return The pointer to the node of the state, nullptr if the node does not exist
*/
Node *getNode(uint_fast64_t state);
@ -83,8 +83,6 @@ namespace storm {
bool above(Node *, Node *);
bool below(Node *, Node *);
void remove(std::vector<Node *> *nodes, Node *node);
void setStates(std::vector<uint_fast64_t> states, Node *node);

Loading…
Cancel
Save