* src/tgbatest/reduccmp.test: Bug.
* src/tgbatest/reductgba.test: More Test. * src/tgbatest/ltl2tgba.cc: Adjust ... * src/tgbaalgos/reductgba_sim_del.cc, src/tgbaalgos/reductgba_sim.hh, src/tgbaalgos/reductgba_sim.cc: try to optimize. * src/tgba/tgbareduc.hh, src/tgba/tgbareduc.cc: Scc reduction and we remove some acceptance condition in scc which are not accepting. * src/ltlvisit/syntimpl.cc : Some case wasn't detect. * src/ltlvisit/basicreduce.cc: Case FGa || FGb = F(Ga | Gb) added. * src/ltltest/syntimpl.test: More Test. * src/ltltest/syntimpl.cc: Put the formula in negative normal form.
This commit is contained in:
parent
acee9e75a4
commit
8be67c1976
14 changed files with 771 additions and 231 deletions
|
|
@ -54,12 +54,14 @@ namespace spot
|
|||
bool exist = false;
|
||||
for (sn_v::iterator i = lnode_succ->begin();
|
||||
i != lnode_succ->end(); ++i)
|
||||
if ((*i)->compare(n) == true)
|
||||
if ((*i == n) ||
|
||||
((*i)->compare(n) == true))
|
||||
exist = true;
|
||||
if (exist)
|
||||
return false;
|
||||
|
||||
lnode_succ->push_back(n);
|
||||
n->add_pred(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -81,13 +83,16 @@ namespace spot
|
|||
void
|
||||
spoiler_node::add_pred(spoiler_node* n)
|
||||
{
|
||||
bool exist = false;
|
||||
for (sn_v::iterator i = lnode_pred->begin();
|
||||
i != lnode_pred->end(); ++i)
|
||||
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)
|
||||
exist = true;
|
||||
if (!exist)
|
||||
lnode_pred->push_back(n);
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -107,9 +112,28 @@ namespace spot
|
|||
{
|
||||
not_win |= (*i)->not_win;
|
||||
}
|
||||
if (change != not_win)
|
||||
for (Sgi::vector<spoiler_node*>::iterator i = lnode_pred->begin();
|
||||
i != lnode_pred->end(); ++i)
|
||||
(*i)->set_win();
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -203,10 +227,36 @@ namespace spot
|
|||
not_win &= (*i)->not_win;
|
||||
}
|
||||
}
|
||||
if (change != not_win)
|
||||
for (Sgi::vector<spoiler_node*>::iterator i = lnode_pred->begin();
|
||||
i != lnode_pred->end(); ++i)
|
||||
(*i)->set_win();
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -391,7 +441,7 @@ namespace spot
|
|||
// parity_game_graph_direct
|
||||
|
||||
void
|
||||
parity_game_graph_direct::build_couple()
|
||||
parity_game_graph_direct::build_graph()
|
||||
{
|
||||
tgba_succ_iterator* si = 0;
|
||||
typedef Sgi::pair<bdd, bdd> couple_bdd;
|
||||
|
|
@ -541,8 +591,218 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
parity_game_graph_direct::prune()
|
||||
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()
|
||||
{
|
||||
bool change = true;
|
||||
|
||||
|
|
@ -562,7 +822,6 @@ namespace spot
|
|||
change |= (*i)->set_win();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
simulation_relation*
|
||||
|
|
@ -607,9 +866,9 @@ namespace spot
|
|||
parity_game_graph_direct::parity_game_graph_direct(const tgba* a)
|
||||
: parity_game_graph(a)
|
||||
{
|
||||
this->build_couple();
|
||||
this->build_graph();
|
||||
this->build_link();
|
||||
this->prune();
|
||||
this->lift();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -106,18 +106,18 @@ namespace spot
|
|||
void process_link(int in, int out, const tgba_succ_iterator* si);
|
||||
|
||||
/// \brief Compute each node of the graph.
|
||||
virtual void build_couple() = 0;
|
||||
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;
|
||||
//virtual void build_link() = 0;
|
||||
|
||||
/// \brief Remove edge from spoiler to duplicator that make
|
||||
/// duplicator loose.
|
||||
/// Spoiler node whose still have some link, reveal
|
||||
/// a direct simulation relation.
|
||||
virtual void prune() = 0;
|
||||
virtual void lift() = 0;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -196,10 +196,27 @@ namespace spot
|
|||
virtual simulation_relation* get_relation();
|
||||
|
||||
protected:
|
||||
virtual void build_graph();
|
||||
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);
|
||||
*/
|
||||
|
||||
virtual void build_couple();
|
||||
virtual void build_link();
|
||||
virtual void prune();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -213,23 +230,27 @@ namespace spot
|
|||
spoiler_node_delayed(const state* d_node,
|
||||
const state* s_node,
|
||||
bdd a,
|
||||
int num);
|
||||
int num,
|
||||
bool l2a = true);
|
||||
~spoiler_node_delayed();
|
||||
|
||||
/// Return true if the progress_measure has changed.
|
||||
bool set_win();
|
||||
bdd get_acceptance_condition_visited() const;
|
||||
virtual bool compare(spoiler_node* n);
|
||||
|
||||
virtual std::string to_string(const tgba* a);
|
||||
|
||||
int get_progress_measure() const;
|
||||
|
||||
bool get_lead_2_acc_all();
|
||||
/*
|
||||
void set_lead_2_acc_all();
|
||||
*/
|
||||
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_;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -247,14 +268,15 @@ namespace spot
|
|||
/// Return true if the progress_measure has changed.
|
||||
bool set_win();
|
||||
virtual std::string to_string(const tgba* a);
|
||||
|
||||
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();
|
||||
|
||||
protected:
|
||||
int progress_measure_;
|
||||
bool lead_2_acc_all_;
|
||||
};
|
||||
|
||||
/// Parity game graph which compute the delayed simulation relation
|
||||
|
|
@ -311,17 +333,20 @@ namespace spot
|
|||
int nb);
|
||||
|
||||
/// \brief Compute the couple as for direct simulation,
|
||||
virtual void build_couple();
|
||||
virtual void build_link();
|
||||
void build_recurse_successor_spoiler(spoiler_node* sn);
|
||||
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);
|
||||
spoiler_node* sn,
|
||||
std::ostringstream& os);
|
||||
|
||||
/// \brief The Jurdzinski's lifting algorithm.
|
||||
void lift();
|
||||
virtual void lift();
|
||||
|
||||
/// \brief Remove all node so as to there is no dead ends (terminal node).
|
||||
virtual void prune();
|
||||
//virtual void prune();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,18 +41,22 @@ namespace spot
|
|||
spoiler_node_delayed::spoiler_node_delayed(const state* d_node,
|
||||
const state* s_node,
|
||||
bdd a,
|
||||
int num)
|
||||
int num,
|
||||
bool l2a)
|
||||
: spoiler_node(d_node, s_node, num),
|
||||
acceptance_condition_visited_(a)
|
||||
{
|
||||
nb_spoiler++;
|
||||
progress_measure_ = 0;
|
||||
if (acceptance_condition_visited_ == bddfalse)
|
||||
if (acceptance_condition_visited_ != bddfalse)
|
||||
nb_spoiler_loose_++;
|
||||
lead_2_acc_all_ = l2a;
|
||||
}
|
||||
|
||||
spoiler_node_delayed::~spoiler_node_delayed()
|
||||
{
|
||||
if (acceptance_condition_visited_ != bddfalse)
|
||||
nb_spoiler_loose_--;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -64,9 +68,9 @@ namespace spot
|
|||
//std::cout << "spoiler_node_delayed::set_win" << std::endl;
|
||||
|
||||
if (lnode_succ->size() == 0)
|
||||
progress_measure_ = nb_spoiler_loose_;
|
||||
progress_measure_ = nb_spoiler_loose_ + 1;
|
||||
|
||||
if (progress_measure_ >= nb_spoiler_loose_)
|
||||
if (progress_measure_ >= nb_spoiler_loose_ + 1)
|
||||
return false;
|
||||
|
||||
bool change;
|
||||
|
|
@ -90,7 +94,8 @@ namespace spot
|
|||
// If the priority of the node is 1
|
||||
// acceptance_condition_visited_ != bddfalse
|
||||
// then we increment the progress measure of 1.
|
||||
if (acceptance_condition_visited_ != bddfalse)
|
||||
if ((acceptance_condition_visited_ != bddfalse) &&
|
||||
(tmpmax < (nb_spoiler_loose_ + 1)))
|
||||
tmpmax++;
|
||||
|
||||
change = (progress_measure_ < tmpmax);
|
||||
|
|
@ -102,7 +107,7 @@ namespace spot
|
|||
bool
|
||||
spoiler_node_delayed::compare(spoiler_node* n)
|
||||
{
|
||||
std::cout << "spoiler_node_delayed::compare" << std::endl;
|
||||
//std::cout << "spoiler_node_delayed::compare" << std::endl;
|
||||
return (this->spoiler_node::compare(n) &&
|
||||
(acceptance_condition_visited_ ==
|
||||
dynamic_cast<spoiler_node_delayed*>(n)->
|
||||
|
|
@ -153,6 +158,19 @@ namespace spot
|
|||
return progress_measure_;
|
||||
}
|
||||
|
||||
bool
|
||||
spoiler_node_delayed::get_lead_2_acc_all()
|
||||
{
|
||||
return lead_2_acc_all_;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
spoiler_node_delayed::set_lead_2_acc_all()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// duplicator_node_delayed
|
||||
|
||||
|
|
@ -179,9 +197,10 @@ namespace spot
|
|||
|
||||
//std::cout << "duplicator_node_delayed::set_win" << std::endl;
|
||||
|
||||
//bool debug = true;
|
||||
if (lnode_succ->size() == 0)
|
||||
progress_measure_ = nb_spoiler_loose_ + 1;
|
||||
|
||||
if (progress_measure_ == nb_spoiler_loose_)
|
||||
if (progress_measure_ >= nb_spoiler_loose_ + 1)
|
||||
return false;
|
||||
|
||||
bool change;
|
||||
|
|
@ -192,32 +211,15 @@ namespace spot
|
|||
{
|
||||
tmpmin =
|
||||
dynamic_cast<spoiler_node_delayed*>(*i)->get_progress_measure();
|
||||
/*
|
||||
debug &= (dynamic_cast<spoiler_node_delayed*>(*i)
|
||||
->get_acceptance_condition_visited()
|
||||
!= bddfalse);
|
||||
*/
|
||||
++i;
|
||||
}
|
||||
for (; i != lnode_succ->end(); ++i)
|
||||
{
|
||||
/*
|
||||
debug &= (dynamic_cast<spoiler_node_delayed*>(*i)
|
||||
->get_acceptance_condition_visited()
|
||||
!= bddfalse);
|
||||
*/
|
||||
tmp = dynamic_cast<spoiler_node_delayed*>(*i)->get_progress_measure();
|
||||
if (tmp < tmpmin)
|
||||
tmpmin = tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
if (debug)
|
||||
std::cout << "All successor p = 1" << std::endl;
|
||||
else
|
||||
std::cout << "Not All successor p = 1" << std::endl;
|
||||
*/
|
||||
|
||||
change = (progress_measure_ < tmpmin);
|
||||
progress_measure_ = tmpmin;
|
||||
return change;
|
||||
|
|
@ -261,6 +263,22 @@ namespace spot
|
|||
return progress_measure_;
|
||||
}
|
||||
|
||||
bool
|
||||
duplicator_node_delayed::get_lead_2_acc_all()
|
||||
{
|
||||
return lead_2_acc_all_;
|
||||
}
|
||||
|
||||
void
|
||||
duplicator_node_delayed::set_lead_2_acc_all()
|
||||
{
|
||||
if (!lead_2_acc_all_)
|
||||
for (sn_v::iterator i = lnode_succ->begin();
|
||||
i != lnode_succ->end(); ++i)
|
||||
lead_2_acc_all_
|
||||
|= dynamic_cast<spoiler_node_delayed*>(*i)->get_lead_2_acc_all();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// parity_game_graph_delayed
|
||||
|
||||
|
|
@ -527,12 +545,12 @@ namespace spot
|
|||
|
||||
// We build only node which are reachable
|
||||
void
|
||||
parity_game_graph_delayed::build_couple()
|
||||
parity_game_graph_delayed::build_graph()
|
||||
{
|
||||
// We build only some "basic" spoiler node.
|
||||
|
||||
s_v::iterator i;
|
||||
for (i = tgba_state_.begin(); i != tgba_state_.end(); ++i)
|
||||
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)
|
||||
|
|
@ -540,93 +558,92 @@ namespace spot
|
|||
for (i2 = tgba_state_.begin();
|
||||
i2 != tgba_state_.end(); ++i2)
|
||||
{
|
||||
std::cout << "add spoiler node" << std::endl;
|
||||
//std::cout << "add spoiler node" << std::endl;
|
||||
nb_spoiler++;
|
||||
spoiler_node_delayed* n1
|
||||
= new spoiler_node_delayed(*i, *i2,
|
||||
= new spoiler_node_delayed(*i1, *i2,
|
||||
bddfalse,
|
||||
nb_node_parity_game++);
|
||||
spoiler_vertice_.push_back(n1);
|
||||
tab_temp.push_back(n1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
parity_game_graph_delayed::build_link()
|
||||
{
|
||||
// We create when it's possible a duplicator node
|
||||
// and recursively his successor.
|
||||
|
||||
//spot::state* s1 = 0;
|
||||
//bool exist_pred = false;
|
||||
|
||||
sn_v::iterator i1;
|
||||
int n = 0;
|
||||
for (i1 = spoiler_vertice_.begin(); i1 != spoiler_vertice_.end(); ++i1)
|
||||
sn_v::iterator j;
|
||||
std::ostringstream os;
|
||||
for (j = tab_temp.begin(); j != tab_temp.end(); ++j)
|
||||
{
|
||||
/*
|
||||
exist_pred = false;
|
||||
|
||||
// We check if there is a predecessor only if the duplicator
|
||||
// is the initial state.
|
||||
s1 = automata_->get_init_state();
|
||||
if (s1->compare((*i1)->get_duplicator_node()) == 0)
|
||||
{
|
||||
tgba_succ_iterator* si;
|
||||
s_v::iterator i2;
|
||||
spot::state* s2 = 0;
|
||||
for (i2 = tgba_state_.begin();
|
||||
i2 != tgba_state_.end(); ++i2)
|
||||
{
|
||||
si = automata_->succ_iter(*i2);
|
||||
s2 = si->current_state();
|
||||
if (s2->compare(s1) == 0)
|
||||
exist_pred = true;
|
||||
delete s2;
|
||||
}
|
||||
}
|
||||
else
|
||||
exist_pred = true;
|
||||
delete s1;
|
||||
|
||||
if (!exist_pred)
|
||||
continue;
|
||||
*/
|
||||
|
||||
// We add a link between a spoiler and a (new) duplicator.
|
||||
// The acc of the duplicator must contains the
|
||||
// acceptance_condition_visited_ of the spoiler.
|
||||
std::cout << "build_link : iter " << ++n << std::endl;
|
||||
build_recurse_successor_spoiler(*i1);
|
||||
//std::cout << "build_link : iter " << ++n << std::endl;
|
||||
|
||||
/*
|
||||
std::cout << "["
|
||||
<< automata_->format_state((*j)->get_spoiler_node())
|
||||
<< "] // ["
|
||||
<< automata_->format_state((*j)->get_duplicator_node())
|
||||
<< "]"
|
||||
<< std::endl;
|
||||
*/
|
||||
|
||||
build_recurse_successor_spoiler(*j, os);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
parity_game_graph_delayed::build_recurse_successor_spoiler(spoiler_node* sn)
|
||||
parity_game_graph_delayed::
|
||||
build_recurse_successor_spoiler(spoiler_node* sn,
|
||||
std::ostringstream& os)
|
||||
{
|
||||
std::cout << "build_recurse_successor_spoiler" << std::endl;
|
||||
//std::cout << os.str() << "build_recurse_successor_spoiler : begin"
|
||||
//<< std::endl;
|
||||
|
||||
// FIXME
|
||||
if (sn == 0)
|
||||
return;
|
||||
|
||||
tgba_succ_iterator* si = automata_->succ_iter(sn->get_spoiler_node());
|
||||
|
||||
int i = 0;
|
||||
//int i = 0;
|
||||
for (si->first(); !si->done(); si->next())
|
||||
{
|
||||
std::cout << "transition " << i++ << std::endl;
|
||||
//std::cout << "transition " << i++ << std::endl;
|
||||
|
||||
bdd btmp = si->current_acceptance_conditions() |
|
||||
dynamic_cast<spoiler_node_delayed*>(sn)->
|
||||
get_acceptance_condition_visited();
|
||||
|
||||
|
||||
// If the spoiler node has witnessed an accepting condition,
|
||||
// so we force to play on an arc which have a different accepting
|
||||
// condition. => FALSE !!!!!!
|
||||
/*
|
||||
if ((dynamic_cast<spoiler_node_delayed*>(sn)->
|
||||
get_acceptance_condition_visited() ==
|
||||
si->current_acceptance_conditions()) &&
|
||||
(si->current_acceptance_conditions() != bddfalse))
|
||||
continue;
|
||||
*/
|
||||
|
||||
/*
|
||||
if (btmp == bddfalse)
|
||||
std::cout << "btmp == bddfasle" << std::endl;
|
||||
else
|
||||
std::cout << "btmp != bddfasle" << std::endl;
|
||||
*/
|
||||
|
||||
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_delayed* dn
|
||||
= add_duplicator_node_delayed(*i1,
|
||||
sn->get_duplicator_node(),
|
||||
|
|
@ -634,54 +651,49 @@ namespace spot
|
|||
btmp,
|
||||
nb_node_parity_game++);
|
||||
|
||||
std::cout << "spoiler call add_succ" << std::endl;
|
||||
if (!(sn->add_succ(dn)))
|
||||
{
|
||||
// dn is already a successor of sn.
|
||||
std::cout << "dn is already a successor of sn."
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
std::cout << "dn is a new successor of sn." << std::endl;
|
||||
(dn)->add_pred(sn);
|
||||
|
||||
build_recurse_successor_duplicator(dn, sn);
|
||||
std::ostringstream os2;
|
||||
os2 << os.str() << " ";
|
||||
build_recurse_successor_duplicator(dn, sn, os2);
|
||||
}
|
||||
delete s;
|
||||
else
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
delete si;
|
||||
|
||||
//std::cout << os.str() << "build_recurse_successor_spoiler : end"
|
||||
//<< std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
parity_game_graph_delayed::
|
||||
build_recurse_successor_duplicator(duplicator_node* dn,
|
||||
spoiler_node*)
|
||||
spoiler_node* ,
|
||||
std::ostringstream& os)
|
||||
{
|
||||
std::cout << "build_recurse_successor_duplicator" << std::endl;
|
||||
//std::cout << "build_recurse_successor_duplicator : begin" << std::endl;
|
||||
|
||||
tgba_succ_iterator* si = automata_->succ_iter(dn->get_duplicator_node());
|
||||
|
||||
int i = 0;
|
||||
for (si->first(); !si->done(); si->next())
|
||||
{
|
||||
std::cout << "transition " << i++ << std::endl;
|
||||
|
||||
/*
|
||||
bdd btmp =
|
||||
dynamic_cast<spoiler_node_delayed*>(sn)->
|
||||
get_acceptance_condition_visited();
|
||||
*/
|
||||
|
||||
bdd btmp = dn->get_acc();
|
||||
bdd btmp2 = btmp - si->current_acceptance_conditions();
|
||||
|
||||
/*
|
||||
if (btmp2 == bddfalse)
|
||||
// if si->current_condition() doesn't implies sn->get_label()
|
||||
// then duplicator can't play.
|
||||
if ((!dn->get_label() | si->current_condition()) != bddtrue)
|
||||
continue;
|
||||
|
||||
// FIXME
|
||||
/*
|
||||
bdd btmp = dn->get_acc();
|
||||
bdd btmp2 = btmp - (btmp & si->current_acceptance_conditions());
|
||||
*/
|
||||
bdd btmp = dn->get_acc() -
|
||||
(dn->get_acc() & si->current_acceptance_conditions());
|
||||
|
||||
s_v::iterator i1;
|
||||
state* s;
|
||||
|
|
@ -689,34 +701,32 @@ namespace spot
|
|||
i1 != tgba_state_.end(); ++i1)
|
||||
{
|
||||
s = si->current_state();
|
||||
|
||||
if (s->compare(*i1) == 0)
|
||||
{
|
||||
delete s;
|
||||
spoiler_node_delayed* sn_n
|
||||
= add_spoiler_node_delayed(dn->get_spoiler_node(),
|
||||
*i1,
|
||||
btmp2,
|
||||
btmp,
|
||||
nb_node_parity_game++);
|
||||
|
||||
// sn_n is already a successor of dn.
|
||||
std::cout << "duplicator call add_succ" << std::endl;
|
||||
if (!(dn->add_succ(sn_n)))
|
||||
{
|
||||
std::cout << "sn_n is already a successor of dn."
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
std::cout << "sn_n is a new successor of dn." << std::endl;
|
||||
(sn_n)->add_pred(dn);
|
||||
|
||||
build_recurse_successor_spoiler(sn_n);
|
||||
continue;
|
||||
|
||||
std::ostringstream os2;
|
||||
os2 << os.str() << " ";
|
||||
build_recurse_successor_spoiler(sn_n, os2);
|
||||
}
|
||||
delete s;
|
||||
else
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
delete si;
|
||||
|
||||
//std::cout << os.str() << "build_recurse_successor_duplicator : end"
|
||||
//<< std::endl;
|
||||
}
|
||||
|
||||
duplicator_node_delayed*
|
||||
|
|
@ -735,7 +745,6 @@ namespace spot
|
|||
= duplicator_vertice_.begin();
|
||||
i != duplicator_vertice_.end(); ++i)
|
||||
{
|
||||
//std::cout << "COMPARE" << std::endl;
|
||||
if (dn_n->compare(*i))
|
||||
{
|
||||
exist = true;
|
||||
|
|
@ -759,14 +768,14 @@ namespace spot
|
|||
{
|
||||
bool exist = false;
|
||||
|
||||
//bool l2a = (acc != automata_->all_acceptance_conditions());
|
||||
spoiler_node_delayed* sn_n
|
||||
= new spoiler_node_delayed(sn, dn, acc, nb);
|
||||
= new spoiler_node_delayed(sn, dn, acc, nb, false);
|
||||
|
||||
for (Sgi::vector<spoiler_node*>::iterator i
|
||||
= spoiler_vertice_.begin();
|
||||
i != spoiler_vertice_.end(); ++i)
|
||||
{
|
||||
//std::cout << "COMPARE" << std::endl;
|
||||
if (sn_n->compare(*i))
|
||||
{
|
||||
exist = true;
|
||||
|
|
@ -777,11 +786,12 @@ namespace spot
|
|||
}
|
||||
|
||||
if (!exist)
|
||||
spoiler_vertice_.push_back(sn_n);
|
||||
spoiler_vertice_.push_back(sn_n);
|
||||
|
||||
return sn_n;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
parity_game_graph_delayed::prune()
|
||||
{
|
||||
|
|
@ -839,17 +849,29 @@ namespace spot
|
|||
<< duplicator_vertice_.size()
|
||||
<< std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
parity_game_graph_delayed::lift()
|
||||
{
|
||||
// Before the lift we compute each vertices
|
||||
// to know if he belong to a all accepting cycle
|
||||
// of the graph.
|
||||
for (Sgi::vector<duplicator_node*>::iterator i
|
||||
= duplicator_vertice_.begin();
|
||||
i != duplicator_vertice_.end(); ++i)
|
||||
{
|
||||
if (dynamic_cast<duplicator_node_delayed*>(*i)->get_lead_2_acc_all())
|
||||
dynamic_cast<duplicator_node_delayed*>(*i)->set_lead_2_acc_all();
|
||||
}
|
||||
|
||||
// Jurdzinski's algorithm
|
||||
//int iter = 0;
|
||||
bool change = true;
|
||||
|
||||
while (change)
|
||||
{
|
||||
std::cout << "lift::change = true" << std::endl;
|
||||
//std::cout << "lift::change = true" << std::endl;
|
||||
change = false;
|
||||
for (Sgi::vector<duplicator_node*>::iterator i
|
||||
= duplicator_vertice_.begin();
|
||||
|
|
@ -864,7 +886,7 @@ namespace spot
|
|||
change |= (*i)->set_win();
|
||||
}
|
||||
}
|
||||
std::cout << "lift::change = false" << std::endl;
|
||||
//std::cout << "lift::change = false" << std::endl;
|
||||
}
|
||||
|
||||
simulation_relation*
|
||||
|
|
@ -879,7 +901,7 @@ namespace spot
|
|||
i != spoiler_vertice_.end(); ++i)
|
||||
{
|
||||
if (dynamic_cast<spoiler_node_delayed*>(*i)->get_progress_measure()
|
||||
< nb_spoiler_loose_)
|
||||
< nb_spoiler_loose_ + 1)
|
||||
{
|
||||
p = new state_couple((*i)->get_spoiler_node(),
|
||||
(*i)->get_duplicator_node());
|
||||
|
|
@ -909,20 +931,23 @@ namespace spot
|
|||
: parity_game_graph(a)
|
||||
{
|
||||
nb_spoiler_loose_ = 0;
|
||||
/*
|
||||
if (this->nb_set_acc_cond() > 2)
|
||||
return;
|
||||
this->build_sub_set_acc_cond();
|
||||
|
||||
/* FIXME
|
||||
if (this->nb_set_acc_cond() > 1)
|
||||
return;
|
||||
*/
|
||||
std::cout << "build couple" << std::endl;
|
||||
this->build_couple();
|
||||
std::cout << "build link" << std::endl;
|
||||
this->build_link();
|
||||
std::cout << "prune" << std::endl;
|
||||
this->prune();
|
||||
std::cout << "lift : " << nb_spoiler_loose_ << std::endl;
|
||||
|
||||
//this->build_sub_set_acc_cond();
|
||||
//std::cout << "build couple" << std::endl;
|
||||
this->build_graph();
|
||||
//std::cout << "build link" << std::endl;
|
||||
//this->build_link();
|
||||
//std::cout << "prune" << std::endl;
|
||||
//this->prune();
|
||||
std::cout << "lift begin : " << nb_spoiler_loose_ << std::endl;
|
||||
this->lift();
|
||||
std::cout << "END" << std::endl;
|
||||
std::cout << "lift end : " << nb_spoiler_loose_ << std::endl;
|
||||
//std::cout << "END" << std::endl;
|
||||
//this->print(std::cout);
|
||||
}
|
||||
|
||||
|
|
@ -934,7 +959,7 @@ namespace spot
|
|||
/// Don't use it !!
|
||||
parity_game_graph_delayed* G = new parity_game_graph_delayed(f);
|
||||
simulation_relation* rel = G->get_relation();
|
||||
if ((opt == 1) || (opt == -1))
|
||||
if (opt == 1)
|
||||
G->print(std::cout);
|
||||
delete G;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue