![]() |
Vcsn
2.5
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 28 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expression_t = typename expressionset_t::value_t |
Definition at line 32 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expressionset_t = ExpressionSet |
Definition at line 31 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weight_t = typename expressionset_t::weight_t |
Definition at line 33 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weightset_t = typename expressionset_t::weightset_t |
Definition at line 34 of file random-expression.hh.
|
inline |
Definition at line 36 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_, and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::parse_param_().
|
inlineprivate |
FIXME: maybe use something similar to Boost.ProgramOptions or getargs.
Definition at line 71 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::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.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_impl().
|
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 146 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 110 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 47 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 164 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 116 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 102 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 63 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_.
Referenced by vcsn::dyn::random_expression().
|
inline |
A random expression string (not parsed, so there might be some syntactic sugar such as <+
).
Definition at line 54 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 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 |
Definition at line 237 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
private |
Random generator.
Definition at line 234 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_label_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_impl().
|
private |
|
private |
For each operator, its probability.
Definition at line 204 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 232 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 236 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 200 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 201 of file random-expression.hh.