00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_TOOLS_GEN_RANDOM_HH
00019 # define VCSN_TOOLS_GEN_RANDOM_HH
00020
00021 # include <vaucanson/misc/selectors.hh>
00022 # include <vaucanson/algebra/implementation/monoid/monoid_rep.hh>
00023 # include <vaucanson/automata/concept/transducer.hh>
00024
00025
00026
00027
00028
00029
00030 # define ALPHABET_MAX_SIZE 1024
00031
00032 namespace vcsn {
00033
00034 namespace tools {
00035
00036
00037
00038
00039
00040 class GenRandomAutomataSet
00041 {
00042 public:
00043
00044 template <class AutoSet>
00045 static AutoSet generate(SELECTOR(AutomataBase<AutoSet>),
00046 unsigned nb_letter = 0);
00047
00048 template <class AutoSet>
00049 static AutoSet generate(SELECTOR(TransducerBase<AutoSet>),
00050 unsigned input_nb_letter = 0,
00051 unsigned output_nb_letter = 0);
00052 };
00053
00054
00055
00056
00057
00058
00059 template <class TAutomata, class AutomataSetGenerator = GenRandomAutomataSet>
00060 class GenRandomAutomata
00061 {
00062 public:
00063 typedef typename TAutomata::set_t automata_set_t;
00064 typedef typename TAutomata::hstate_t hstate_t;
00065
00066 public:
00067 GenRandomAutomata();
00068
00069 TAutomata empty(unsigned nb_letter = 0);
00070 TAutomata empty(const automata_set_t& set);
00071
00072 TAutomata generate(unsigned nb_state, unsigned nb_transition,
00073 unsigned istate = 1, unsigned fstate = 1,
00074 unsigned nb_letter = 0);
00075 TAutomata generate(const automata_set_t& set,
00076 unsigned nb_state, unsigned nb_transition,
00077 unsigned istate = 1, unsigned fstate = 1);
00078
00079 TAutomata generate_dfa(unsigned nb_state,
00080 unsigned size_alphabet = 0,
00081 unsigned fstate = 1);
00082 TAutomata generate_dfa(const automata_set_t& set,
00083 unsigned nb_state,
00084 unsigned fstate = 1);
00085
00086 TAutomata generate_with_epsilon(unsigned nb_state, unsigned nb_transition,
00087 unsigned nb_epsilon_min,
00088 unsigned nb_epsilon_max);
00089 TAutomata generate_with_epsilon(const automata_set_t& set,
00090 unsigned nb_state, unsigned nb_transition,
00091 unsigned nb_epsilon_min,
00092 unsigned nb_epsilon_max);
00093
00094 TAutomata generate_normalized(unsigned nb_state, unsigned density = 3);
00095 TAutomata generate_normalized(const automata_set_t& set,
00096 unsigned nb_state, unsigned density = 3);
00097
00098
00099 private:
00100
00101 unsigned nb_transition_circle(TAutomata work, hstate_t state);
00102 void del_transition_circle(TAutomata& work, hstate_t state);
00103
00104 };
00105
00106 static unsigned alea(unsigned max);
00107
00108 }
00109
00110 }
00111
00112 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00113 # include <vaucanson/tools/gen_random.hxx>
00114 # endif // VCSN_USE_INTERFACE_ONLY
00115
00116 #endif // ! VCSN_TOOLS_GEN_RANDOM_HH