remove \r
[extl.git] / extl / intelligence / ga / fopti / fopti_rmake_traits.h
blob4cd60584f54f81b2fd32cd2b344e5a98138756e0
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: fopti_rmake_traits.h
4 * Created: 08.09.13
5 * Updated: 08.11.07
7 * Brief: The fopti_rmake_traits class
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
13 #ifndef EXTL_INTELLIGENCE_GA_FOPTI_RMAKE_TRAITS_H
14 #define EXTL_INTELLIGENCE_GA_FOPTI_RMAKE_TRAITS_H
16 /*!\file fopti_rmake_traits.h
17 * \brief The fopti_rmake_traits class
19 #ifndef __cplusplus
20 # error fopti_rmake_traits.h need be supported by c++.
21 #endif
23 /* ///////////////////////////////////////////////////////////////////////
24 * Includes
26 #include "prefix.h"
28 /* ///////////////////////////////////////////////////////////////////////
29 * ::extl::intelligence namespace
31 EXTL_INTELLIGENCE_BEGIN_WHOLE_NAMESPACE
33 /*!\brief fopti_rmake_traits
35 * \param Pop The population type
36 * \param Rand The random type
38 * \ingroup extl_group_intelligence
40 template< typename_param_k Pop
41 , typename_param_k Rand
43 class fopti_rmake_traits
44 : public rmake_traits_base<fopti_rmake_traits<Pop, Rand>, Pop, Rand>
46 /// \name Types
47 /// @{
48 public:
49 typedef rmake_traits_base<fopti_rmake_traits<Pop, Rand>, Pop, Rand> base_type;
50 typedef Pop population_type;
51 typedef typename_type_k population_type::individual_type individual_type;
52 typedef typename_type_k individual_type::size_type size_type;
53 typedef typename_type_k individual_type::bool_type bool_type;
54 typedef typename_type_k individual_type::float_type float_type;
55 typedef typename_type_k individual_type::index_type index_type;
56 typedef typename_type_k individual_type::int_type int_type;
57 typedef typename_type_k individual_type::scopes_type scopes_type;
58 typedef Rand random_type;
59 /// @}
61 /// \name Members
62 /// @{
63 private:
64 scopes_type const* m_psps;
65 //// @}
67 private:
68 scopes_type const& sps() const { return *m_psps; }
70 /// \name Constructors
71 /// @{
72 public:
73 fopti_rmake_traits()
74 : base_type(), m_psps(NULL)
76 /// @}
78 /// \name Methods
79 // @{
80 public:
81 /// initialization
82 void init(random_type& rand, scopes_type const& sps)
84 base_type::init(rand);
85 m_psps = &sps;
87 /// invariance
88 bool_type is_valid() const
90 if (NULL == m_psps) return e_false_v;
91 return base_type::is_valid();
93 ///@}
95 /// \name Implemention
96 /// @{
97 public:
98 individual_type& do_rmake(individual_type& idl)
100 size_type var_n = idl.size();
101 for (index_type i = 0; i < var_n; ++i)
103 idl.value(i, this->rand().fgenerate(sps()[i].lower(), sps()[i].upper()));
105 return idl;
108 individual_type& do_rmake_at_hand(individual_type& idl)
110 size_type var_n = idl.size();
111 for (index_type i = 0; i < var_n; ++i)
113 float_type len = sps()[i].size() * 0.0001;
114 idl.value(i, this->rand().fgenerate(idl.value(i) - len, idl.value(i) + len));
116 return idl;
118 /// @}
122 /* ///////////////////////////////////////////////////////////////////////
123 * ::extl::intelligence namespace
125 EXTL_INTELLIGENCE_END_WHOLE_NAMESPACE
127 /* //////////////////////////////////////////////////////////////////// */
128 #endif /* EXTL_INTELLIGENCE_GA_FOPTI_RMAKE_TRAITS_H */
129 /* //////////////////////////////////////////////////////////////////// */