| 1368 | */ |
| 1369 | |
| 1370 | void generateSol10( CBiteRnd& rnd ) |
| 1371 | { |
| 1372 | ptype* const Params = TmpParams; |
| 1373 | |
| 1374 | const ptype* const rp1 = getParamsOrdered( |
| 1375 | rnd.getSqrInt( CurPopSize )); |
| 1376 | |
| 1377 | const ptype* const rp2 = getParamsOrdered( |
| 1378 | rnd.getSqrIntInv( CurPopSize )); |
| 1379 | |
| 1380 | int i; |
| 1381 | |
| 1382 | // Calculate centroid. |
| 1383 | |
| 1384 | for( i = 0; i < ParamCount; i++ ) |
| 1385 | { |
| 1386 | Params[ i ] = ( rp1[ i ] + rp2[ i ]) >> 1; |
| 1387 | } |
| 1388 | |
| 1389 | // Calculate radius. |
| 1390 | |
| 1391 | double Radius = 0.0; |
| 1392 | |
| 1393 | for( i = 0; i < ParamCount; i++ ) |
| 1394 | { |
| 1395 | const ptype v1 = rp1[ i ] - Params[ i ]; |
| 1396 | const ptype v2 = rp2[ i ] - Params[ i ]; |
| 1397 | Radius += (double) v1 * v1 + 0.45 * v2 * v2; |
| 1398 | } |
| 1399 | |
| 1400 | // Select a point on a hyper-spheroid. |
| 1401 | |
| 1402 | double s2 = 1e-300; |
| 1403 | |
| 1404 | for( i = 0; i < ParamCount; i++ ) |
| 1405 | { |
| 1406 | NewValues[ i ] = rnd.get() - 0.5; |
| 1407 | s2 += NewValues[ i ] * NewValues[ i ]; |
| 1408 | } |
| 1409 | |
| 1410 | // Add hyper-spheroid-based offset to the centroid. |
| 1411 | |
| 1412 | const double d = sqrt( Radius / s2 ); |
| 1413 | |
| 1414 | for( i = 0; i < ParamCount; i++ ) |
| 1415 | { |
| 1416 | Params[ i ] += (ptype) ( NewValues[ i ] * d ); |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | /** |
| 1421 | * Stochastic PSO-alike solution generator. Moves a randomly-selected |
nothing calls this directly
no test coverage detected