00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "freEvolutionaryStrategyCtrlrs.h"
00023
00024 #include "freEvolutionaryStrategyOptimizerController.h"
00025
00026 #include "freESRandomMultiParentSelectorController.h"
00027 #include "freESDominantRecombinatorController.h"
00028 #include "freESIntermediateRecombinatorController.h"
00029 #include "freESRankRecombinatorController.h"
00030 #include "freESDiscriminativeRecombinatorController.h"
00031 #include "freESAdaptiveNormalMutationController.h"
00032 #include "freESAdaptiveScaleMutationController.h"
00033 #include "freESAsymmetricMutationController.h"
00034 #include "freESPlusSelectionController.h"
00035 #include "freESCommaSelectionController.h"
00036 #include "freESCMAMutationController.h"
00037
00038 namespace FREE
00039 {
00040
00041 #ifndef __FREE_DISABLE_DLL_INTERFACE
00042
00043 namespace
00044 {
00045
00046 extern "C"
00047 #ifdef _WIN32
00048 __declspec( dllexport )
00049 #endif
00050 void FREEGetControllerList(int& iControllerCount, const char**& pControllerIDs)
00051 {
00052 ::FREE::EvolutionaryStrategyCtrlrs::GetControllerList(iControllerCount, pControllerIDs);
00053 };
00054
00055 extern "C"
00056 #ifdef _WIN32
00057 __declspec( dllexport )
00058 #endif
00059 GenericComponentController* FREECreateController(const char* pControllerID)
00060 {
00061 return ::FREE::EvolutionaryStrategyCtrlrs::CreateController(pControllerID);
00062 };
00063
00064 extern "C"
00065 #ifdef _WIN32
00066 __declspec( dllexport )
00067 #endif
00068 bool FREEDeleteController (GenericComponentController* pController)
00069 {
00070 if (pController)
00071 {
00072 delete pController;
00073 }
00074 return true;
00075 };
00076
00077 extern "C"
00078 #ifdef _WIN32
00079 __declspec( dllexport )
00080 #endif
00081 void FREELinkCentralAsDedicated (::FREE::ControllerCentral::ControllerListType* pDedicatedControllerList,
00082 ::FREE::ControllerCentral::LibraryHandleListType* pDedicatedLibraryHandles,
00083 ::FREE::ProgressEventBase* pfnOnControl, ::FREE::ProgressEventBase* pfnOnBuild,
00084 ::FREE::ControllerCentral::CtrlCallbackListType* pCtrlCallbackList,
00085 ::FREE::ControllerCentral::CtrlProgressListType* pCtrlProgressList,
00086 ::itk::MutexLock* pGlobalCallbackMutex,
00087 ::itk::MutexLock* pGlobalProgressMutex)
00088 {
00089 ::FREE::ControllerCentral::LinkControllerCentralAsDedicated(pDedicatedControllerList,pDedicatedLibraryHandles,pfnOnControl,pfnOnBuild,pCtrlCallbackList,pCtrlProgressList,pGlobalCallbackMutex,pGlobalProgressMutex);
00090 }
00091
00092
00093 }
00094
00095 #endif // __FREE_DISABLE_DLL_INTERFACE
00096
00100
00101
00102 void EvolutionaryStrategyCtrlrs::RegisterAllControllers(ControllerCentral* pCentral)
00103 {
00104 int iCount = 0;
00105 const char** pControllerIDs = 0;
00106
00107 EvolutionaryStrategyCtrlrs::GetControllerList(iCount,pControllerIDs);
00108
00109 for (int iPos = 0; iPos < iCount; iPos++)
00110 {
00111 pCentral->RegisterController(EvolutionaryStrategyCtrlrs::CreateController(pControllerIDs[iPos]));
00112 }
00113
00114 if (pControllerIDs)
00115 delete pControllerIDs;
00116 };
00117
00118 void EvolutionaryStrategyCtrlrs::GetControllerList(int& iControllerCount, const char**& pControllerIDs)
00119 {
00120 typedef std::vector<const char*> ControllerListType;
00121 ControllerListType internalControllerList;
00122
00123
00124 internalControllerList.push_back(ControllerID::EvolutionaryStrategyOptimizerController);
00125
00126
00127 internalControllerList.push_back(ControllerID::ESRandomMultiParentSelectorController);
00128 internalControllerList.push_back(ControllerID::ESDominantRecombinatorController);
00129 internalControllerList.push_back(ControllerID::ESIntermediateRecombinatorController);
00130 internalControllerList.push_back(ControllerID::ESRankRecombinatorController);
00131 internalControllerList.push_back(ControllerID::ESDiscriminativeRecombinatorController);
00132 internalControllerList.push_back(ControllerID::ESAdaptiveNormalMutationController);
00133 internalControllerList.push_back(ControllerID::ESAdaptiveScaleMutationController);
00134 internalControllerList.push_back(ControllerID::ESAsymmetricMutationController);
00135 internalControllerList.push_back(ControllerID::ESCMAMutationController);
00136 internalControllerList.push_back(ControllerID::ESPlusSelectionController);
00137 internalControllerList.push_back(ControllerID::ESCommaSelectionController);
00138
00139
00140 iControllerCount = internalControllerList.size();
00141 pControllerIDs = new const char*[iControllerCount];
00142 for (unsigned int iPos = 0; iPos<iControllerCount; iPos++)
00143 {
00144 pControllerIDs[iPos] = internalControllerList.at(iPos);
00145 }
00146 };
00147
00148 GenericComponentController* EvolutionaryStrategyCtrlrs::CreateController(const char* pControllerID)
00149 {
00150 std::string sControllerID(pControllerID);
00151
00152 if (sControllerID == ControllerID::EvolutionaryStrategyOptimizerController)
00153 return(GenericComponentController*)new EvolutionaryStrategyOptimizerController;
00154
00155 if (sControllerID == ControllerID::ESRandomMultiParentSelectorController)
00156 return(GenericComponentController*)new ESRandomMultiParentSelectorController;
00157 if (sControllerID == ControllerID::ESDominantRecombinatorController)
00158 return(GenericComponentController*)new ESDominantRecombinatorController;
00159 if (sControllerID == ControllerID::ESIntermediateRecombinatorController)
00160 return(GenericComponentController*)new ESIntermediateRecombinatorController;
00161 if (sControllerID == ControllerID::ESRankRecombinatorController)
00162 return(GenericComponentController*)new ESRankRecombinatorController;
00163 if (sControllerID == ControllerID::ESDiscriminativeRecombinatorController)
00164 return(GenericComponentController*)new ESDiscriminativeRecombinatorController;
00165 if (sControllerID == ControllerID::ESAdaptiveNormalMutationController)
00166 return(GenericComponentController*)new ESAdaptiveNormalMutationController;
00167 if (sControllerID == ControllerID::ESAdaptiveScaleMutationController)
00168 return(GenericComponentController*)new ESAdaptiveScaleMutationController;
00169 if (sControllerID == ControllerID::ESAsymmetricMutationController)
00170 return(GenericComponentController*)new ESAsymmetricMutationController;
00171 if (sControllerID == ControllerID::ESCMAMutationController)
00172 return(GenericComponentController*)new ESCMAMutationController;
00173 if (sControllerID == ControllerID::ESPlusSelectionController)
00174 return(GenericComponentController*)new ESPlusSelectionController;
00175 if (sControllerID == ControllerID::ESCommaSelectionController)
00176 return(GenericComponentController*)new ESCommaSelectionController;
00177
00178 return NULL;
00179 };
00180
00181
00182 }