Commit 48b4f102 authored by ehebrard's avatar ehebrard
Browse files

pas si mal

parent 7e452765
......@@ -240,6 +240,8 @@ void Graph::resize(const int n) {
vertices.reserve(n);
vertices.fill_back();
// buffer.resize(n);
// cout << "before resize " << edges << endl;
......@@ -265,10 +267,20 @@ size_t Graph::indegree(const int u) const { return neighbor[IN][u].size(); }
//
void Graph::merge(const int u, const int v) {
#ifdef DEBUG_SG
// cout << *this << endl;
verify("before merge");
#endif
// cout << endl
// << *this << "\n"
// << "merge " << v << " to " << u << " (" << size() << ")" << endl;
// cout
// //<< *this << "\n"
// << "merge " << v << " to " << u << endl;
assert(vertices.has(v));
assert(vertices.has(u));
removeVertex(v);
......@@ -332,6 +344,11 @@ void Graph::merge(const int u, const int v) {
}
}
#ifdef DEBUG_SG
// cout << *this << endl;
verify("after merge");
#endif
// cout << vertices << endl;
}
......@@ -402,60 +419,46 @@ ostream &Graph::display(ostream &os) const {
void Graph::verify(const char *msg) {
// cout << msg << endl ;
// cout << "beg verif " << msg << endl ;
for (auto l{OUT}; l <= IN; ++l) {
int count = 0;
for (auto x : vertices) {
int rank = 0;
// if(x==188)
// cout << "verif " << x << endl;
//
// int rank = 0;
for (auto ith{0}; ith < neighbor[l][x].size(); ++ith) {
auto y{neighbor[l][x][ith]};
if (y == x) {
cout << msg << ": error, there is a loop on " << x << endl;
exit(1);
}
if (l == OUT)
// if(not edges.has(x,y)) {
// cout << msg << ": error, edge (" << x << "," << y << ")
// is not in edge set"
// << endl << *this << endl;
//
// cout << edges << endl;
//
// exit(1);
// }
auto jth{neighbor_rank[l][x][ith]};
auto jth{neighbor_rank[l][x][ith]};
// if(x==188)
// cout << ith << ": " << y << " (" << jth << " ==> " << neighbor[1 - l][y][jth] << "/" << neighbor_rank[1 - l][y][jth] << ")" << endl;
//
if (neighbor_rank[1 - l][y][jth] != ith or
neighbor[1 - l][y][jth] != x) {
cout << msg << ": error on " << x << " " << y << "\n"
<< *this << endl;
exit(1);
}
// else {
// cout << "ok " << x << " " << y << "\n";
// }
++rank;
// ++rank;
}
count += rank;
count += neighbor[l][x].size();
}
assert(count == arcCount());
// if(count != edges.count()) {
// cout << msg << ": error, too many edges in edgeset"
// << endl << *this << endl;
// for(auto u{0}; u<size(); ++u) {
// for(auto v{0}; v<size(); ++v) {
// if(edges.has(u,v))
// cout << " (" << u << "," << v << ")";
// }
// cout << endl;
// }
// }
}
// cout << "end verif " << msg << endl ;
}
#endif
......
......@@ -19,7 +19,7 @@ namespace schedcl {
// #define TRACE 7
#define DEBUG_MERGE
// #define DEBUG_MERGE
// #define DEBUG_FLAG (num_literals >= 152)
// #define QUEUE_FLAG (scheduler.num_literals >= 152)
// #define CONSTRAINT_FLAG true
......
......@@ -454,10 +454,10 @@ template <typename T> void Scheduler<T>::fail(Explanation e) {
}
#endif
analyzeConflict(e);
++num_fails;
queue.clear();
// analyzeConflict(e);
//
// ++num_fails;
// queue.clear();
throw Failure();
}
......@@ -540,7 +540,7 @@ template <typename T> ostream &Scheduler<T>::displayStats(ostream &os) const {
// << " updates=" << setw(10) << left << num_updates
<< " literals=" << setw(12) << left << num_literals
<< " prunings=" << setw(8) << left << num_prunings << " graph=" << setw(5)
<< right << distance.arcCount() << " cpu=" << (cpu_time() - start_time)
<< left << distance.arcCount() << " cpu=" << (cpu_time() - start_time)
<< "\n";
#else
os << endl;
......@@ -693,6 +693,11 @@ template <typename T> void Scheduler<T>::search() {
}
} catch (const Failure &f) {
// analyzeConflict(e);
++num_fails;
queue.clear();
try {
backtrack();
......@@ -769,41 +774,46 @@ void Scheduler<T>::updateNetwork(vector<event>::const_iterator first) {
auto to_merge{getVariable(merged_event, other_event)};
if (to_merge != NoVar) {
if (to_merge != NoVar and constraint_network.has(to_merge)) {
auto rep_other{distance.getRepresentant(other_event)};
auto the_rep{getVariable(rep_event, rep_other)};
if (rep_event != rep_other) {
#ifdef DEBUG_MERGE
cout << " -> merge (" << label(merged_event) << ","
<< label(other_event) << ") to (" << label(rep_event) << ","
<< label(rep_other) << ")";
#endif
if (the_rep == NoVar) {
declareVariable(rep_event, rep_other);
the_rep = getVariable(rep_event, rep_other);
}
#ifdef DEBUG_MERGE
cout << " -> merge (" << to_merge <<": " << label(merged_event) << ","
<< label(other_event) << ") to (" << the_rep << ": " << label(rep_event) << ","
<< label(rep_other) << ")";
#endif
constraint_network.merge(the_rep, to_merge);
}
}
to_merge = getVariable(other_event, merged_event);
if (to_merge != NoVar) {
if (to_merge != NoVar and constraint_network.has(to_merge)) {
auto rep_other{distance.getRepresentant(other_event)};
auto the_rep{getVariable(rep_other, rep_event)};
if (rep_event != rep_other) {
cout << " -> merge (" << label(other_event) << ","
<< label(merged_event) << ") to (" << label(rep_other) << ","
<< label(rep_event) << ")";
if (the_rep == NoVar) {
declareVariable(rep_other, rep_event);
the_rep = getVariable(rep_other, rep_event);
}
#ifdef DEBUG_MERGE
cout << " -> merge (" << to_merge << ": " << label(other_event) << ","
<< label(merged_event) << ") to (" << the_rep << ": " << label(rep_other) << ","
<< label(rep_event) << ")";
#endif
constraint_network.merge(the_rep, to_merge);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment