Commit 9ce68888 authored by martinez's avatar martinez
Browse files

* src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh,

src/tgbaalgos/reductgba_sim.cc,	src/tgbaalgos/reductgba_sim.hh,
src/tgbaalgos/reductgba_sim_del.cc: Remove some comments.

* src/tgbatest/ltl2tgba.cc, src/tgbatest/reductgba.cc: Adjust ...
* src/tgbatest/spotlbtt.test: More test (delayed simulation)
parent 7ff38981
2004-07-02 Thomas Martinez <martinez@src.lip6.fr>
* src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh,
src/tgbaalgos/reductgba_sim.cc, src/tgbaalgos/reductgba_sim.hh,
src/tgbaalgos/reductgba_sim_del.cc: Remove some comments.
* src/tgbatest/ltl2tgba.cc, src/tgbatest/reductgba.cc: Adjust ...
* src/tgbatest/spotlbtt.test: More test (delayed simulation)
2004-06-29 Alexandre Duret-Lutz <adl@src.lip6.fr>
* configure.ac, NEWS: Bump version to 0.0w.
......
......@@ -122,7 +122,6 @@ namespace spot
if (!scc_computed_)
this->compute_scc();
this->prune_acc();
// FIXME
this->delete_scc();
}
......@@ -144,26 +143,6 @@ namespace spot
return i->second;
}
int
tgba_reduc::get_nb_state()
{
return state_name_map_.size();
}
int
tgba_reduc::get_nb_transition()
{
int nb_transition = 0;
sn_map::iterator i;
for (i = state_name_map_.begin();
i != state_name_map_.end(); ++i)
{
nb_transition += (i->first)->size();
}
return nb_transition;
}
////////////////////////////////////////////
void
......
......@@ -64,11 +64,7 @@ namespace spot
/// Add the SCC index to the display of the state \a state.
virtual std::string format_state(const spot::state* state) const;
/// Obsolete.
int get_nb_state();
int get_nb_transition();
// Just for Debug !!
// For Debug
void display_rel_sim(simulation_relation* rel, std::ostream& os);
void display_scc(std::ostream& os);
......
......@@ -50,7 +50,6 @@ namespace spot
bool
spoiler_node::add_succ(spoiler_node* n)
{
//std::cout << "spoiler_node::add_succ" << std::endl;
bool exist = false;
for (sn_v::iterator i = lnode_succ->begin();
i != lnode_succ->end(); ++i)
......@@ -84,15 +83,6 @@ namespace spot
spoiler_node::add_pred(spoiler_node* n)
{
lnode_pred->push_back(n);
/*
bool exist = false;
for (sn_v::iterator i = lnode_pred->begin();
i != lnode_pred->end(); ++i)
if ((*i)->compare(n) == 0)
exist = true;
if (!exist)
lnode_pred->push_back(n);
*/
}
void
......@@ -120,25 +110,10 @@ namespace spot
return change != not_win;
}
/*
bool
spoiler_node::set_win()
{
bool change = not_win;
for (Sgi::vector<spoiler_node*>::iterator i = lnode_succ->begin();
i != lnode_succ->end(); ++i)
{
not_win |= (*i)->not_win;
}
return change != not_win;
}
*/
std::string
spoiler_node::to_string(const tgba* a)
{
std::ostringstream os;
// print the node.
os << num_
<< " [shape=box, label=\"("
<< a->format_state(sc_->first)
......@@ -164,7 +139,6 @@ namespace spot
bool
spoiler_node::compare(spoiler_node* n)
{
//std::cout << "spoiler_node::compare" << std::endl;
return (((sc_->first)->compare((n->get_pair())->first) == 0) &&
((sc_->second)->compare((n->get_pair())->second) == 0));
}
......@@ -235,34 +209,10 @@ namespace spot
return change != not_win;
}
/*
bool
duplicator_node::set_win()
{
bool change = not_win;
if (!this->get_nb_succ())
not_win = true;
else
{
not_win = true;
for (Sgi::vector<spoiler_node*>::iterator i = lnode_succ->begin();
i != lnode_succ->end(); ++i)
{
not_win &= (*i)->not_win;
}
}
return change != not_win;
}
*/
std::string
duplicator_node::to_string(const tgba* a)
{
std::ostringstream os;
// print the node.
os << num_
<< " [shape=box, label=\"("
<< a->format_state(sc_->first)
......@@ -274,14 +224,12 @@ namespace spot
bdd_print_acc(os, a->get_dict(), acc_);
os << ")\"]"
<< std::endl;
return os.str();
}
bool
duplicator_node::compare(spoiler_node* n)
{
//std::cout << "duplicator_node::compare" << std::endl;
return (this->spoiler_node::compare(n) &&
(label_ == dynamic_cast<duplicator_node*>(n)->get_label()) &&
(acc_ == dynamic_cast<duplicator_node*>(n)->get_acc()));
......@@ -591,216 +539,6 @@ namespace spot
}
}
/*
void
parity_game_graph_direct::build_couple()
{
// We build only some "basic" spoiler node.
sn_v tab_temp;
s_v::iterator i1;
for (i1 = tgba_state_.begin(); i1 != tgba_state_.end(); ++i1)
{
// spoiler node are all state couple (i,j)
s_v::iterator i2;
for (i2 = tgba_state_.begin();
i2 != tgba_state_.end(); ++i2)
{
//std::cout << "add spoiler node" << std::endl;
spoiler_node_delayed* n1
= new spoiler_node_delayed(*i1, *i2,
bddfalse,
nb_node_parity_game++);
spoiler_vertice_.push_back(n1);
tab_temp.push_back(n1);
}
}
sn_v::iterator j;
std::ostringstream os;
for (j = tab_temp.begin(); j != tab_temp.end(); ++j)
build_recurse_successor_spoiler(*j, os);
}
void
parity_game_graph_direct::
build_recurse_successor_spoiler(spoiler_node* sn,
std::ostringstream& os)
{
//std::cout << os.str() << "build_recurse_successor_spoiler : begin"
//<< std::endl;
tgba_succ_iterator* si = automata_->succ_iter(sn->get_spoiler_node());
for (si->first(); !si->done(); si->next())
{
bdd btmp = si->current_acceptance_conditions();
s_v::iterator i1;
state* s;
for (i1 = tgba_state_.begin();
i1 != tgba_state_.end(); ++i1)
{
s = si->current_state();
if (s->compare(*i1) == 0)
{
delete s;
duplicator_node* dn
= add_duplicator_node(*i1,
sn->get_duplicator_node(),
si->current_condition(),
btmp,
nb_node_parity_game++);
if (!(sn->add_succ(dn)))
continue;
std::ostringstream os2;
os2 << os.str() << " ";
build_recurse_successor_duplicator(dn, sn, os2);
}
else
delete s;
}
}
delete si;
//std::cout << os.str() << "build_recurse_successor_spoiler : end" <<
//std::endl;
}
void
parity_game_graph_direct::
build_recurse_successor_duplicator(duplicator_node* dn,
spoiler_node* ,
std::ostringstream& os)
{
//std::cout << "build_recurse_successor_duplicator : begin" << std::endl;
tgba_succ_iterator* si = automata_->succ_iter(dn->get_duplicator_node());
for (si->first(); !si->done(); si->next())
{
// if si->current_condition() doesn't implies sn->get_label()
// then duplicator can't play.
if ((!dn->get_label() | si->current_condition()) != bddtrue)
continue;
bdd btmp = dn->get_acc() -
(dn->get_acc() & si->current_acceptance_conditions());
s_v::iterator i1;
state* s;
for (i1 = tgba_state_.begin();
i1 != tgba_state_.end(); ++i1)
{
s = si->current_state();
if (s->compare(*i1) == 0)
{
delete s;
spoiler_node* sn_n
= add_spoiler_node(dn->get_spoiler_node(),
*i1,
nb_node_parity_game++);
if (!(dn->add_succ(sn_n)))
continue;
std::ostringstream os2;
os2 << os.str() << " ";
build_recurse_successor_spoiler(sn_n, os2);
}
else
delete s;
}
}
delete si;
//std::cout << os.str() << "build_recurse_successor_duplicator : end"
//<< std::endl;
}
duplicator_node*
parity_game_graph_direct::add_duplicator_node(const spot::state* sn,
const spot::state* dn,
bdd acc,
bdd label,
int nb)
{
bool exist = false;
duplicator_node* dn_n
= new duplicator_node(sn, dn, acc, label, nb);
for (Sgi::vector<duplicator_node*>::iterator i
= duplicator_vertice_.begin();
i != duplicator_vertice_.end(); ++i)
{
if (dn_n->compare(*i))
{
exist = true;
delete dn_n;
dn_n = *i;
break;
}
}
if (!exist)
duplicator_vertice_.push_back(dn_n);
return dn_n;
}
spoiler_node*
parity_game_graph_direct::add_spoiler_node(const spot::state* sn,
const spot::state* dn,
int nb)
{
bool exist = false;
spoiler_node* sn_n
= new spoiler_node(sn, dn, nb);
for (Sgi::vector<spoiler_node*>::iterator i
= spoiler_vertice_.begin();
i != spoiler_vertice_.end(); ++i)
{
if (sn_n->compare(*i))
{
exist = true;
delete sn_n;
sn_n = *i;
break;
}
}
if (!exist)
spoiler_vertice_.push_back(sn_n);
return sn_n;
}
*/
/*
void
parity_game_graph_direct::lift()
{
for (Sgi::vector<spoiler_node*>::iterator i
= spoiler_vertice_.begin();
i != spoiler_vertice_.end(); ++i)
{
(*i)->set_win();
}
}
*/
void
parity_game_graph_direct::lift()
{
......@@ -874,12 +612,14 @@ namespace spot
///////////////////////////////////////////////////////////////////////
simulation_relation*
get_direct_relation_simulation(const tgba* f, int opt)
get_direct_relation_simulation(const tgba* f,
std::ostream& os,
int opt)
{
parity_game_graph_direct* G = new parity_game_graph_direct(f);
simulation_relation* rel = G->get_relation();
if (opt == 1)
G->print(std::cout);
G->print(os);
delete G;
return rel;
}
......@@ -931,7 +671,7 @@ namespace spot
if (opt & Reduce_Dir_Sim)
{
simulation_relation* rel
= get_direct_relation_simulation(automatareduc);
= get_direct_relation_simulation(automatareduc, std::cout);
automatareduc->display_rel_sim(rel, std::cout);
automatareduc->prune_automata(rel);
......@@ -942,7 +682,7 @@ namespace spot
if (opt & Reduce_Del_Sim)
{
simulation_relation* rel
= get_delayed_relation_simulation(automatareduc);
= get_delayed_relation_simulation(automatareduc, std::cout);
automatareduc->display_rel_sim(rel, std::cout);
automatareduc->prune_automata(rel);
......@@ -952,7 +692,6 @@ namespace spot
if (opt & Reduce_Scc)
{
automatareduc->compute_scc();
automatareduc->prune_scc();
}
......
......@@ -58,21 +58,19 @@ namespace spot
/// \brief Compute a direct simulation relation on state of tgba \a f.
simulation_relation* get_direct_relation_simulation(const tgba* a,
std::ostream& os,
int opt = -1);
/// Compute a delayed simulation relation on state of tgba \a f.
/// FIXME : this method is incorrect !!
/// Don't use it !!
// FIXME: This method is correct but she build sometime (when there are more
// than one acceptance condition) only a part of the simulation relation.
simulation_relation* get_delayed_relation_simulation(const tgba* a,
std::ostream& os,
int opt = -1);
/// To free a simulation relation.
void free_relation_simulation(simulation_relation* rel);
/// Test if the initial state of a2 fair simulate this of a1.
/// Not implemented.
bool is_include(const tgba* a1, const tgba* a2);
///////////////////////////////////////////////////////////////////////
// simulation.
......@@ -108,11 +106,6 @@ namespace spot
/// \brief Compute each node of the graph.
virtual void build_graph() = 0;
/// \brief Compute the link of the graph.
/// Successor of spoiler node (resp. duplicator node)
/// are duplicator node (resp. spoiler node).
//virtual void build_link() = 0;
/// \brief Remove edge from spoiler to duplicator that make
/// duplicator loose.
/// Spoiler node whose still have some link, reveal
......@@ -156,7 +149,6 @@ namespace spot
protected:
sn_v* lnode_succ;
sn_v* lnode_pred;
//Sgi::vector<spoiler_node*>* lnode_succ;
state_couple* sc_;
};
......@@ -200,23 +192,6 @@ namespace spot
virtual void lift();
void build_link();
/*
private:
void build_recurse_successor_spoiler(spoiler_node* sn,
std::ostringstream& os);
void build_recurse_successor_duplicator(duplicator_node* dn,
spoiler_node* sn,
std::ostringstream& os);
duplicator_node* add_duplicator_node(const spot::state* sn,
const spot::state* dn,
bdd acc,
bdd label,
int nb);
spoiler_node* add_spoiler_node(const spot::state* sn,
const spot::state* dn,
int nb);
*/
};
......@@ -230,8 +205,7 @@ namespace spot
spoiler_node_delayed(const state* d_node,
const state* s_node,
bdd a,
int num,
bool l2a = true);
int num);
~spoiler_node_delayed();
/// Return true if the progress_measure has changed.
......@@ -242,16 +216,16 @@ namespace spot
int get_progress_measure() const;
bool get_lead_2_acc_all();
/*
void set_lead_2_acc_all();
*/
bool set_lead_2_acc_all(bdd acc = bddfalse);
//
bool seen_;
protected:
/// a Bdd for retain all the acceptance condition
/// that a node has visited.
bdd acceptance_condition_visited_;
int progress_measure_;
bool lead_2_acc_all_;
};
/// Duplicator node of parity game graph for delayed simulation.
......@@ -271,9 +245,12 @@ namespace spot
bool implies_label(bdd l);
bool implies_acc(bdd a);
int get_progress_measure();
bool get_lead_2_acc_all();
void set_lead_2_acc_all();
bool set_lead_2_acc_all(bdd acc = bddfalse);
//
bool seen_;
protected:
int progress_measure_;
bool lead_2_acc_all_;
......@@ -316,9 +293,6 @@ namespace spot
/// Return the number of acceptance condition.
int nb_set_acc_cond();
/// Compute sub_set_acc_cond_;
void build_sub_set_acc_cond();
///
duplicator_node_delayed* add_duplicator_node_delayed(const spot::state* sn,
const spot::state* dn,
......@@ -332,21 +306,18 @@ namespace spot
bdd acc,
int nb);
/// \brief Compute the couple as for direct simulation,
virtual void build_graph();
//virtual void build_link();
void build_recurse_successor_spoiler(spoiler_node* sn,
std::ostringstream& os);
void build_recurse_successor_duplicator(duplicator_node* dn,
spoiler_node* sn,
std::ostringstream& os);
/// \brief Compute the couple as for direct simulation,
virtual void build_graph();
/// \brief The Jurdzinski's lifting algorithm.
virtual void lift();
/// \brief Remove all node so as to there is no dead ends (terminal node).
//virtual void prune();
};
}
......
......@@ -33,7 +33,13 @@ namespace spot
static int nb_spoiler;
static int nb_duplicator;
//static int nb_node;
static bdd all_acc_cond = bddfalse;
static Sgi::vector<bool*> bool_v;
//static int nb_node = 0;
//seen_map_node seen_node_;
///////////////////////////////////////////////////////////////////////
// spoiler_node_delayed
......@@ -41,8 +47,7 @@ namespace spot
spoiler_node_delayed::spoiler_node_delayed(const state* d_node,
const state* s_node,
bdd a,
int num,
bool l2a)
int num)
: spoiler_node(d_node, s_node, num),
acceptance_condition_visited_(a)
{
......@@ -50,12 +55,16 @@ namespace spot
progress_measure_ = 0;
if (acceptance_condition_visited_ != bddfalse)
nb_spoiler_loose_++;
lead_2_acc_all_ = l2a;
lead_2_acc_all_ = false;
seen_ = false;
//seen_ = new bool(false);
//bool_v[nb_node++] = seen_;
}
spoiler_node_delayed::~spoiler_node_delayed()
{
if (acceptance_condition_visited_ != bddfalse)
if (acceptance_condition_visited_ != bddfalse)
nb_spoiler_loose_--;
}
......@@ -76,11 +85,14 @@ namespace spot
bool change;
int tmpmax = 0;
int tmp = 0;
int tmpmaxwin = -1;
sn_v::iterator i = lnode_succ->begin();
if (i != lnode_succ->end())
{
tmpmax =
dynamic_cast<duplicator_node_delayed*>(*i)->get_progress_measure();
if (dynamic_cast<duplicator_node_delayed*>(*i)->get_lead_2_acc_all())
tmpmaxwin = tmpmax;
++i;
}
for (; i != lnode_succ->end(); ++i)
......@@ -89,8 +101,14 @@ namespace spot
dynamic_cast<duplicator_node_delayed*>(*i)->get_progress_measure();
if (tmp > tmpmax)
tmpmax = tmp;
if (dynamic_cast<duplicator_node_delayed*>(*i)->get_lead_2_acc_all() &&
(tmp > tmpmaxwin))
tmpmaxwin = tmp;
}
if (tmpmaxwin != -1)
tmpmax = tmpmaxwin;
// If the priority of the node is 1