| 43 | */ |
| 44 | |
| 45 | class CSMAESOpt : public CBiteOptBase< double > |
| 46 | { |
| 47 | public: |
| 48 | /** |
| 49 | * Function updates dimensionality of *this object. |
| 50 | * |
| 51 | * @param aParamCount The number of parameters being optimized. |
| 52 | * @param PopSize0 The number of elements in population to use. If set to |
| 53 | * 0 or negative, the default formula will be used. |
| 54 | */ |
| 55 | |
| 56 | void updateDims( const int aParamCount, const int PopSize0 = 0 ) |
| 57 | { |
| 58 | const int aPopSize = ( PopSize0 > 0 ? PopSize0 : 13 + aParamCount ); |
| 59 | |
| 60 | if( aParamCount == ParamCount && aPopSize == PopSize ) |
| 61 | { |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | initBuffers( aParamCount, aPopSize ); |
| 66 | |
| 67 | Ort.updateDims( aParamCount, aPopSize ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Function initializes *this optimizer. |
| 72 | * |
| 73 | * @param rnd Random number generator. |
| 74 | * @param InitParams Initial parameter values, only used as centroid, |
| 75 | * not evaluated. |
| 76 | * @param InitRadius Initial radius, multiplier relative to the default |
| 77 | * sigma value. |
| 78 | */ |
| 79 | |
| 80 | void init( CBiteRnd& rnd, const double* const InitParams = NULL, |
| 81 | const double InitRadius = 1.0 ) |
| 82 | { |
| 83 | initCommonVars( rnd ); |
| 84 | |
| 85 | cure = 0; |
| 86 | curem = (int) ceil( CurPopSize * Ort.EvalFac ); |
| 87 | |
| 88 | // Provide initial centroid and sigma (PopParams is used here |
| 89 | // temporarily, otherwise initially undefined). |
| 90 | |
| 91 | const double sd = 0.25 * InitRadius; |
| 92 | int i; |
| 93 | |
| 94 | if( InitParams == NULL ) |
| 95 | { |
| 96 | for( i = 0; i < ParamCount; i++ ) |
| 97 | { |
| 98 | PopParams[ 0 ][ i ] = MinValues[ i ] + DiffValues[ i ] * 0.5; |
| 99 | PopParams[ 1 ][ i ] = fabs( DiffValues[ i ]) * sd; |
| 100 | } |
| 101 | } |
| 102 | else |
nothing calls this directly
no outgoing calls
no test coverage detected