- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# 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/algebra/implementation/monoid/monoid_rep.hh>
    00023 # include <vaucanson/automata/concept/transducer.hh>
    00024
    00025 // We can have letter types with very large cardinal
    00026 // (say int letters). So we clip the max size to
    00027 // ALPHABET_MAX_SIZE to ensure the test-suite will
    00028 // be able to generate random automata with max-sized
    00029 // alphabets.
    00030 # define ALPHABET_MAX_SIZE 1024
    00031
    00032 namespace vcsn {
    00033
    00034   namespace tools {
    00035
    00036     /*---------------------.
    00037     | GenRandomAutomataSet |
    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     | GenRandomAutomata |
    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   } // ! tools
    00109
    00110 } // ! vcsn
    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