MCPcopy Create free account
hub / github.com/avaneev/biteopt / optimize

Method optimize

mbopt.h:117–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 */
116
117 int optimize( CBiteRnd& rnd )
118 {
119 double* Params;
120 int i;
121
122 if( DoInitEvals )
123 {
124 Params = getCurParams();
125 LastValues = Params;
126
127 genInitParamsReal( rnd, Params );
128
129 NewCosts[ 0 ] = fixCostNaN( optcost( Params ));
130 updateBestCost( NewCosts[ 0 ], Params,
131 updatePop( NewCosts[ 0 ], Params ));
132
133 if( CurPopPos == PopSize )
134 {
135 updateCentroid();
136 DoInitEvals = false;
137 }
138
139 return( 0 );
140 }
141
142 Params = TmpParams;
143 LastCosts = NewCosts;
144 LastValues = TmpParams;
145
146 bool DoEval = true;
147 const int SelMethod = select( MethodSel, rnd );
148
149 if( SelMethod == 0 )
150 {
151 // A variant of BiteOpt generator 1.
152
153 copyParams( Params, getParamsOrdered( rnd.getPowInt( 3.0, 4 )));
154
155 // Convert real value to normalized value, apply the "bitmask
156 // inversion" operation, and convert back.
157
158 i = rnd.getInt( ParamCount );
159 Params[ i ] = ( (int64_t) (( Params[ i ] - MinValues[ i ]) *
160 DiffValuesI[ i ] * MantMult ) ^
161 ( IntMantMask >> rnd.getPowInt( 4.0, 32 ))) * MantMultI *
162 DiffValues[ i ] + MinValues[ i ];
163
164 const double* const rp2 = getParamsOrdered(
165 rnd.getSqrInt( CurPopSize ));
166
167 const double v = rp2[ i ];
168 Params[ i ] += ( v - Params[ i ]) * rnd.getTPDF();
169 Params[ i ] += ( v - Params[ i ]) * rnd.getTPDF();
170 Params[ i ] += ( v - Params[ i ]) * rnd.getTPDF();
171 Params[ i ] += ( v - Params[ i ]) * rnd.getTPDF();
172 }
173 else
174 if( SelMethod == 1 )

Callers

nothing calls this directly

Calls 9

getPowIntMethod · 0.80
getIntMethod · 0.80
getSqrIntMethod · 0.80
getTPDFMethod · 0.80
getBitMethod · 0.80
getLogIntMethod · 0.80
getLastCostsMethod · 0.45
getLastValuesMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected