1 /* ///////////////////////////////////////////////////////////////////////
2 * File: fopti_fitness_traits_impl.h
7 * Brief: The fopti_fitness_traits_impl class
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
13 #ifndef EXTL_INTELLIGENCE_GA_FITNESS_TRAITS_H
14 #define EXTL_INTELLIGENCE_GA_FITNESS_TRAITS_H
17 # error fopti_fitness_traits_impl.h need be supported by c++.
20 /* ///////////////////////////////////////////////////////////////////////
23 #include "../prefix.h"
25 /* ///////////////////////////////////////////////////////////////////////
26 * ::extl::detail namespace
28 EXTL_INTELLIGENCE_BEGIN_WHOLE_NAMESPACE
29 EXTL_DETAIL_BEGIN_NAMESPACE
31 template<e_bool_t for_max
>
32 struct for_max_type_wrap
{};
34 template<typename_param_k T
>
35 struct fopti_fitness_traits_impl
38 typedef for_max_type_wrap
<e_true_v
> for_max_selector_type
;
39 typedef for_max_type_wrap
<e_false_v
> for_min_selector_type
;
42 static float_type
impl(float_type fvalue
, float_type fmin
, float_type
/*fmax*/, for_max_selector_type
)
44 return (fvalue
< fmin
)? 0 : (fvalue
- fmin
);
48 static float_type
impl(float_type fvalue
, float_type
/*fmin*/, float_type fmax
, for_min_selector_type
)
50 return (fvalue
> fmax
)? 0 : (fmax
- fvalue
);
55 /* ///////////////////////////////////////////////////////////////////////
56 * ::extl::detail namespace
58 EXTL_DETAIL_END_NAMESPACE
59 EXTL_INTELLIGENCE_END_WHOLE_NAMESPACE
61 /* //////////////////////////////////////////////////////////////////// */
62 #endif /* EXTL_INTELLIGENCE_GA_FITNESS_TRAITS_H */
63 /* //////////////////////////////////////////////////////////////////// */