![]() |
Vcsn
2.3a
Be Rational
|
Class random expression generator. More...
#include <random-expression.hh>
Public Types | |
using | expressionset_t = ExpressionSet |
using | expression_t = typename expressionset_t::value_t |
using | weight_t = typename expressionset_t::weight_t |
using | weightset_t = typename expressionset_t::weightset_t |
Public Member Functions | |
random_expression_impl (const expressionset_t &rs, const std::string ¶m, RandomGenerator &gen) | |
std::ostream & | print_random_expression (std::ostream &out) const |
Print a random expression string (not parsed, so there might be some syntactic sugar such as <+ ). More... | |
std::string | random_expression_string () const |
A random expression string (not parsed, so there might be some syntactic sugar such as <+ ). More... | |
expression_t | random_expression () const |
A random expression (parsed, so there cannot be syntactic sugar such as <+ ). More... | |
Private Member Functions | |
void | parse_param_ (const std::string ¶m) |
FIXME: maybe use something similar to Boost.ProgramOptions or getargs. More... | |
void | print_weight_ (std::ostream &out) const |
Print random weight. More... | |
void | print_label_ (std::ostream &out) const |
Print label. More... | |
void | print_unary_exp_ (std::ostream &out, unsigned length, const std::string &op) const |
Print expression with unary operator. More... | |
void | print_binary_exp_ (std::ostream &out, unsigned length, const std::string &op) const |
Print binary expression with binary operator. More... | |
std::ostream & | print_random_expression_ (std::ostream &out, unsigned length) const |
Private Attributes | |
expressionset_t | rs_ |
weightset_t | ws_ |
unsigned | length_ |
std::map< std::string, float > | operators_ |
For each operator, its probability. More... | |
std::unordered_map< std::string, int > | arities_ |
Number of arguments of each operator. More... | |
std::vector< float > | proba_op_ |
Vector of weights associated with the operators, i.e., the probabilities to pick each operator. More... | |
RandomGenerator & | gen_ |
Random generator. More... | |
random_weight< weightset_t, RandomGenerator > | random_weight_ {gen_, ws_} |
Random weights generator. More... | |
discrete_chooser< RandomGenerator > | chooser_it_ {gen_} |
Class random expression generator.
Generate a random expression from a context.
ExpressionSet | the expression set type. |
RandomGenerator | the random number engine type. |
Definition at line 29 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expression_t = typename expressionset_t::value_t |
Definition at line 33 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expressionset_t = ExpressionSet |
Definition at line 32 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weight_t = typename expressionset_t::weight_t |
Definition at line 34 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weightset_t = typename expressionset_t::weightset_t |
Definition at line 35 of file random-expression.hh.
|
inline |
Definition at line 37 of file random-expression.hh.
|
inlineprivate |
FIXME: maybe use something similar to Boost.ProgramOptions or getargs.
Definition at line 72 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::arities_, vcsn::has(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::length_, vcsn::detail::lexical_cast(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operators_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::proba_op_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_weight_, vcsn::detail::transform(), and vcsn::detail::v.
|
inlineprivate |
Print binary expression with binary operator.
It is composed of the left and right side, and the operator. The number of symbols is randomly distribued between both side.
Definition at line 149 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_label_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
inlineprivate |
Print label.
Definition at line 113 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_, vcsn::random_label(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
inline |
Print a random expression string (not parsed, so there might be some syntactic sugar such as <+
).
Definition at line 48 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::length_, and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_string().
|
inlineprivate |
Definition at line 167 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::arities_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::chooser_it_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operators_, vcsn::detail::out(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_label_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_unary_exp_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::proba_op_.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_unary_exp_().
|
inlineprivate |
Print expression with unary operator.
Definition at line 119 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_weight_().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
inlineprivate |
Print random weight.
Definition at line 105 of file random-expression.hh.
References vcsn::detail::out(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_weight_, and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_unary_exp_().
|
inline |
A random expression (parsed, so there cannot be syntactic sugar such as <+
).
Definition at line 64 of file random-expression.hh.
References vcsn::conv(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_string(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_.
|
inline |
A random expression string (not parsed, so there might be some syntactic sugar such as <+
).
Definition at line 55 of file random-expression.hh.
References vcsn::detail::out(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression().
|
private |
Number of arguments of each operator.
Definition at line 210 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::parse_param_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
private |
Definition at line 240 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
private |
Random generator.
Definition at line 237 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_label_().
|
private |
|
private |
For each operator, its probability.
Definition at line 207 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::parse_param_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
private |
Vector of weights associated with the operators, i.e., the probabilities to pick each operator.
Definition at line 235 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::parse_param_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
private |
Random weights generator.
Definition at line 239 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::parse_param_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_weight_().
|
private |
Definition at line 203 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_label_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_weight_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression().
|
private |
Definition at line 204 of file random-expression.hh.