Differential Evolution C++ library
|
00001 /* 00002 * Copyright (c) 2011 Adrian Michel 00003 * http://www.amichel.com 00004 * 00005 * Permission to use, copy, modify, distribute and sell this 00006 * software and its documentation for any purpose is hereby 00007 * granted without fee, provided that both the above copyright 00008 * notice and this permission notice appear in all copies and in 00009 * the supporting documentation. 00010 * 00011 * This library is distributed in the hope that it will be 00012 * useful. However, Adrian Michel makes no representations about 00013 * the suitability of this software for any purpose. It is 00014 * provided "as is" without any express or implied warranty. 00015 * 00016 * Should you find this library useful, please email 00017 * info@amichel.com with a link or other reference 00018 * to your work. 00019 */ 00020 00021 #ifndef DE_TERMINATION_STRATEGY_HPP_INCLUDED 00022 #define DE_TERMINATION_STRATEGY_HPP_INCLUDED 00023 00024 // MS compatible compilers support #pragma once 00025 00026 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 00027 #pragma once 00028 #endif 00029 00030 namespace de 00031 { 00032 00046 class termination_strategy 00047 { 00048 public: 00049 virtual ~termination_strategy(){} 00050 00062 virtual bool event( individual_ptr best, size_t genCount ) = 0; 00063 }; 00064 00068 typedef boost::shared_ptr< termination_strategy > termination_strategy_ptr; 00069 00077 class max_gen_termination_strategy : public termination_strategy 00078 { 00079 private: 00080 const size_t m_maxGen; 00081 public: 00090 max_gen_termination_strategy( size_t maxGen ) 00091 : m_maxGen( maxGen ) 00092 { 00093 } 00094 00095 virtual bool event( individual_ptr best, size_t genCount ) 00096 { 00097 return genCount < m_maxGen; 00098 } 00099 }; 00100 00101 } 00102 00103 #endif //DE_TERMINATION_STRATEGY_HPP_INCLUDED