File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -220,10 +220,17 @@ namespace libcmaes
220
220
if (eostrat<TGenoPheno>::_parameters._tpa && eostrat<TGenoPheno>::_niter > 0 )
221
221
{
222
222
dVec mean_shift = eostrat<TGenoPheno>::_solutions._xmean - eostrat<TGenoPheno>::_solutions._xmean_prev ;
223
- double mean_shift_norm = mean_shift.norm ();
224
- dVec z = eostrat<TGenoPheno>::_parameters._chi * (mean_shift / mean_shift_norm);
225
- eostrat<TGenoPheno>::_solutions._tpa_x1 = eostrat<TGenoPheno>::_solutions._xmean + eostrat<TGenoPheno>::_solutions._sigma * z;
226
- eostrat<TGenoPheno>::_solutions._tpa_x2 = eostrat<TGenoPheno>::_solutions._xmean - eostrat<TGenoPheno>::_solutions._sigma * z;
223
+ double mean_shift_norm = 1.0 ;
224
+ if (!eostrat<TGenoPheno>::_parameters._sep && !eostrat<TGenoPheno>::_parameters._vd )
225
+ mean_shift_norm = (_esolver._eigenSolver .eigenvalues ().cwiseInverse ().cwiseProduct (_esolver._eigenSolver .eigenvectors ().transpose ()*mean_shift)).norm () / eostrat<TGenoPheno>::_solutions._sigma ;
226
+ else mean_shift_norm = eostrat<TGenoPheno>::_solutions._sepcov .cwiseInverse ().cwiseProduct (mean_shift).norm () / eostrat<TGenoPheno>::_solutions._sigma ;
227
+ // std::cout << "mean_shift_norm=" << mean_shift_norm << " / sqrt(N)=" << std::sqrt(std::sqrt(eostrat<TGenoPheno>::_parameters._dim)) << std::endl;
228
+
229
+ dMat rz = _esolver.samples_ind (1 );
230
+ double mfactor = rz.norm ();
231
+ dVec z = mfactor * (mean_shift / mean_shift_norm);
232
+ eostrat<TGenoPheno>::_solutions._tpa_x1 = eostrat<TGenoPheno>::_solutions._xmean + z;
233
+ eostrat<TGenoPheno>::_solutions._tpa_x2 = eostrat<TGenoPheno>::_solutions._xmean - z;
227
234
228
235
// if gradient is in col 0, move tpa vectors to pos 1 & 2
229
236
int p1 = 0 , p2 = 1 ;
You can’t perform that action at this time.
0 commit comments