Commit 15329c56 authored by Denis Poitrenaud's avatar Denis Poitrenaud
Browse files

* src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh,

src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh,
src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.hh,
src/tgbaalgos/tau03opt.cc: Fix comments and debug traces

* src/tgbatest/randtgba.cc: Adjust names of algorithms.
parent 2143d6c4
2004-11-25 Denis Poitrenaud <Denis.Poitrenaud@lip6.fr>
* src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh,
src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh,
src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.hh,
src/tgbaalgos/tau03opt.cc: Fix comments and debug traces
* src/tgbatest/randtgba.cc: Adjust names of algorithms.
2004-11-25 Alexandre Duret-Lutz <adl@src.lip6.fr> 2004-11-25 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbatest/randtgba.cc: Add option -D. * src/tgbatest/randtgba.cc: Add option -D.
......
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
//#define TRACE //#define TRACE
#ifdef TRACE
#include <iostream> #include <iostream>
#ifdef TRACE
#define trace std::cerr
#else
#define trace while (0) std::cerr
#endif #endif
#include <cassert> #include <cassert>
...@@ -178,17 +181,12 @@ namespace spot ...@@ -178,17 +181,12 @@ namespace spot
while (!st_blue.empty()) while (!st_blue.empty())
{ {
stack_item& f = st_blue.front(); stack_item& f = st_blue.front();
# ifdef TRACE trace << "DFS_BLUE treats: " << a_->format_state(f.s) << std::endl;
std::cout << "DFS_BLUE treats: "
<< a_->format_state(f.s) << std::endl;
# endif
if (!f.it->done()) if (!f.it->done())
{ {
const state *s_prime = f.it->current_state(); const state *s_prime = f.it->current_state();
# ifdef TRACE trace << " Visit the successor: "
std::cout << " Visit the successor: " << a_->format_state(s_prime) << std::endl;
<< a_->format_state(s_prime) << std::endl;
# endif
bdd label = f.it->current_condition(); bdd label = f.it->current_condition();
bdd acc = f.it->current_acceptance_conditions(); bdd acc = f.it->current_acceptance_conditions();
// Go down the edge (f.s, <label, acc>, s_prime) // Go down the edge (f.s, <label, acc>, s_prime)
...@@ -197,9 +195,7 @@ namespace spot ...@@ -197,9 +195,7 @@ namespace spot
typename heap::color_ref c = h.get_color_ref(s_prime); typename heap::color_ref c = h.get_color_ref(s_prime);
if (c.is_white()) if (c.is_white())
{ {
# ifdef TRACE trace << " It is white, go down" << std::endl;
std::cout << " It is white, go down" << std::endl;
# endif
inc_states(); inc_states();
h.add_new_state(s_prime, BLUE); h.add_new_state(s_prime, BLUE);
push(st_blue, s_prime, label, acc); push(st_blue, s_prime, label, acc);
...@@ -212,10 +208,8 @@ namespace spot ...@@ -212,10 +208,8 @@ namespace spot
// the number of runs reported by successive // the number of runs reported by successive
// calls to the check method. Without this // calls to the check method. Without this
// functionnality, the test can be ommited. // functionnality, the test can be ommited.
# ifdef TRACE trace << " It is blue and the arc is "
std::cout << " It is blue and the arc is " << "accepting, start a red dfs" << std::endl;
<< "accepting, start a red dfs" << std::endl;
# endif
target = f.s; target = f.s;
c.set_color(RED); c.set_color(RED);
push(st_red, s_prime, label, acc); push(st_red, s_prime, label, acc);
...@@ -224,9 +218,7 @@ namespace spot ...@@ -224,9 +218,7 @@ namespace spot
} }
else else
{ {
# ifdef TRACE trace << " It is blue or red, pop it" << std::endl;
std::cout << " It is blue or red, pop it" << std::endl;
# endif
h.pop_notify(s_prime); h.pop_notify(s_prime);
} }
} }
...@@ -235,10 +227,7 @@ namespace spot ...@@ -235,10 +227,7 @@ namespace spot
// Backtrack the edge // Backtrack the edge
// (predecessor of f.s in st_blue, <f.label, f.acc>, f.s) // (predecessor of f.s in st_blue, <f.label, f.acc>, f.s)
{ {
# ifdef TRACE trace << " All the successors have been visited" << std::endl;
std::cout << " All the successors have been visited"
<< std::endl;
# endif
stack_item f_dest(f); stack_item f_dest(f);
pop(st_blue); pop(st_blue);
typename heap::color_ref c = h.get_color_ref(f_dest.s); typename heap::color_ref c = h.get_color_ref(f_dest.s);
...@@ -250,12 +239,10 @@ namespace spot ...@@ -250,12 +239,10 @@ namespace spot
// the number of runs reported by successive // the number of runs reported by successive
// calls to the check method. Without this // calls to the check method. Without this
// functionnality, the test can be ommited. // functionnality, the test can be ommited.
# ifdef TRACE trace << " It is blue and the arc from "
std::cout << " It is blue and the arc from " << a_->format_state(st_blue.front().s)
<< a_->format_state(st_blue.front().s) << " to it is accepting, start a red dfs"
<< " to it is accepting, start a red dfs" << std::endl;
<< std::endl;
# endif
target = st_blue.front().s; target = st_blue.front().s;
c.set_color(RED); c.set_color(RED);
push(st_red, f_dest.s, f_dest.label, f_dest.acc); push(st_red, f_dest.s, f_dest.label, f_dest.acc);
...@@ -264,10 +251,7 @@ namespace spot ...@@ -264,10 +251,7 @@ namespace spot
} }
else else
{ {
# ifdef TRACE trace << " Pop it" << std::endl;
std::cout << " Pop it"
<< std::endl;
# endif
h.pop_notify(f_dest.s); h.pop_notify(f_dest.s);
} }
} }
...@@ -284,17 +268,12 @@ namespace spot ...@@ -284,17 +268,12 @@ namespace spot
while (!st_red.empty()) while (!st_red.empty())
{ {
stack_item& f = st_red.front(); stack_item& f = st_red.front();
# ifdef TRACE trace << "DFS_RED treats: " << a_->format_state(f.s) << std::endl;
std::cout << "DFS_RED treats: "
<< a_->format_state(f.s) << std::endl;
# endif
if (!f.it->done()) if (!f.it->done())
{ {
const state *s_prime = f.it->current_state(); const state *s_prime = f.it->current_state();
# ifdef TRACE trace << " Visit the successor: "
std::cout << " Visit the successor: " << a_->format_state(s_prime) << std::endl;
<< a_->format_state(s_prime) << std::endl;
# endif
bdd label = f.it->current_condition(); bdd label = f.it->current_condition();
bdd acc = f.it->current_acceptance_conditions(); bdd acc = f.it->current_acceptance_conditions();
// Go down the edge (f.s, <label, acc>, s_prime) // Go down the edge (f.s, <label, acc>, s_prime)
...@@ -310,16 +289,12 @@ namespace spot ...@@ -310,16 +289,12 @@ namespace spot
// to the visit of white state. Anyway, it is not necessary // to the visit of white state. Anyway, it is not necessary
// to visit white states either if a cycle can be missed // to visit white states either if a cycle can be missed
// with bit-state hashing search. // with bit-state hashing search.
# ifdef TRACE trace << " It is white, pop it" << std::endl;
std::cout << " It is white, pop it" << std::endl;
# endif
delete s_prime; delete s_prime;
} }
else if (c.get_color() == BLUE) else if (c.get_color() == BLUE)
{ {
# ifdef TRACE trace << " It is blue, go down" << std::endl;
std::cout << " It is blue, go down" << std::endl;
# endif
c.set_color(RED); c.set_color(RED);
push(st_red, s_prime, label, acc); push(st_red, s_prime, label, acc);
if (target->compare(s_prime) == 0) if (target->compare(s_prime) == 0)
...@@ -327,18 +302,14 @@ namespace spot ...@@ -327,18 +302,14 @@ namespace spot
} }
else else
{ {
# ifdef TRACE trace << " It is red, pop it" << std::endl;
std::cout << " It is red, pop it" << std::endl;
# endif
h.pop_notify(s_prime); h.pop_notify(s_prime);
} }
} }
else // Backtrack else // Backtrack
{ {
# ifdef TRACE trace << " All the successors have been visited, pop it"
std::cout << " All the successors have been visited, pop it" << std::endl;
<< std::endl;
# endif
h.pop_notify(f.s); h.pop_notify(f.s);
pop(st_red); pop(st_red);
} }
......
...@@ -55,8 +55,7 @@ namespace spot ...@@ -55,8 +55,7 @@ namespace spot
/// for all t in post(s) do /// for all t in post(s) do
/// if t.color == white then /// if t.color == white then
/// call dfs_blue(t); /// call dfs_blue(t);
/// end if; /// else if (the edge (s,t) is accepting) then
/// if (the edge (s,t) is accepting) then
/// target = s; /// target = s;
/// call dfs_red(t); /// call dfs_red(t);
/// end if; /// end if;
...@@ -70,7 +69,7 @@ namespace spot ...@@ -70,7 +69,7 @@ namespace spot
/// report cycle /// report cycle
/// end if; /// end if;
/// for all t in post(s) do /// for all t in post(s) do
/// if t.color != red then /// if t.color == blue then
/// call dfs_red(t); /// call dfs_red(t);
/// end if; /// end if;
/// end for; /// end for;
......
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
//#define TRACE //#define TRACE
#ifdef TRACE
#include <iostream> #include <iostream>
#ifdef TRACE
#define trace std::cerr
#else
#define trace while (0) std::cerr
#endif #endif
#include <cassert> #include <cassert>
...@@ -53,7 +56,7 @@ namespace spot ...@@ -53,7 +56,7 @@ namespace spot
/// condition (i.e. it is a TBA). /// condition (i.e. it is a TBA).
se05_search(const tgba *a, size_t size) se05_search(const tgba *a, size_t size)
: emptiness_check(a), : emptiness_check(a),
current_weight(0), ec_statistics(),
h(size), h(size),
all_cond(a->all_acceptance_conditions()) all_cond(a->all_acceptance_conditions())
{ {
...@@ -92,7 +95,7 @@ namespace spot ...@@ -92,7 +95,7 @@ namespace spot
assert(st_blue.empty()); assert(st_blue.empty());
const state* s0 = a_->get_init_state(); const state* s0 = a_->get_init_state();
inc_states(); inc_states();
h.add_new_state(s0, CYAN, current_weight); h.add_new_state(s0, CYAN);
push(st_blue, s0, bddfalse, bddfalse); push(st_blue, s0, bddfalse, bddfalse);
if (dfs_blue()) if (dfs_blue())
return new result(*this); return new result(*this);
...@@ -160,10 +163,6 @@ namespace spot ...@@ -160,10 +163,6 @@ namespace spot
st.pop_front(); st.pop_front();
} }
/// \brief number of visited accepting arcs
/// in the blue stack.
int current_weight;
/// \brief Stack of the blue dfs. /// \brief Stack of the blue dfs.
stack_type st_blue; stack_type st_blue;
...@@ -182,17 +181,12 @@ namespace spot ...@@ -182,17 +181,12 @@ namespace spot
while (!st_blue.empty()) while (!st_blue.empty())
{ {
stack_item& f = st_blue.front(); stack_item& f = st_blue.front();
# ifdef TRACE trace << "DFS_BLUE treats: " << a_->format_state(f.s) << std::endl;
std::cout << "DFS_BLUE treats: "
<< a_->format_state(f.s) << std::endl;
# endif
if (!f.it->done()) if (!f.it->done())
{ {
const state *s_prime = f.it->current_state(); const state *s_prime = f.it->current_state();
# ifdef TRACE trace << " Visit the successor: "
std::cout << " Visit the successor: " << a_->format_state(s_prime) << std::endl;
<< a_->format_state(s_prime) << std::endl;
# endif
bdd label = f.it->current_condition(); bdd label = f.it->current_condition();
bdd acc = f.it->current_acceptance_conditions(); bdd acc = f.it->current_acceptance_conditions();
// Go down the edge (f.s, <label, acc>, s_prime) // Go down the edge (f.s, <label, acc>, s_prime)
...@@ -201,25 +195,16 @@ namespace spot ...@@ -201,25 +195,16 @@ namespace spot
typename heap::color_ref c = h.get_color_ref(s_prime); typename heap::color_ref c = h.get_color_ref(s_prime);
if (c.is_white()) if (c.is_white())
{ {
# ifdef TRACE trace << " It is white, go down" << std::endl;
std::cout << " It is white, go down" << std::endl;
# endif
if (acc == all_cond)
++current_weight;
inc_states(); inc_states();
h.add_new_state(s_prime, CYAN, current_weight); h.add_new_state(s_prime, CYAN);
push(st_blue, s_prime, label, acc); push(st_blue, s_prime, label, acc);
} }
else if (c.get_color() == CYAN && (acc == all_cond || else if (c.get_color() == CYAN && (acc == all_cond ||
(f.s->compare(s_prime) != 0 && f.acc == all_cond) // option SE05 (f.s->compare(s_prime) != 0 && f.acc == all_cond)))
// current_weight > c.get_weight() // option WEIGHT
/**/))
// For Alexandre: combat style.test! ----------^
{ {
# ifdef TRACE trace << " It is cyan and acceptance condition "
std::cout << " It is cyan and acceptance condition " << "is reached, report cycle" << std::endl;
<< "is reached, report cycle" << std::endl;
# endif
c.set_color(RED); c.set_color(RED);
push(st_red, s_prime, label, acc); push(st_red, s_prime, label, acc);
return true; return true;
...@@ -230,10 +215,8 @@ namespace spot ...@@ -230,10 +215,8 @@ namespace spot
// the number of runs reported by successive // the number of runs reported by successive
// calls to the check method. Without this // calls to the check method. Without this
// functionnality, the test can be ommited. // functionnality, the test can be ommited.
# ifdef TRACE trace << " It is cyan or blue and the arc is "
std::cout << " It is cyan or blue and the arc is " << "accepting, start a red dfs" << std::endl;
<< "accepting, start a red dfs" << std::endl;
# endif
c.set_color(RED); c.set_color(RED);
push(st_red, s_prime, label, acc); push(st_red, s_prime, label, acc);
if (dfs_red()) if (dfs_red())
...@@ -241,10 +224,7 @@ namespace spot ...@@ -241,10 +224,7 @@ namespace spot
} }
else else
{ {
# ifdef TRACE trace << " It is cyan, blue or red, pop it" << std::endl;
std::cout << " It is cyan, blue or red, pop it"
<< std::endl;
# endif
h.pop_notify(s_prime); h.pop_notify(s_prime);
} }
} }
...@@ -252,14 +232,9 @@ namespace spot ...@@ -252,14 +232,9 @@ namespace spot
// Backtrack the edge // Backtrack the edge
// (predecessor of f.s in st_blue, <f.label, f.acc>, f.s) // (predecessor of f.s in st_blue, <f.label, f.acc>, f.s)
{ {
# ifdef TRACE trace << " All the successors have been visited" << std::endl;
std::cout << " All the successors have been visited"
<< std::endl;
# endif
stack_item f_dest(f); stack_item f_dest(f);
pop(st_blue); pop(st_blue);
if (f_dest.acc == all_cond)
--current_weight;
typename heap::color_ref c = h.get_color_ref(f_dest.s); typename heap::color_ref c = h.get_color_ref(f_dest.s);
assert(!c.is_white()); assert(!c.is_white());
if (!st_blue.empty() && if (!st_blue.empty() &&
...@@ -269,12 +244,10 @@ namespace spot ...@@ -269,12 +244,10 @@ namespace spot
// the number of runs reported by successive // the number of runs reported by successive
// calls to the check method. Without this // calls to the check method. Without this
// functionnality, the test can be ommited. // functionnality, the test can be ommited.
# ifdef TRACE trace << " The arc from "
std::cout << " The arc from " << a_->format_state(st_blue.front().s)
<< a_->format_state(st_blue.front().s) << " to the current state is accepting, start a "
<< " to the current state is accepting, start a " << "red dfs" << std::endl;
<< "red dfs" << std::endl;
# endif
c.set_color(RED); c.set_color(RED);
push(st_red, f_dest.s, f_dest.label, f_dest.acc); push(st_red, f_dest.s, f_dest.label, f_dest.acc);
if (dfs_red()) if (dfs_red())
...@@ -282,9 +255,7 @@ namespace spot ...@@ -282,9 +255,7 @@ namespace spot
} }
else else
{ {
# ifdef TRACE trace << " Pop it" << std::endl;
std::cout << " Pop it" << std::endl;
# endif
c.set_color(BLUE); c.set_color(BLUE);
h.pop_notify(f_dest.s); h.pop_notify(f_dest.s);
} }
...@@ -300,17 +271,12 @@ namespace spot ...@@ -300,17 +271,12 @@ namespace spot
while (!st_red.empty()) while (!st_red.empty())
{ {
stack_item& f = st_red.front(); stack_item& f = st_red.front();
# ifdef TRACE trace << "DFS_RED treats: " << a_->format_state(f.s) << std::endl;
std::cout << "DFS_RED treats: "
<< a_->format_state(f.s) << std::endl;
# endif
if (!f.it->done()) if (!f.it->done())
{ {
const state *s_prime = f.it->current_state(); const state *s_prime = f.it->current_state();
# ifdef TRACE trace << " Visit the successor: "
std::cout << " Visit the successor: " << a_->format_state(s_prime) << std::endl;
<< a_->format_state(s_prime) << std::endl;
# endif
bdd label = f.it->current_condition(); bdd label = f.it->current_condition();
bdd acc = f.it->current_acceptance_conditions(); bdd acc = f.it->current_acceptance_conditions();
// Go down the edge (f.s, <label, acc>, s_prime) // Go down the edge (f.s, <label, acc>, s_prime)
...@@ -325,45 +291,33 @@ namespace spot ...@@ -325,45 +291,33 @@ namespace spot
// implying the report of a cycle. // implying the report of a cycle.
// However, with a bit-state hashing search and due to // However, with a bit-state hashing search and due to
// collision, this property does not hold. // collision, this property does not hold.
# ifdef TRACE trace << " It is white (due to collision), pop it"
std::cout << " It is white (due to collision), pop it" << std::endl;
<< std::endl;
# endif
delete s_prime; delete s_prime;
} }
else if (c.get_color() == RED) else if (c.get_color() == RED)
{ {
# ifdef TRACE trace << " It is red, pop it" << std::endl;
std::cout << " It is red, pop it"
<< std::endl;
# endif
h.pop_notify(s_prime); h.pop_notify(s_prime);
} }
else if (c.get_color() == CYAN) else if (c.get_color() == CYAN)
{ {
# ifdef TRACE trace << " It is cyan, report a cycle" << std::endl;
std::cout << " It is cyan, report a cycle"
<< std::endl;
# endif
c.set_color(RED); c.set_color(RED);
push(st_red, s_prime, label, acc); push(st_red, s_prime, label, acc);
return true; return true;
} }
else else
{ {
# ifdef TRACE trace << " It is blue, go down" << std::endl;
std::cout << " It is blue, go down" << std::endl;
# endif
c.set_color(RED); c.set_color(RED);
push(st_red, s_prime, label, acc); push(st_red, s_prime, label, acc);
} }
} }
else // Backtrack else // Backtrack
{ {
# ifdef TRACE trace << " All the successors have been visited, pop it"
std::cout << " All the successors have been visited, pop it" << std::endl;
<< std::endl;
# endif
h.pop_notify(f.s); h.pop_notify(f.s);
pop(st_red); pop(st_red);
} }
...@@ -429,7 +383,7 @@ namespace spot ...@@ -429,7 +383,7 @@ namespace spot
class explicit_se05_search_heap class explicit_se05_search_heap
{ {
typedef Sgi::hash_map<const state*, int, typedef Sgi::hash_set<const state*,
state_ptr_hash, state_ptr_equal> hcyan_type; state_ptr_hash, state_ptr_equal> hcyan_type;
typedef Sgi::hash_map<const state*, color, typedef Sgi::hash_map<const state*, color,
state_ptr_hash, state_ptr_equal> hash_type; state_ptr_hash, state_ptr_equal> hash_type;
...@@ -437,12 +391,12 @@ namespace spot ...@@ -437,12 +391,12 @@ namespace spot
class color_ref class color_ref
{ {
public: public:
color_ref(hash_type* h, hcyan_type* hc, const state* s, int w) color_ref(hash_type* h, hcyan_type* hc, const state* s)
: is_cyan(true), weight(w), ph(h), phc(hc), ps(s), pc(0) : is_cyan(true), ph(h), phc(hc), ps(s), pc(0)
{ {
} }
color_ref(color* c) color_ref(color* c)
: is_cyan(false), weight(0), ph(0), phc(0), ps(0), pc(c)