LibCudaOptimize
1.0
|
00001 //*************************************************************************// 00002 // // 00003 // LibCudaOptimize // 00004 // Copyright (C) 2012 Ibislab, University of Parma // 00005 // Authors: Youssef S.G. Nashed, Roberto Ugolotti // 00006 // // 00007 // You should have received a copy of the GNU General Public License // 00008 // along with this program. If not, see <http://www.gnu.org/licenses/> // 00009 // // 00010 //*************************************************************************// 00011 00012 #ifndef SCATTERSEARCH_H 00013 #define SCATTERSEARCH_H 00014 00016 #include "IOptimizer.h" 00017 00018 /*open the namespace 00019 this code should be after all the #include lines and before the first line of the code in each file. 00020 by Hamid. 23/07/2012*/ 00021 #ifdef LIBCUDAOPTIMIZE_NAMESPACE 00022 OPEN_NAMESPACE 00023 #endif 00024 00025 //Scatter Search Standard Values 00026 #define SS_B1 5 00027 #define SS_B2 5 00028 #define SS_LAMBDA 1.333333f 00029 #define SS_LOCAL_ITERATIONS 10 00030 #define SS_DIVS 5 00031 00032 class SS_Optimizer : public virtual IOptimizer 00033 { 00034 private: 00035 void reconstructReferenceSet(); 00036 void addDiversityToReferenceSet(bool); 00037 void combineReferenceSet(); 00038 void initReferenceSet(); 00039 void updateReferenceSet(); 00040 void cacheParams(); 00041 void restoreParams(); 00042 00043 protected: 00044 SolutionSet m_diversitySet; 00045 00046 virtual void reinitLocalSearch(unsigned int n) = 0; 00047 #ifndef PRIVATE_DOXYGEN 00048 unsigned int m_localIterations; 00049 unsigned int m_divs; 00050 unsigned int m_b1; 00051 unsigned int m_b2; 00052 float m_lambda; 00053 bool m_useDiversity; 00054 00055 unsigned int m_b; 00056 unsigned int m_newIDsNum; 00057 unsigned int m_poolSize; 00058 00059 //caching variables 00060 unsigned int m_cachedSolutionsNumber; 00061 float* m_dCachedPositions; 00062 float* m_dCachedFitnesses; 00063 00064 00065 float* m_dSolutionDistances; 00066 //float* m_dReferenceSetFitnesses; 00067 float* m_dPool; 00068 float* m_dPoolAndRefFitnesses; 00069 uint32_t* m_dPoolIndex; 00070 uint32_t* m_dReferenceSetIDs; 00071 uint32_t* m_dNewSolutionsIDs; 00072 00073 void findBest(); 00074 #endif 00075 00076 public: 00077 SS_Optimizer(EvalFuncPtr fPtr=NULL, unsigned int dn=PROBLEM_DIMENSIONS, unsigned int sn=NUM_SETS, unsigned int pn=NUM_SOLUTIONS); 00078 virtual ~SS_Optimizer(); 00079 00080 virtual void optimize(); 00081 virtual bool init(); 00082 virtual void free(); 00083 00084 void setReferenceSetSize(unsigned int b1, unsigned int b2); 00085 void setB1(unsigned int b1) {m_b1 = b1;} 00086 void setB2(unsigned int b2) {m_b2 = b2;} 00087 void setLambda(float l) {m_lambda = l;} 00088 void setLocalSearchIterations(unsigned int i) {m_localIterations = i;} 00089 void setUseDiversity(bool d) {m_useDiversity = d;} 00090 void setGridDivisions(unsigned int d) {m_divs = d;} 00091 00092 unsigned int getReferenceSetSize() const {return m_b;} 00093 unsigned int getB1() const {return m_b1;} 00094 unsigned int getB2() const {return m_b2;} 00095 unsigned int getLocalSearchIterations() const {return m_localIterations;} 00096 unsigned int getGridDivisions() const {return m_divs;} 00097 float getLambda() const {return m_lambda;} 00098 bool getUseDiversity() const {return m_useDiversity;} 00099 }; 00100 00101 /*close the namespace 00102 this code should be at the end of the file 00103 by Hamid. 23/07/2012*/ 00104 #ifdef LIBCUDAOPTIMIZE_NAMESPACE 00105 CLOSE_NAMESPACE 00106 #endif 00107 00108 #endif