1 /* ///////////////////////////////////////////////////////////////////////
2 * File: fopti_rmake_traits.h
7 * Brief: The fopti_rmake_traits class
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
20 # error fopti_rmake_traits.h need be supported by c++.
23 /* ///////////////////////////////////////////////////////////////////////
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
>
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
;
64 scopes_type
const* m_psps
;
68 scopes_type
const& sps() const { return *m_psps
; }
70 /// \name Constructors
74 : base_type(), m_psps(NULL
)
82 void init(random_type
& rand
, scopes_type
const& sps
)
84 base_type::init(rand
);
88 bool_type
is_valid() const
90 if (NULL
== m_psps
) return e_false_v
;
91 return base_type::is_valid();
95 /// \name Implemention
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()));
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
));
122 /* ///////////////////////////////////////////////////////////////////////
123 * ::extl::intelligence namespace
125 EXTL_INTELLIGENCE_END_WHOLE_NAMESPACE
127 /* //////////////////////////////////////////////////////////////////// */
128 #endif /* EXTL_INTELLIGENCE_GA_FOPTI_RMAKE_TRAITS_H */
129 /* //////////////////////////////////////////////////////////////////// */