reductgba_sim.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SPOT_TGBAALGOS_REDUCTGBA_SIM_HH
00026 #define SPOT_TGBAALGOS_REDUCTGBA_SIM_HH
00027
00028 #include "tgba/tgbareduc.hh"
00029 #include "tgbaalgos/reachiter.hh"
00030 #include <vector>
00031 #include <list>
00032 #include <sstream>
00033
00034 namespace spot
00035 {
00036
00039
00041 enum reduce_tgba_options
00042 {
00043
00044
00045 #ifndef SWIG
00046
00047 Reduce_None = 0,
00048 #endif
00049
00050 Reduce_quotient_Dir_Sim = 1,
00052 Reduce_transition_Dir_Sim = 2,
00054 Reduce_quotient_Del_Sim = 4,
00056 Reduce_transition_Del_Sim = 8,
00058 Reduce_Scc = 16,
00059 #ifndef SWIG
00060
00061 Reduce_All = -1U
00062 #endif
00063 };
00064
00072 const tgba* reduc_tgba_sim(const tgba* a, int opt = Reduce_All);
00073
00074 #ifndef SWIG
00075
00077 direct_simulation_relation* get_direct_relation_simulation(const tgba* a,
00078 std::ostream& os,
00079 int opt = -1);
00080
00083 delayed_simulation_relation* get_delayed_relation_simulation(const tgba* a,
00084 std::ostream& os,
00085 int opt = -1);
00086
00088 void free_relation_simulation(direct_simulation_relation* rel);
00090 void free_relation_simulation(delayed_simulation_relation* rel);
00091
00093
00094
00095 class spoiler_node;
00096 class duplicator_node;
00097
00098 typedef std::vector<spoiler_node*> sn_v;
00099 typedef std::vector<duplicator_node*> dn_v;
00100 typedef std::vector<const state*> s_v;
00101
00103 class parity_game_graph : public tgba_reachable_iterator_breadth_first
00104 {
00105 public:
00106 parity_game_graph(const tgba* a);
00107 virtual ~parity_game_graph();
00108
00109 virtual simulation_relation* get_relation() = 0;
00110
00111 void print(std::ostream& os);
00112
00113 protected:
00114 sn_v spoiler_vertice_;
00115 dn_v duplicator_vertice_;
00116 s_v tgba_state_;
00117 int nb_node_parity_game;
00118
00119 void start();
00120 void end();
00121 void process_state(const state* s, int n, tgba_succ_iterator* si);
00122 void process_link(int in, int out, const tgba_succ_iterator* si);
00123
00125 virtual void build_graph() = 0;
00126
00131 virtual void lift() = 0;
00132 };
00133
00135
00136
00138 class spoiler_node
00139 {
00140 public:
00141 spoiler_node(const state* d_node,
00142 const state* s_node,
00143 int num);
00144 virtual ~spoiler_node();
00145
00149 bool add_succ(spoiler_node* n);
00150 void del_succ(spoiler_node* n);
00151 virtual void add_pred(spoiler_node* n);
00152 virtual void del_pred();
00153 int get_nb_succ();
00154 bool prune();
00155 virtual bool set_win();
00156 virtual std::string to_string(const tgba* a);
00157 virtual std::string succ_to_string();
00158 virtual bool compare(spoiler_node* n);
00159
00160 const state* get_spoiler_node();
00161 const state* get_duplicator_node();
00162 state_couple* get_pair();
00163
00164 bool not_win;
00165 int num_;
00166
00167 protected:
00168 sn_v* lnode_succ;
00169 sn_v* lnode_pred;
00170 state_couple* sc_;
00171 };
00172
00174 class duplicator_node : public spoiler_node
00175 {
00176 public:
00177 duplicator_node(const state* d_node,
00178 const state* s_node,
00179 bdd l,
00180 bdd a,
00181 int num);
00182 virtual ~duplicator_node();
00183
00184 virtual bool set_win();
00185 virtual std::string to_string(const tgba* a);
00186 virtual bool compare(spoiler_node* n);
00187
00188 bool match(bdd l, bdd a);
00189 bool implies(bdd l, bdd a);
00190
00191 bdd get_label() const;
00192 bdd get_acc() const;
00193
00194 protected:
00195 bdd label_;
00196 bdd acc_;
00197 };
00198
00200 class parity_game_graph_direct : public parity_game_graph
00201 {
00202 public:
00203 parity_game_graph_direct(const tgba* a);
00204 ~parity_game_graph_direct();
00205
00206 virtual direct_simulation_relation* get_relation();
00207
00208 protected:
00209 virtual void build_graph();
00210 virtual void lift();
00211 void build_link();
00212
00213 };
00214
00215
00217
00218
00220 class spoiler_node_delayed : public spoiler_node
00221 {
00222 public:
00223 spoiler_node_delayed(const state* d_node,
00224 const state* s_node,
00225 bdd a,
00226 int num);
00227 ~spoiler_node_delayed();
00228
00230 bool set_win();
00231 bdd get_acceptance_condition_visited() const;
00232 virtual bool compare(spoiler_node* n);
00233 virtual std::string to_string(const tgba* a);
00234 int get_progress_measure() const;
00235
00236 bool get_lead_2_acc_all();
00237 bool set_lead_2_acc_all(bdd acc = bddfalse);
00238
00239
00240 bool seen_;
00241 protected:
00244 bdd acceptance_condition_visited_;
00245 int progress_measure_;
00246 bool lead_2_acc_all_;
00247 };
00248
00250 class duplicator_node_delayed : public duplicator_node
00251 {
00252 public:
00253 duplicator_node_delayed(const state* d_node,
00254 const state* s_node,
00255 bdd l,
00256 bdd a,
00257 int num);
00258 ~duplicator_node_delayed();
00259
00261 bool set_win();
00262 virtual std::string to_string(const tgba* a);
00263 bool implies_label(bdd l);
00264 bool implies_acc(bdd a);
00265 int get_progress_measure();
00266
00267 bool get_lead_2_acc_all();
00268 bool set_lead_2_acc_all(bdd acc = bddfalse);
00269
00270
00271 bool seen_;
00272 protected:
00273 int progress_measure_;
00274 bool lead_2_acc_all_;
00275 };
00276
00277
00297 class parity_game_graph_delayed: public parity_game_graph
00298 {
00299 public:
00300 parity_game_graph_delayed(const tgba* a);
00301 ~parity_game_graph_delayed();
00302
00303 virtual delayed_simulation_relation* get_relation();
00304
00305 private:
00306
00309 typedef std::vector<bdd> bdd_v;
00310 bdd_v sub_set_acc_cond_;
00311
00313 int nb_set_acc_cond();
00314
00316 duplicator_node_delayed* add_duplicator_node_delayed(const spot::state* sn,
00317 const spot::state* dn,
00318 bdd acc,
00319 bdd label,
00320 int nb);
00321
00323 spoiler_node_delayed* add_spoiler_node_delayed(const spot::state* sn,
00324 const spot::state* dn,
00325 bdd acc,
00326 int nb);
00327
00328 void build_recurse_successor_spoiler(spoiler_node* sn,
00329 std::ostringstream& os);
00330 void build_recurse_successor_duplicator(duplicator_node* dn,
00331 spoiler_node* sn,
00332 std::ostringstream& os);
00333
00335 virtual void build_graph();
00336
00338 virtual void lift();
00339 };
00340
00341 #endif // SWIG
00342
00344 }
00345
00346 #endif // SPOT_TGBAALGOS_REDUCTGBA_SIM_HH