| 95 | */ |
| 96 | |
| 97 | int optimize( CBiteRnd& rnd ) |
| 98 | { |
| 99 | int i; |
| 100 | |
| 101 | if( DoInitEvals ) |
| 102 | { |
| 103 | ptype* const Params = getCurParams(); |
| 104 | |
| 105 | genInitParams( rnd, Params ); |
| 106 | |
| 107 | const double NewCost = fixCostNaN( optcost( NewValues )); |
| 108 | NewCosts[ 0 ] = NewCost; |
| 109 | |
| 110 | updateBestCost( NewCost, NewValues, updatePop( NewCost, Params )); |
| 111 | |
| 112 | if( CurPopPos == PopSize ) |
| 113 | { |
| 114 | DoInitEvals = false; |
| 115 | } |
| 116 | |
| 117 | return( 0 ); |
| 118 | } |
| 119 | |
| 120 | const int si1 = rnd.getPowInt( 4.0, CurPopSize / 2 ); |
| 121 | const ptype* const rp1 = getParamsOrdered( si1 ); |
| 122 | |
| 123 | const int PairCount = 3; |
| 124 | const int pc = 1 + 2 * PairCount; |
| 125 | int PopIdx[ pc ]; |
| 126 | PopIdx[ 0 ] = si1; |
| 127 | |
| 128 | int pp = 1; |
| 129 | int j; |
| 130 | |
| 131 | if( CurPopSize1 <= pc ) |
| 132 | { |
| 133 | while( pp < pc ) |
| 134 | { |
| 135 | PopIdx[ pp ] = rnd.getInt( CurPopSize ); |
| 136 | pp++; |
| 137 | } |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | while( pp < pc ) |
| 142 | { |
| 143 | const int sii = rnd.getInt( CurPopSize ); |
| 144 | |
| 145 | for( j = 0; j < pp; j++ ) |
| 146 | { |
| 147 | if( PopIdx[ j ] == sii ) |
| 148 | { |
| 149 | break; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if( j >= pp ) |
| 154 | { |