00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "freESRandomMultiParentSelectorController.h"
00023 #include "freExceptions.h"
00024
00025 namespace FREE
00026 {
00027
00031
00032
00033 DefineParameterMacro(ESRandomMultiParentSelectorController,AllowRedraw,"AllowRedraw","Indicates if a parent is allowed to be randomly drawn more than once. If redraw isn't allowed the number of selections must be less or equal the size of the population.");
00034 DefineParameterMacro(ESRandomMultiParentSelectorController,NumberOfSelections,"NumberOfSelections","The number of individuals that should be selected. In terms of ES it is the parameter rho.");
00035
00036 ESRandomMultiParentSelectorController::
00037 ESRandomMultiParentSelectorController()
00038 {
00039
00040 this->UpdateControllerID(ControllerID::ESRandomMultiParentSelectorController);
00041 this->m_Description = "ES selects the parents out of the population randomly.";
00042 };
00043
00044 void
00045 ESRandomMultiParentSelectorController::
00046 GenerateProfile(CtrlProfile::ControllerProfile& profile,
00047 const SessionComponentCache* pComponentCache,
00048 bool bRegardOldSetup) const
00049 {
00050 Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00051
00052
00053 profile.Parameters().AddParameter(cParam_AllowRedraw,CtrlProfile::Parameter::PVTBool,cParamDsc_AllowRedraw,1,"false");
00054 profile.Parameters().AddParameter(cParam_NumberOfSelections,CtrlProfile::Parameter::PVTULong,cParamDsc_NumberOfSelections,1,"1",-1);
00055 };
00056
00057 void
00058 ESRandomMultiParentSelectorController::
00059 ActualizeMainComponent(ComponentType* pMainComponent,
00060 SessionComponentCache* pComponentCache, SessionInfo* pSessionInfo,
00061 const unsigned int& iActLevel) const
00062 {
00063 Superclass::ActualizeMainComponent(pMainComponent, pComponentCache,
00064 pSessionInfo, iActLevel);
00065
00066 bool bAllowRedraw;
00067 unsigned long lNumberOfSelections;
00068
00069 try
00070 {
00071 SessionAccessor::GetParameterValue(pComponentCache,cParam_AllowRedraw,bAllowRedraw,0,iActLevel,true);
00072 SessionAccessor::GetParameterValue(pComponentCache,cParam_NumberOfSelections,lNumberOfSelections,0,iActLevel,true);
00073 }
00074 catchAllNPassMacro("Error while retrieving parameter values.");
00075
00076 pMainComponent->SetAllowRedraw(bAllowRedraw);
00077 pMainComponent->SetNumberOfSelections(lNumberOfSelections);
00078 };
00079
00080
00081 }