Commit 8dbc9424 authored by Denis Poitrenaud's avatar Denis Poitrenaud

* src/tgbaalgos/ndfs_result.hh: Rewrite the computation of accepting

runs.
* src/tgbaalgos/bfssteps.hh, src/tgbaalgos/bfssteps.cc: Add the method
finalize witch compute (by default) the traversed path.
* src/tgbaalgos/magic.cc, src/tgbaalgos/se05.cc: Fix a bug concerning
the heap used for bit state hashing version and ajust the prototype of
has_been_visited and pop_notify.
* src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.cc: ajust the prototype
of has_been_visited and pop_notify.
parent 0c2c12a8
2004-12-20 Denis Poitrenaud <Denis.Poitrenaud@lip6.fr>
* src/tgbaalgos/ndfs_result.hh: Rewrite the computation of accepting
runs.
* src/tgbaalgos/bfssteps.hh, src/tgbaalgos/bfssteps.cc: Add the method
finalize witch compute (by default) the traversed path.
* src/tgbaalgos/magic.cc, src/tgbaalgos/se05.cc: Fix a bug concerning
the heap used for bit state hashing version and ajust the prototype of
has_been_visited and pop_notify.
* src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.cc: ajust the prototype
of has_been_visited and pop_notify.
2004-12-17 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbaalgos/ndfs_result.hh: Include misc/hash.hh.
......
......@@ -19,7 +19,6 @@
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include <map>
#include <deque>
#include <utility>
#include "tgba/tgba.hh"
......@@ -37,6 +36,28 @@ namespace spot
{
}
void
bfs_steps::finalize(const std::map<const state*, tgba_run::step,
state_ptr_less_than>& father, const tgba_run::step& s,
const state* start, tgba_run::steps& l)
{
tgba_run::steps p;
tgba_run::step current = s;
for (;;)
{
tgba_run::step tmp = current;
tmp.s = tmp.s->clone();
p.push_front(tmp);
if (current.s == start)
break;
std::map<const state*, tgba_run::step,
state_ptr_less_than>::const_iterator it = father.find(current.s);
assert(it!=father.end());
current = it->second;
}
l.splice(l.end(), p);
}
const state*
bfs_steps::search(const state* start, tgba_run::steps& l)
{
......@@ -68,19 +89,7 @@ namespace spot
if (match(s, dest))
{
// Found it!
tgba_run::steps p;
for (;;)
{
tgba_run::step tmp = s;
tmp.s = tmp.s->clone();
p.push_front(tmp);
if (s.s == start)
break;
s = father[s.s];
}
l.splice(l.end(), p);
finalize(father, s, start, l);
delete i;
return dest;
}
......
......@@ -22,6 +22,8 @@
#ifndef SPOT_TGBAALGOS_BFSSTEPS_HH
# define SPOT_TGBAALGOS_BFSSTEPS_HH
#include <map>
#include "tgba/state.hh"
#include "emptiness.hh"
namespace spot
......@@ -82,6 +84,14 @@ namespace spot
/// augmented with the shortest past that ends with this
/// transition.
virtual bool match(tgba_run::step& step, const state* dest) = 0;
virtual void finalize(const std::map<const state*,
tgba_run::step,
state_ptr_less_than>& father,
const tgba_run::step& s,
const state* start,
tgba_run::steps& l);
protected:
const tgba* a_; ///< The spot::tgba we are searching into.
};
......
......@@ -377,21 +377,14 @@ namespace spot
h.insert(std::make_pair(s, c));
}
void pop_notify(const state*)
void pop_notify(const state*) const
{
}
bool has_been_visited(const state*& s) const
bool has_been_visited(const state* s) const
{
hash_type::const_iterator it = h.find(s);
if (it==h.end())
return false;
if (s!=it->first)
{
delete s;
s = it->first;
}
return true;
return (it != h.end());
}
private:
......@@ -452,15 +445,15 @@ namespace spot
cr.set_color(c);
}
void pop_notify(const state* s)
void pop_notify(const state* s) const
{
delete s;
}
bool has_been_visited(const state*& s) const
bool has_been_visited(const state* s) const
{
size_t ha = s->hash();
return color((h[ha%size] >> (ha%4)) & 3U) != WHITE;
return color((h[ha%size] >> ((ha%4)*2)) & 3U) != WHITE;
}
private:
......
This diff is collapsed.
......@@ -430,31 +430,19 @@ namespace spot
h.insert(std::make_pair(s, c));
}
void pop_notify(const state*)
void pop_notify(const state*) const
{
}
bool has_been_visited(const state*& s) const
bool has_been_visited(const state* s) const
{
hcyan_type::const_iterator ic = hc.find(s);
if (ic==hc.end())
if (ic == hc.end())
{
hash_type::const_iterator it = h.find(s);
if (it==h.end())
return false; // white state
if (s!=it->first)
{
delete s;
s = it->first;
}
return true; // blue or red state
return (it != h.end());
}
if (s!=*ic)
{
delete s;
s = *ic;
}
return true; // cyan state
return true;
}
private:
......@@ -541,18 +529,18 @@ namespace spot
}
}
void pop_notify(const state* s)
void pop_notify(const state* s) const
{
delete s;
}
bool has_been_visited(const state*& s) const
bool has_been_visited(const state* s) const
{
hcyan_type::const_iterator ic = hc.find(s);
if (ic!=hc.end())
if (ic != hc.end())
return true;
size_t ha = s->hash();
return color((h[ha%size] >> (ha%4)) & 3U) != WHITE;
return color((h[ha%size] >> ((ha%4)*2)) & 3U) != WHITE;
}
private:
......
......@@ -351,21 +351,14 @@ namespace spot
h.insert(std::make_pair(s, std::make_pair(c, bddfalse)));
}
void pop_notify(const state*)
void pop_notify(const state*) const
{
}
bool has_been_visited(const state*& s) const
bool has_been_visited(const state* s) const
{
hash_type::const_iterator it = h.find(s);
if (it == h.end())
return false;
else if (s != it->first)
{
delete s;
s = it->first;
}
return true;
return (it != h.end());
}
private:
......
......@@ -466,31 +466,17 @@ namespace spot
hc.insert(std::make_pair(s, std::make_pair(w, bddfalse)));
}
void pop_notify(const state*)
void pop_notify(const state*) const
{
}
bool has_been_visited(const state*& s) const
bool has_been_visited(const state* s) const
{
hcyan_type::const_iterator ic = hc.find(s);
if (ic == hc.end())
{
hash_type::const_iterator it = h.find(s);
if (it == h.end())
// white state
return false;
if (s != it->first)
{
delete s;
s = it->first;
}
// blue or red state
return true;
}
else if (s != ic->first)
{
delete s;
s = ic->first;
return (it != h.end());
}
return true;
}
......
Markdown is supported
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