remove \r
[extl.git] / extl / intelligence / ga / fopti / detail / fopti_fitness_traits_impl.h
blobe05c0a7fdddf9ac711986c8677013406f1357f3c
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: fopti_fitness_traits_impl.h
4 * Created: 08.09.09
5 * Updated: 08.09.09
7 * Brief: The fopti_fitness_traits_impl class
9 * [<Home>]
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
16 #ifndef __cplusplus
17 # error fopti_fitness_traits_impl.h need be supported by c++.
18 #endif
20 /* ///////////////////////////////////////////////////////////////////////
21 * Includes
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
37 typedef T float_type;
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;
41 // for maximum
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);
47 // for minimum
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 /* //////////////////////////////////////////////////////////////////// */