|
|
@ -8,17 +8,28 @@ namespace storm { |
|
|
|
namespace analysis { |
|
|
|
Lattice::Lattice(storm::storage::BitVector topStates, |
|
|
|
storm::storage::BitVector bottomStates, uint_fast64_t numberOfStates) { |
|
|
|
|
|
|
|
Node *top = new Node(); |
|
|
|
top->states = topStates; |
|
|
|
Node *bottom = new Node(); |
|
|
|
bottom->states = bottomStates; |
|
|
|
top->below.push_back(bottom); |
|
|
|
bottom->above.push_back(top); |
|
|
|
nodes = std::vector<Node *>({top, bottom}); |
|
|
|
|
|
|
|
nodes = std::vector<Node *>(numberOfStates); |
|
|
|
for (auto i = topStates.getNextSetIndex(0); i < numberOfStates; i = topStates.getNextSetIndex(i+1)) { |
|
|
|
nodes.at(i) = top; |
|
|
|
|
|
|
|
} |
|
|
|
for (auto i = bottomStates.getNextSetIndex(0); i < numberOfStates; i = bottomStates.getNextSetIndex(i+1)) { |
|
|
|
nodes.at(i) = bottom; |
|
|
|
} |
|
|
|
this->numberOfStates = numberOfStates; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void Lattice::addBetween(uint_fast64_t state, Node *above, Node *below) { |
|
|
|
std::cout << "Adding: " << state << std::endl; |
|
|
|
Node *newNode = new Node(); |
|
|
|
newNode->states = storm::storage::BitVector(numberOfStates); |
|
|
|
newNode->states.set(state); |
|
|
@ -28,11 +39,12 @@ namespace storm { |
|
|
|
remove(&(above->below), below); |
|
|
|
(below->above).push_back(newNode); |
|
|
|
above->below.push_back(newNode); |
|
|
|
nodes.push_back(newNode); |
|
|
|
nodes.at(state) = newNode; |
|
|
|
} |
|
|
|
|
|
|
|
void Lattice::addToNode(uint_fast64_t state, Node *node) { |
|
|
|
node->states.set(state); |
|
|
|
nodes.at(state) = node; |
|
|
|
} |
|
|
|
|
|
|
|
int Lattice::compare(uint_fast64_t state1, uint_fast64_t state2) { |
|
|
@ -57,18 +69,16 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
Lattice::Node *Lattice::getNode(uint_fast64_t stateNumber) { |
|
|
|
Node *node; |
|
|
|
for (auto itr = nodes.begin(); itr != nodes.end(); ++itr) { |
|
|
|
storm::storage::BitVector states = (*itr)->states; |
|
|
|
|
|
|
|
if (states[stateNumber]) return (*itr); |
|
|
|
} |
|
|
|
return node; |
|
|
|
return nodes.at(stateNumber); |
|
|
|
} |
|
|
|
|
|
|
|
void Lattice::toString(std::ostream &out) { |
|
|
|
std::vector<Node*> printedNodes = std::vector<Node*>({}); |
|
|
|
for (auto itr = nodes.begin(); itr != nodes.end(); ++itr) { |
|
|
|
|
|
|
|
if (std::find(printedNodes.begin(), printedNodes.end(), (*itr)) == printedNodes.end()) { |
|
|
|
Node *node = *itr; |
|
|
|
printedNodes.push_back(*itr); |
|
|
|
out << "Node: {"; |
|
|
|
uint_fast64_t index = node->states.getNextSetIndex(0); |
|
|
|
while (index < numberOfStates) { |
|
|
@ -121,6 +131,7 @@ namespace storm { |
|
|
|
out << "}" << "\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bool Lattice::above(Node *node1, Node *node2) { |
|
|
|
bool result = !node1->below.empty() && std::find(node1->below.begin(), node1->below.end(), node2) != node1->below.end(); |
|
|
|