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