gen_random.hh

00001 // gen_random.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The
00006 // Vaucanson Group.
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // The complete GNU General Public Licence Notice can be found as the
00014 // `COPYING' file in the root directory.
00015 //
00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
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 // We can have letter types with very large cardinal
00025 // (say int letters). So we clip the max size to
00026 // ALPHABET_MAX_SIZE to ensure the test-suite will
00027 // be able to generate random automata with max-sized
00028 // alphabets.
00029 # define ALPHABET_MAX_SIZE 1024
00030 
00031 namespace vcsn {
00032 
00033   namespace tools {
00034 
00035     /*---------------------.
00036     | GenRandomAutomataSet |
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     | GenRandomAutomata |
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   } // ! tools
00108 
00109 } // ! vcsn
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

Generated on Thu Oct 9 20:22:35 2008 for Vaucanson by  doxygen 1.5.1