Vcsn  2.3
Be Rational
vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator > Class Template Reference

Class random expression generator. More...

#include <random-expression.hh>

Collaboration diagram for vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >:

Public Types

using expressionset_t = ExpressionSet
 
using expression_t = typename expressionset_t::value_t
 

Public Member Functions

 random_expression_impl (const expressionset_t &rs, const std::string &param, 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 Types

using operator_t = std::map< std::string, float >
 
using operator_set_t = std::unordered_set< std::string >
 
using weight_t = std::vector< float >
 

Private Member Functions

void parse_param_ (const std::string &param)
 
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_
 
unsigned length_
 
operator_t operators_
 
operator_set_t nullary_op_ = { "\\e", "\\z" }
 
operator_set_t unary_op_ = { "!", "{c}", "*", "{T}" }
 
operator_set_t binary_op_ = { "&", "&:", ":", ".", "<+", "%", "+", "{/}", "{\\}" }
 
weight_t weight_
 
RandomGenerator & gen_
 

Detailed Description

template<typename ExpressionSet, typename RandomGenerator = std::default_random_engine>
class vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >

Class random expression generator.

Generate a random expression from a context.

Template Parameters
ExpressionSetthe expression set type.
RandomGeneratorthe random number engine type.

Definition at line 29 of file random-expression.hh.

Member Typedef Documentation

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expression_t = typename expressionset_t::value_t

Definition at line 33 of file random-expression.hh.

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expressionset_t = ExpressionSet

Definition at line 32 of file random-expression.hh.

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operator_set_t = std::unordered_set<std::string>
private

Definition at line 68 of file random-expression.hh.

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operator_t = std::map<std::string, float>
private

Definition at line 67 of file random-expression.hh.

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weight_t = std::vector<float>
private

Definition at line 69 of file random-expression.hh.

Constructor & Destructor Documentation

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_impl ( const expressionset_t rs,
const std::string &  param,
RandomGenerator &  gen 
)
inline

Definition at line 35 of file random-expression.hh.

Member Function Documentation

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
void vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_ ( std::ostream &  out,
unsigned  length,
const std::string &  op 
) const
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 120 of file random-expression.hh.

References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_(), vcsn::random_label(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_.

Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().

Here is the call graph for this function:

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
std::ostream& vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression ( std::ostream &  out) const
inline

Print a random expression string (not parsed, so there might be some syntactic sugar such as <+).

Definition at line 45 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().

Here is the call graph for this function:

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
std::ostream& vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_ ( std::ostream &  out,
unsigned  length 
) const
inlineprivate
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
void vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_unary_exp_ ( std::ostream &  out,
unsigned  length,
const std::string &  op 
) const
inlineprivate

Print expression with unary operator.

Definition at line 98 of file random-expression.hh.

References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().

Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().

Here is the call graph for this function:

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
expression_t vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression ( ) const
inline

A random expression (parsed, so there cannot be syntactic sugar such as <+).

Definition at line 61 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_.

Here is the call graph for this function:

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
std::string vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_string ( ) const
inline

A random expression string (not parsed, so there might be some syntactic sugar such as <+).

Definition at line 52 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().

Here is the call graph for this function:

Member Data Documentation

template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
operator_set_t vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::binary_op_ = { "&", "&:", ":", ".", "<+", "%", "+", "{/}", "{\\}" }
private
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
RandomGenerator& vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_
private
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
unsigned vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::length_
private
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
operator_set_t vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::nullary_op_ = { "\\e", "\\z" }
private
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
operator_t vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operators_
private
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
operator_set_t vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::unary_op_ = { "!", "{c}", "*", "{T}" }
private
template<typename ExpressionSet , typename RandomGenerator = std::default_random_engine>
weight_t vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weight_
private

The documentation for this class was generated from the following file: