2
#include "CTL/DependencyGraph/Configuration.h"
3
#include "CTL/SearchStrategy/SearchStrategy.h"
8
namespace SearchStrategy{
10
bool SearchStrategy::empty() const
12
return Wsize() == 0 && N.empty() && D.empty();
15
void SearchStrategy::pushNegation(DependencyGraph::Edge* edge)
20
bool hasCZero = false;
22
for (DependencyGraph::Configuration *c : edge->targets) {
23
if (c->assignment == DependencyGraph::Assignment::CZERO) {
27
if (c->assignment != DependencyGraph::Assignment::ONE) {
32
if(allOne || hasCZero)
42
void SearchStrategy::pushEdge(DependencyGraph::Edge *edge)
44
if(edge->status > 0 || edge->source->isDone()) return;
45
if(edge->processed && edge->is_negated)
55
void SearchStrategy::pushDependency(DependencyGraph::Edge* edge)
57
if(edge->source->isDone()) return;
63
DependencyGraph::Edge* SearchStrategy::popEdge(bool saturate)
65
if(saturate && D.empty()) return nullptr;
67
if (Wsize() == 0 && D.empty()) {
71
auto edge = D.empty() ? popFromW() : D.back();
76
assert(edge->refcnt >= 0);
82
uint32_t SearchStrategy::maxDistance() const
85
for(DependencyGraph::Edge* e : N)
87
if(!e->source->isDone())
88
m = std::max(m, e->source->getDistance());
93
bool SearchStrategy::available() const
95
return Wsize() > 0 || !D.empty();
98
void SearchStrategy::releaseNegationEdges(uint32_t dist)
100
for(auto it = N.begin(); it != N.end(); ++it)
103
if((*it)->source->getDistance() >= dist || (*it)->source->isDone())
107
if(N.empty() || it == N.end()) break;
112
bool SearchStrategy::trivialNegation()
114
for(auto it = N.begin(); it != N.end(); ++it)
117
bool hasCZero = false;
119
for (DependencyGraph::Configuration *c : e->targets) {
120
if (c->assignment == DependencyGraph::Assignment::CZERO) {
124
if (c->assignment != DependencyGraph::Assignment::ONE) {
129
if(allOne || hasCZero)
133
if(N.empty() || it == N.end()) break;