00001
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include <math.h>
00005
00006 #include "benchmarksdeclare.h"
00007 #include "benchmarkshelper.h"
00008 #include "bbobStructures.h"
00009
00010 #define NHIGHPEAKS21 101
00011 #define NHIGHPEAKS22 21
00012
00013 static double * tmpvect;
00014 static double * tmx;
00015 static double ** rotation;
00016 static double ** rot2;
00017 static double ** linearTF;
00018 static double * peaks21;
00019 static double * peaks22;
00020 static int * rperm;
00021 static int * rperm21;
00022 static int * rperm22;
00023 static double ** Xlocal;
00024 static double ** Xlocal21;
00025 static double ** Xlocal22;
00026 static double ** arrScales;
00027 static double ** arrScales21;
00028 static double ** arrScales22;
00029
00030
00031
00032
00033
00034
00035
00036 TwoDoubles f1(double* x) {
00037
00038
00039 int i, rseed;
00040 static unsigned int funcId = 1;
00041 double Fadd, r, Fval, Ftrue = 0.;
00042 TwoDoubles res;
00043
00044 if (!isInitDone)
00045 {
00046 rseed = funcId + 10000 * trialid;
00047
00048 Fopt = computeFopt(funcId, trialid);
00049 computeXopt(rseed, DIM);
00050 isInitDone = 1;
00051 }
00052
00053 Fadd = Fopt;
00054
00055 for (i = 0; i < DIM; i++)
00056 {
00057 r = x[i] - Xopt[i];
00058 Ftrue += r * r;
00059 }
00060 Ftrue += Fadd;
00061 Fval = Ftrue;
00062 res.Ftrue = Ftrue;
00063 res.Fval = Fval;
00064 return res;
00065 }
00066
00067 TwoDoubles f2(double* x) {
00068
00069
00070 int i, rseed;
00071 static double condition = 1e6;
00072 static unsigned int funcId = 2;
00073 double Fadd, Fval, Ftrue = 0.;
00074 TwoDoubles res;
00075
00076 if (!isInitDone)
00077 {
00078 rseed = funcId + 10000 * trialid;
00079
00080 Fopt = computeFopt(funcId, trialid);
00081 computeXopt(rseed, DIM);
00082 isInitDone = 1;
00083 }
00084
00085 Fadd = Fopt;
00086
00087 for (i = 0; i < DIM; i++)
00088 {
00089 tmx[i] = x[i] - Xopt[i];
00090 }
00091
00092 monotoneTFosc(tmx);
00093
00094
00095 for (i = 0; i < DIM; i++)
00096 {
00097 Ftrue += pow(condition, ((double)i)/((double)(DIM-1))) * tmx[i] * tmx[i];
00098 }
00099 Ftrue += Fadd;
00100 Fval = Ftrue;
00101
00102 res.Fval = Fval;
00103 res.Ftrue = Ftrue;
00104 return res;
00105 }
00106
00107 TwoDoubles f3(double* x) {
00108
00109 int i, rseed;
00110
00111 static unsigned int funcId = 3;
00112 static double condition = 10.;
00113 static double beta = 0.2;
00114 double tmp, tmp2, Fadd, Fval, Ftrue = 0.;
00115 TwoDoubles res;
00116
00117 if (!isInitDone)
00118 {
00119 rseed = funcId + 10000 * trialid;
00120
00121 Fopt = computeFopt(funcId, trialid);
00122 computeXopt(rseed, DIM);
00123 isInitDone = 1;
00124 }
00125
00126 Fadd = Fopt;
00127 for (i = 0; i < DIM; i++)
00128 {
00129 tmx[i] = x[i] - Xopt[i];
00130 }
00131
00132 monotoneTFosc(tmx);
00133 for (i = 0; i < DIM; i++)
00134 {
00135 tmp = ((double)i)/((double)(DIM-1));
00136 if (tmx[i] > 0)
00137 tmx[i] = pow(tmx[i], 1 + beta * tmp * sqrt(tmx[i]));
00138 tmx[i] = pow(sqrt(condition), tmp) * tmx[i];
00139 }
00140
00141 tmp = 0.;
00142 tmp2 = 0.;
00143 for (i = 0; i < DIM; i++)
00144 {
00145 tmp += cos(2*M_PI*tmx[i]);
00146 tmp2 += tmx[i]*tmx[i];
00147 }
00148 Ftrue = 10 * (DIM - tmp) + tmp2;
00149 Ftrue += Fadd;
00150 Fval = Ftrue;
00151
00152 res.Fval = Fval;
00153 res.Ftrue = Ftrue;
00154 return res;
00155 }
00156
00157 TwoDoubles f4(double* x) {
00158
00159
00160 int i, rseed;
00161 static unsigned int funcId = 4;
00162 static double condition = 10.;
00163 static double alpha = 100.;
00164 double tmp, tmp2, Fadd, Fval, Fpen = 0., Ftrue = 0.;
00165 TwoDoubles res;
00166
00167 if (!isInitDone)
00168 {
00169 rseed = 3 + 10000 * trialid;
00170
00171 Fopt = computeFopt(funcId, trialid);
00172 computeXopt(rseed, DIM);
00173 for (i = 0; i < DIM; i += 2)
00174 Xopt[i] = fabs(Xopt[i]);
00175 isInitDone = 1;
00176 }
00177 Fadd = Fopt;
00178
00179 for (i = 0; i < DIM; i++) {
00180 tmp = fabs(x[i]) - 5.;
00181 if (tmp > 0.)
00182 Fpen += tmp * tmp;
00183 }
00184 Fpen *= 1e2;
00185 Fadd += Fpen;
00186
00187 for (i = 0; i < DIM; i++)
00188 {
00189 tmx[i] = x[i] - Xopt[i];
00190 }
00191
00192 monotoneTFosc(tmx);
00193 for (i = 0; i < DIM; i++)
00194 {
00195 if (i % 2 == 0 && tmx[i] > 0)
00196 tmx[i] = sqrt(alpha) * tmx[i];
00197 tmx[i] = pow(sqrt(condition), ((double)i)/((double)(DIM-1))) * tmx[i];
00198 }
00199
00200 tmp = 0.;
00201 tmp2 = 0.;
00202 for (i = 0; i < DIM; i++)
00203 {
00204 tmp += cos(2*M_PI*tmx[i]);
00205 tmp2 += tmx[i]*tmx[i];
00206 }
00207 Ftrue = 10 * (DIM - tmp) + tmp2;
00208 Ftrue += Fadd;
00209 Fval = Ftrue;
00210
00211 res.Fval = Fval;
00212 res.Ftrue = Ftrue;
00213 return res;
00214 }
00215
00216 TwoDoubles f5(double* x) {
00217
00218 int i, rseed;
00219 static unsigned int funcId = 5;
00220 static double alpha = 100.;
00221 static double Fadd;
00222 double tmp, Fval, Ftrue = 0.;
00223 TwoDoubles res;
00224
00225 if (!isInitDone)
00226 {
00227 rseed = funcId + 10000 * trialid;
00228
00229 Fopt = computeFopt(funcId, trialid);
00230 Fadd = Fopt;
00231 computeXopt(rseed, DIM);
00232 for (i = 0; i < DIM; i ++)
00233 {
00234 tmp = pow(sqrt(alpha), ((double)i)/((double)(DIM-1)));
00235 if (Xopt[i] > 0)
00236 {
00237 Xopt[i] = 5.;
00238 }
00239 else if (Xopt[i] < 0)
00240 {
00241 Xopt[i] = -5.;
00242 }
00243 Fadd += 5. * tmp;
00244 }
00245 isInitDone = 1;
00246 }
00247
00248
00249
00250 for (i = 0; i < DIM; i++) {
00251 if ((Xopt[i] == 5.) && (x[i] > 5))
00252 tmx[i] = 5.;
00253 else if ((Xopt[i] == -5.) && (x[i] < -5))
00254 tmx[i] = -5.;
00255 else
00256 tmx[i] = x[i];
00257 }
00258
00259
00260 for (i = 0; i < DIM; i++)
00261 {
00262 if (Xopt[i] > 0) {
00263 Ftrue -= pow(sqrt(alpha), ((double)i)/((double)(DIM-1))) * tmx[i];
00264 } else {
00265 Ftrue += pow(sqrt(alpha), ((double)i)/((double)(DIM-1))) * tmx[i];
00266 }
00267 }
00268 Ftrue += Fadd;
00269 Fval = Ftrue;
00270
00271 res.Fval = Fval;
00272 res.Ftrue = Ftrue;
00273 return res;
00274 }
00275
00276 TwoDoubles f6(double* x) {
00277
00278 int i, j, k, rseed;
00279 static unsigned int funcId = 6;
00280 static double alpha = 100.;
00281 double Fadd, Fval, Ftrue = 0.;
00282 TwoDoubles res;
00283
00284 if (!isInitDone)
00285 {
00286 static double condition = 10.;
00287 rseed = funcId + 10000 * trialid;
00288
00289 Fopt = computeFopt(funcId, trialid);
00290 computeXopt(rseed, DIM);
00291 computeRotation(rotation, rseed + 1000000, DIM);
00292 computeRotation(rot2, rseed, DIM);
00293
00294 for (i = 0; i < DIM; i ++)
00295 {
00296 for (j = 0; j < DIM; j++)
00297 {
00298 linearTF[i][j] = 0.;
00299 for (k = 0; k < DIM; k++) {
00300 linearTF[i][j] += rotation[i][k] * pow(sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j];
00301 }
00302 }
00303 }
00304 isInitDone = 1;
00305 }
00306 Fadd = Fopt;
00307
00308
00309
00310 for (i = 0; i < DIM; i++) {
00311
00312 tmx[i] = 0.;
00313 for (j = 0; j < DIM; j++) {
00314 tmx[i] += linearTF[i][j] * (x[j] - Xopt[j]);
00315 }
00316 }
00317
00318
00319 for (i = 0; i < DIM; i++)
00320 {
00321 if (tmx[i] * Xopt[i] > 0)
00322 tmx[i] *= alpha;
00323 Ftrue += tmx[i] * tmx[i];
00324 }
00325
00326
00327 if (Ftrue > 0)
00328 {
00329 Ftrue = pow(exp(log(Ftrue)/0.1 + 0.49*(sin(log(Ftrue)/0.1) + sin(0.79*log(Ftrue)/0.1))), 0.1);
00330 }
00331 else if (Ftrue < 0)
00332 {
00333 Ftrue = -pow(exp(log(-Ftrue)/0.1 + 0.49*(sin(0.55 * log(-Ftrue)/0.1) + sin(0.31*log(-Ftrue)/0.1))), 0.1);
00334 }
00335 Ftrue = pow(Ftrue, 0.9);
00336 Ftrue += Fadd;
00337 Fval = Ftrue;
00338
00339 res.Fval = Fval;
00340 res.Ftrue = Ftrue;
00341 return res;
00342 }
00343
00344 TwoDoubles f7(double* x) {
00345
00346
00347 int i, j, rseed;
00348 static unsigned int funcId = 7;
00349 static double condition = 100.;
00350 static double alpha = 10.;
00351 double x1, tmp, Fadd, Fval, Fpen = 0., Ftrue = 0.;
00352 TwoDoubles res;
00353
00354 if (!isInitDone)
00355 {
00356 rseed = funcId + 10000 * trialid;
00357
00358 Fopt = computeFopt(funcId, trialid);
00359 computeXopt(rseed, DIM);
00360 computeRotation(rotation, rseed + 1000000, DIM);
00361 computeRotation(rot2, rseed, DIM);
00362 isInitDone = 1;
00363 }
00364 Fadd = Fopt;
00365
00366
00367 for (i = 0; i < DIM; i++)
00368 {
00369 tmp = fabs(x[i]) - 5.;
00370 if (tmp > 0.)
00371 {
00372 Fpen += tmp * tmp;
00373 }
00374 }
00375 Fadd += Fpen;
00376
00377
00378 for (i = 0; i < DIM; i++) {
00379
00380 tmpvect[i] = 0.;
00381 tmp = sqrt(pow(condition/10., ((double)i)/((double)(DIM-1))));
00382 for (j = 0; j < DIM; j++) {
00383 tmpvect[i] += tmp * rot2[i][j] * (x[j] - Xopt[j]);
00384 }
00385
00386 }
00387 x1 = tmpvect[0];
00388
00389 for (i = 0; i < DIM; i++) {
00390 if (fabs(tmpvect[i]) > 0.5)
00391 tmpvect[i] = round(tmpvect[i]);
00392 else
00393 tmpvect[i] = round(alpha * tmpvect[i])/alpha;
00394 }
00395
00396 for (i = 0; i < DIM; i++) {
00397 tmx[i] = 0.;
00398 for (j = 0; j < DIM; j++) {
00399 tmx[i] += rotation[i][j] * tmpvect[j];
00400 }
00401 }
00402
00403
00404 for (i = 0; i < DIM; i++)
00405 {
00406 Ftrue += pow(condition, ((double)i)/((double)(DIM-1))) * tmx[i] * tmx[i];
00407 }
00408 Ftrue = 0.1 * fmax(1e-4 * fabs(x1), Ftrue);
00409
00410 Ftrue += Fadd;
00411 Fval = Ftrue;
00412
00413 res.Fval = Fval;
00414 res.Ftrue = Ftrue;
00415 return res;
00416 }
00417
00418 TwoDoubles f8(double* x) {
00419
00420 static unsigned int funcId = 8;
00421 int i, rseed;
00422 static double scales;
00423 double tmp, Fadd, Fval, Ftrue = 0.;
00424 TwoDoubles res;
00425
00426 if (!isInitDone)
00427 {
00428 rseed = funcId + 10000 * trialid;
00429
00430 scales = fmax(1., sqrt((double)DIM) / 8.);
00431
00432 Fopt = computeFopt(funcId, trialid);
00433 computeXopt(rseed, DIM);
00434 for (i = 0; i < DIM; i ++)
00435 Xopt[i] *= 0.75;
00436 isInitDone = 1;
00437 }
00438 Fadd = Fopt;
00439
00440
00441
00442
00443 for (i = 0; i < DIM; i++) {
00444 tmx[i] = scales * (x[i] - Xopt[i]) + 1;
00445 }
00446
00447
00448 for (i = 0; i < DIM - 1; i++)
00449 {
00450 tmp = (tmx[i] * tmx[i] - tmx[i+1]);
00451 Ftrue += tmp * tmp;
00452 }
00453 Ftrue *= 1e2;
00454 for (i = 0; i < DIM - 1; i ++)
00455 {
00456 tmp = (tmx[i] - 1.);
00457 Ftrue += tmp * tmp;
00458 }
00459 Ftrue += Fadd;
00460 Fval = Ftrue;
00461
00462 res.Fval = Fval;
00463 res.Ftrue = Ftrue;
00464 return res;
00465 }
00466
00467 TwoDoubles f9(double* x) {
00468
00469 int i, j, rseed;
00470 static unsigned int funcId = 9;
00471 double scales, tmp, Fadd, Fval, Ftrue = 0.;
00472 TwoDoubles res;
00473
00474 if (!isInitDone)
00475 {
00476 rseed = funcId + 10000 * trialid;
00477
00478 Fopt = computeFopt(funcId, trialid);
00479
00480 computeRotation(rotation, rseed, DIM);
00481 scales = fmax(1., sqrt((double)DIM) / 8.);
00482 for (i = 0; i < DIM; i ++)
00483 {
00484 for (j = 0; j < DIM; j++)
00485 linearTF[i][j] = scales * rotation[i][j];
00486 }
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496 isInitDone = 1;
00497 }
00498 Fadd = Fopt;
00499
00500
00501
00502
00503 for (i = 0; i < DIM; i++) {
00504 tmx[i] = 0.5;
00505 for (j = 0; j < DIM; j++) {
00506 tmx[i] += linearTF[i][j] * x[j];
00507 }
00508 }
00509
00510
00511 for (i = 0; i < DIM - 1; i++)
00512 {
00513 tmp = (tmx[i] * tmx[i] - tmx[i+1]);
00514 Ftrue += tmp * tmp;
00515 }
00516 Ftrue *= 1e2;
00517 for (i = 0; i < DIM - 1; i ++)
00518 {
00519 tmp = (tmx[i] - 1.);
00520 Ftrue += tmp * tmp;
00521 }
00522
00523 Ftrue += Fadd;
00524 Fval = Ftrue;
00525
00526 res.Fval = Fval;
00527 res.Ftrue = Ftrue;
00528 return res;
00529 }
00530
00531 TwoDoubles f10(double* x) {
00532
00533 int i, j, rseed;
00534 static unsigned int funcId = 10;
00535 static double condition = 1e6;
00536 double Fadd, Fval, Ftrue = 0.;
00537 TwoDoubles res;
00538
00539 if (!isInitDone)
00540 {
00541 rseed = funcId + 10000 * trialid;
00542
00543 Fopt = computeFopt(funcId, trialid);
00544 computeXopt(rseed, DIM);
00545 computeRotation(rotation, rseed + 1000000, DIM);
00546 isInitDone = 1;
00547 }
00548 Fadd = Fopt;
00549
00550
00551
00552 for (i = 0; i < DIM; i++)
00553 {
00554 tmx[i] = 0.;
00555 for (j = 0; j < DIM; j++) {
00556 tmx[i] += rotation[i][j] * (x[j] - Xopt[j]);
00557 }
00558 }
00559
00560 monotoneTFosc(tmx);
00561
00562 for (i = 0; i < DIM; i++)
00563 {
00564 Ftrue += pow(condition, ((double)i)/((double)(DIM-1))) * tmx[i] * tmx[i];
00565 }
00566 Ftrue += Fadd;
00567 Fval = Ftrue;
00568
00569 res.Fval = Fval;
00570 res.Ftrue = Ftrue;
00571 return res;
00572 }
00573
00574 TwoDoubles f11(double* x) {
00575
00576 int i, j, rseed;
00577 static unsigned int funcId = 11;
00578 static double condition = 1e6;
00579 double Fadd, Fval, Ftrue;
00580 TwoDoubles res;
00581
00582 if (!isInitDone)
00583 {
00584 rseed = funcId + 10000 * trialid;
00585
00586 Fopt = computeFopt(funcId, trialid);
00587 computeXopt(rseed, DIM);
00588 computeRotation(rotation, rseed + 1000000, DIM);
00589 isInitDone = 1;
00590 }
00591 Fadd = Fopt;
00592
00593
00594
00595 for (i = 0; i < DIM; i++)
00596 {
00597 tmx[i] = 0.;
00598 for (j = 0; j < DIM; j++) {
00599 tmx[i] += rotation[i][j] * (x[j] - Xopt[j]);
00600 }
00601 }
00602
00603 monotoneTFosc(tmx);
00604
00605
00606 Ftrue = condition * tmx[0] * tmx[0];
00607 for (i = 1; i < DIM; i++)
00608 {
00609 Ftrue += tmx[i] * tmx[i];
00610 }
00611 Ftrue += Fadd;
00612 Fval = Ftrue;
00613 res.Fval = Fval;
00614 res.Ftrue = Ftrue;
00615 return res;
00616 }
00617
00618 TwoDoubles f12(double* x) {
00619
00620 int i, j, rseed;
00621 static unsigned int funcId = 12;
00622 static double condition = 1e6;
00623 static double beta = 0.5;
00624 double Fadd, Fval, Ftrue;
00625 TwoDoubles res;
00626
00627 if (!isInitDone)
00628 {
00629 rseed = funcId + 10000 * trialid;
00630
00631 Fopt = computeFopt(funcId, trialid);
00632 computeXopt(rseed + 1000000, DIM);
00633 computeRotation(rotation, rseed + 1000000, DIM);
00634 isInitDone = 1;
00635 }
00636 Fadd = Fopt;
00637
00638
00639
00640 for (i = 0; i < DIM; i++)
00641 {
00642 tmpvect[i] = 0.;
00643 for (j = 0; j < DIM; j++) {
00644 tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]);
00645 }
00646 if (tmpvect[i] > 0)
00647 {
00648 tmpvect[i] = pow(tmpvect[i], 1 + beta * ((double)i)/((double)(DIM-1)) * sqrt(tmpvect[i]));
00649 }
00650 }
00651
00652 for (i = 0; i < DIM; i++)
00653 {
00654 tmx[i] = 0.;
00655 for (j = 0; j < DIM; j++) {
00656 tmx[i] += rotation[i][j] * tmpvect[j];
00657 }
00658 }
00659
00660
00661 Ftrue = tmx[0] * tmx[0];
00662 for (i = 1; i < DIM; i++)
00663 {
00664 Ftrue += condition * tmx[i] * tmx[i];
00665 }
00666 Ftrue += Fadd;
00667 Fval = Ftrue;
00668
00669 res.Fval = Fval;
00670 res.Ftrue = Ftrue;
00671 return res;
00672 }
00673
00674 TwoDoubles f13(double* x) {
00675
00676 int i, j, k, rseed;
00677 static unsigned int funcId = 13;
00678 static double condition = 10.;
00679 static double alpha = 100.;
00680 double Fadd, Fval, Ftrue = 0.;
00681 TwoDoubles res;
00682
00683 if (!isInitDone)
00684 {
00685 rseed = funcId + 10000 * trialid;
00686
00687 Fopt = computeFopt(funcId, trialid);
00688 computeXopt(rseed, DIM);
00689 computeRotation(rotation, rseed + 1000000, DIM);
00690 computeRotation(rot2, rseed, DIM);
00691
00692 for (i = 0; i < DIM; i++)
00693 {
00694 for (j = 0; j < DIM; j++)
00695 {
00696 linearTF[i][j] = 0.;
00697 for (k = 0; k < DIM; k++)
00698 {
00699 linearTF[i][j] += rotation[i][k] * pow(sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j];
00700 }
00701 }
00702 }
00703 isInitDone = 1;
00704 }
00705 Fadd = Fopt;
00706
00707
00708
00709 for (i = 0; i < DIM; i++)
00710 {
00711 tmx[i] = 0.;
00712 for (j = 0; j < DIM; j++) {
00713 tmx[i] += linearTF[i][j] * (x[j] - Xopt[j]);
00714 }
00715 }
00716
00717
00718 for (i = 1; i < DIM; i++)
00719 {
00720 Ftrue += tmx[i] * tmx[i];
00721 }
00722 Ftrue = alpha * sqrt(Ftrue);
00723 Ftrue += tmx[0] * tmx[0];
00724
00725 Ftrue += Fadd;
00726 Fval = Ftrue;
00727
00728 res.Fval = Fval;
00729 res.Ftrue = Ftrue;
00730 return res;
00731 }
00732
00733 TwoDoubles f14(double* x) {
00734
00735 int i, j, rseed;
00736 static unsigned int funcId = 14;
00737 static double alpha = 4.;
00738 double Fadd, Fval, Ftrue = 0.;
00739 TwoDoubles res;
00740
00741 if (!isInitDone)
00742 {
00743 rseed = funcId + 10000 * trialid;
00744
00745 Fopt = computeFopt(funcId, trialid);
00746 computeXopt(rseed, DIM);
00747 computeRotation(rotation, rseed + 1000000, DIM);
00748 isInitDone = 1;
00749 }
00750 Fadd = Fopt;
00751
00752
00753
00754 for (i = 0; i < DIM; i++)
00755 {
00756 tmx[i] = 0.;
00757 for (j = 0; j < DIM; j++) {
00758 tmx[i] += rotation[i][j] * (x[j] - Xopt[j]);
00759 }
00760 }
00761
00762
00763 for (i = 0; i < DIM; i++)
00764 {
00765 Ftrue += pow(fabs(tmx[i]), 2. + alpha * ((double)i)/((double)(DIM-1)));
00766 }
00767 Ftrue = sqrt(Ftrue);
00768
00769 Ftrue += Fadd;
00770 Fval = Ftrue;
00771
00772 res.Fval = Fval;
00773 res.Ftrue = Ftrue;
00774 return res;
00775 }
00776
00777 TwoDoubles f15(double* x) {
00778
00779 int i, j, k, rseed;
00780 static unsigned int funcId = 15;
00781 static double condition = 10.;
00782 static double beta = 0.2;
00783 double tmp = 0., tmp2 = 0., Fadd, Fval, Ftrue;
00784 TwoDoubles res;
00785
00786 if (!isInitDone)
00787 {
00788 rseed = funcId + 10000 * trialid;
00789
00790 Fopt = computeFopt(funcId, trialid);
00791 computeXopt(rseed, DIM);
00792 computeRotation(rotation, rseed + 1000000, DIM);
00793 computeRotation(rot2, rseed, DIM);
00794 for (i = 0; i < DIM; i++)
00795 {
00796 for (j = 0; j < DIM; j++)
00797 {
00798 linearTF[i][j] = 0.;
00799 for (k = 0; k < DIM; k++) {
00800 linearTF[i][j] += rotation[i][k] * pow(sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j];
00801 }
00802 }
00803 }
00804 isInitDone = 1;
00805 }
00806 Fadd = Fopt;
00807
00808
00809
00810 for (i = 0; i < DIM; i++)
00811 {
00812 tmpvect[i] = 0.;
00813 for (j = 0; j < DIM; j++)
00814 {
00815 tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]);
00816 }
00817 }
00818
00819 monotoneTFosc(tmpvect);
00820 for (i = 0; i < DIM; i++)
00821 {
00822 if (tmpvect[i] > 0)
00823 tmpvect[i] = pow(tmpvect[i], 1 + beta * ((double)i)/((double)(DIM-1)) * sqrt(tmpvect[i]));
00824 }
00825 for (i = 0; i < DIM; i++)
00826 {
00827 tmx[i] = 0.;
00828 for (j = 0; j < DIM; j++)
00829 {
00830 tmx[i] += linearTF[i][j] * tmpvect[j];
00831 }
00832 }
00833
00834 for (i = 0; i < DIM; i++)
00835 {
00836 tmp += cos(2. * M_PI * tmx[i]);
00837 tmp2 += tmx[i] * tmx[i];
00838 }
00839 Ftrue = 10. * ((double)DIM - tmp) + tmp2;
00840 Ftrue += Fadd;
00841 Fval = Ftrue;
00842
00843 res.Fval = Fval;
00844 res.Ftrue = Ftrue;
00845 return res;
00846 }
00847
00848 TwoDoubles f16(double* x) {
00849
00850 int i, j, k, rseed;
00851 static unsigned int funcId = 16;
00852 static double condition = 100.;
00853 static double aK[12];
00854 static double bK[12];
00855 static double F0;
00856 double tmp, Fadd, Fval, Fpen = 0., Ftrue = 0.;
00857 TwoDoubles res;
00858
00859 if (!isInitDone)
00860 {
00861 rseed = funcId + 10000 * trialid;
00862
00863 Fopt = computeFopt(funcId, trialid);
00864 computeXopt(rseed, DIM);
00865 computeRotation(rotation, rseed + 1000000, DIM);
00866 computeRotation(rot2, rseed, DIM);
00867 for (i = 0; i < DIM; i++)
00868 {
00869 for (j = 0; j < DIM; j++)
00870 {
00871 linearTF[i][j] = 0.;
00872 for (k = 0; k < DIM; k++) {
00873 linearTF[i][j] += rotation[i][k] * pow(1./sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j];
00874 }
00875 }
00876 }
00877
00878 F0 = 0.;
00879 for (i = 0; i < 12; i ++)
00880 {
00881 aK[i] = pow(0.5, (double)i);
00882 bK[i] = pow(3., (double)i);
00883 F0 += aK[i] * cos(2 * M_PI * bK[i] * 0.5);
00884 }
00885 isInitDone = 1;
00886 }
00887 Fadd = Fopt;
00888
00889
00890 for (i = 0; i < DIM; i++)
00891 {
00892 tmp = fabs(x[i]) - 5.;
00893 if (tmp > 0.)
00894 {
00895 Fpen += tmp * tmp;
00896 }
00897 }
00898 Fadd += 10./(double)DIM * Fpen;
00899
00900
00901 for (i = 0; i < DIM; i++)
00902 {
00903 tmpvect[i] = 0.;
00904 for (j = 0; j < DIM; j++)
00905 {
00906 tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]);
00907 }
00908 }
00909
00910 monotoneTFosc(tmpvect);
00911 for (i = 0; i < DIM; i++)
00912 {
00913 tmx[i] = 0.;
00914 for (j = 0; j < DIM; j++)
00915 {
00916 tmx[i] += linearTF[i][j] * tmpvect[j];
00917 }
00918 }
00919
00920 for (i = 0; i < DIM; i++)
00921 {
00922 tmp = 0.;
00923 for (j = 0; j < 12; j++)
00924 {
00925 tmp += cos(2 * M_PI * (tmx[i] + 0.5) * bK[j]) * aK[j];
00926 }
00927 Ftrue += tmp;
00928 }
00929 Ftrue = 10. * pow(Ftrue/(double)DIM - F0, 3.);
00930 Ftrue += Fadd;
00931 Fval = Ftrue;
00932
00933 res.Fval = Fval;
00934 res.Ftrue = Ftrue;
00935 return res;
00936 }
00937
00938 TwoDoubles f17(double* x) {
00939
00940 int i, j, rseed;
00941 static unsigned int funcId = 17;
00942 static double condition = 10.;
00943 static double beta = 0.5;
00944 double tmp, Fadd, Fval, Fpen = 0., Ftrue = 0.;
00945 TwoDoubles res;
00946
00947 if (!isInitDone)
00948 {
00949 rseed = funcId + 10000 * trialid;
00950
00951 Fopt = computeFopt(funcId, trialid);
00952 computeXopt(rseed, DIM);
00953 computeRotation(rotation, rseed + 1000000, DIM);
00954 computeRotation(rot2, rseed, DIM);
00955 isInitDone = 1;
00956 }
00957 Fadd = Fopt;
00958
00959
00960 for (i = 0; i < DIM; i++)
00961 {
00962 tmp = fabs(x[i]) - 5.;
00963 if (tmp > 0.)
00964 {
00965 Fpen += tmp * tmp;
00966 }
00967 }
00968 Fadd += 10. * Fpen;
00969
00970
00971 for (i = 0; i < DIM; i++)
00972 {
00973 tmpvect[i] = 0.;
00974 for (j = 0; j < DIM; j++)
00975 {
00976 tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]);
00977 }
00978 if (tmpvect[i] > 0)
00979 tmpvect[i] = pow(tmpvect[i], 1 + beta * ((double)i)/((double)(DIM-1)) * sqrt(tmpvect[i]));
00980 }
00981
00982 for (i = 0; i < DIM; i++)
00983 {
00984 tmx[i] = 0.;
00985 tmp = pow(sqrt(condition), ((double)i)/((double)(DIM-1)));
00986 for (j = 0; j < DIM; j++)
00987 {
00988 tmx[i] += tmp * rot2[i][j] * tmpvect[j];
00989 }
00990 }
00991
00992
00993 for (i = 0; i < DIM - 1; i++)
00994 {
00995 tmp = tmx[i] * tmx[i] + tmx[i+1] * tmx[i+1];
00996 Ftrue += pow(tmp, 0.25) * (pow(sin(50 * pow(tmp, 0.1)), 2.) + 1.);
00997 }
00998 Ftrue = pow(Ftrue/(double)(DIM - 1), 2.);
00999 Ftrue += Fadd;
01000 Fval = Ftrue;
01001
01002 res.Fval = Fval;
01003 res.Ftrue = Ftrue;
01004 return res;
01005 }
01006
01007 TwoDoubles f18(double* x) {
01008
01009 int i, j, rseed;
01010 static unsigned int funcId = 18;
01011 static double condition = 1e3;
01012 static double beta = 0.5;
01013 double tmp, Fadd, Fval, Fpen = 0., Ftrue = 0.;
01014 TwoDoubles res;
01015
01016 if (!isInitDone)
01017 {
01018 rseed = 17 + 10000 * trialid;
01019
01020 Fopt = computeFopt(funcId, trialid);
01021 computeXopt(rseed, DIM);
01022 computeRotation(rotation, rseed + 1000000, DIM);
01023 computeRotation(rot2, rseed, DIM);
01024 isInitDone = 1;
01025 }
01026 Fadd = Fopt;
01027
01028 for (i = 0; i < DIM; i++)
01029 {
01030 tmp = fabs(x[i]) - 5.;
01031 if (tmp > 0.)
01032 {
01033 Fpen += tmp * tmp;
01034 }
01035 }
01036 Fadd += 10. * Fpen;
01037
01038
01039 for (i = 0; i < DIM; i++)
01040 {
01041 tmpvect[i] = 0.;
01042 for (j = 0; j < DIM; j++)
01043 {
01044 tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]);
01045 }
01046 if (tmpvect[i] > 0)
01047 tmpvect[i] = pow(tmpvect[i], 1. + beta * ((double)i)/((double)(DIM-1)) * sqrt(tmpvect[i]));
01048 }
01049
01050 for (i = 0; i < DIM; i++)
01051 {
01052 tmx[i] = 0.;
01053 tmp = pow(sqrt(condition), ((double)i)/((double)(DIM-1)));
01054 for (j = 0; j < DIM; j++)
01055 {
01056 tmx[i] += tmp * rot2[i][j] * tmpvect[j];
01057 }
01058 }
01059
01060
01061 for (i = 0; i < DIM - 1; i++)
01062 {
01063 tmp = tmx[i] * tmx[i] + tmx[i+1] * tmx[i+1];
01064 Ftrue += pow(tmp, 0.25) * (pow(sin(50. * pow(tmp, 0.1)), 2.) + 1.);
01065 }
01066 Ftrue = pow(Ftrue/(double)(DIM - 1), 2.);
01067 Ftrue += Fadd;
01068 Fval = Ftrue;
01069
01070 res.Fval = Fval;
01071 res.Ftrue = Ftrue;
01072 return res;
01073 }
01074
01075 TwoDoubles f19(double* x) {
01076
01077 int i, j, rseed;
01078 static unsigned int funcId = 19;
01079 double scales, F2, tmp = 0., tmp2, Fadd, Fval, Ftrue = 0.;
01080 TwoDoubles res;
01081
01082 if (!isInitDone)
01083 {
01084 rseed = funcId + 10000 * trialid;
01085
01086 Fopt = computeFopt(funcId, trialid);
01087
01088 scales = fmax(1., sqrt((double)DIM) / 8.);
01089 computeRotation(rotation, rseed, DIM);
01090 for (i = 0; i < DIM; i ++)
01091 {
01092 for (j = 0; j < DIM; j++)
01093 {
01094 linearTF[i][j] = scales * rotation[i][j];
01095 }
01096 }
01097 for (i = 0; i < DIM; i++)
01098 {
01099 Xopt[i] = 0.;
01100 for (j = 0; j < DIM; j++)
01101 {
01102 Xopt[i] += linearTF[j][i] * 0.5/scales/scales;
01103 }
01104 }
01105 isInitDone = 1;
01106 }
01107 Fadd = Fopt;
01108
01109
01110
01111 for (i = 0; i < DIM; i++) {
01112 tmx[i] = 0.5;
01113 for (j = 0; j < DIM; j++) {
01114 tmx[i] += linearTF[i][j] * x[j];
01115 }
01116 }
01117
01118
01119 for (i = 0; i < DIM - 1; i++)
01120 {
01121 tmp2 = tmx[i] * tmx[i] -tmx[i+1];
01122 F2 = 100. * tmp2 * tmp2;
01123 tmp2 = 1 - tmx[i];
01124 F2 += tmp2 * tmp2;
01125 tmp += F2 / 4000. - cos(F2);
01126 }
01127 Ftrue = 10. + 10. * tmp / (double)(DIM - 1);
01128
01129 Ftrue += Fadd;
01130 Fval = Ftrue;
01131
01132 res.Fval = Fval;
01133 res.Ftrue = Ftrue;
01134 return res;
01135 }
01136
01137 TwoDoubles f20(double* x) {
01138
01139 int i, rseed;
01140 static unsigned int funcId = 20;
01141 static double condition = 10.;
01142 double tmp, Fadd, Fval, Fpen = 0., Ftrue = 0.;
01143 TwoDoubles res;
01144
01145 if (!isInitDone)
01146 {
01147 rseed = funcId + 10000 * trialid;
01148
01149 Fopt = computeFopt(funcId, trialid);
01150 unif(tmpvect, DIM, rseed);
01151 for (i = 0; i < DIM; i++)
01152 {
01153 Xopt[i] = 0.5 * 4.2096874633;
01154 if (tmpvect[i] - 0.5 < 0)
01155 Xopt[i] *= -1.;
01156 }
01157 isInitDone = 1;
01158 }
01159 Fadd = Fopt;
01160
01161
01162 for (i = 0; i < DIM; i++)
01163 {
01164 tmpvect[i] = 2. * x[i];
01165 if (Xopt[i] < 0.)
01166 tmpvect[i] *= -1.;
01167 }
01168
01169 tmx[0] = tmpvect[0];
01170 for (i = 1; i < DIM; i++)
01171 {
01172 tmx[i] = tmpvect[i] + 0.25 * (tmpvect[i-1] - 2. * fabs(Xopt[i-1]));
01173 }
01174
01175 for (i = 0; i < DIM; i++)
01176 {
01177 tmx[i] -= 2 * fabs(Xopt[i]);
01178 tmx[i] *= pow(sqrt(condition), ((double)i)/((double)(DIM-1)));
01179 tmx[i] = 100. * (tmx[i] + 2 * fabs(Xopt[i]));
01180 }
01181
01182
01183 for (i = 0; i < DIM; i++)
01184 {
01185 tmp = fabs(tmx[i]) - 500.;
01186 if (tmp > 0.)
01187 {
01188 Fpen += tmp * tmp;
01189 }
01190 }
01191 Fadd += 0.01 * Fpen;
01192
01193
01194 for (i = 0; i < DIM; i++)
01195 {
01196 Ftrue += tmx[i] * sin(sqrt(fabs(tmx[i])));
01197 }
01198 Ftrue = 0.01 * ((418.9828872724339) - Ftrue / (double)DIM);
01199
01200 Ftrue += Fadd;
01201 Fval = Ftrue;
01202
01203 res.Fval = Fval;
01204 res.Ftrue = Ftrue;
01205 return res;
01206 }
01207
01208 TwoDoubles f21(double* x) {
01209
01210 int i, j, k, rseed;
01211 static unsigned int funcId = 21;
01212 static double fitvalues[2] = {1.1, 9.1};
01213 static double maxcondition = 1000.;
01214 static double arrCondition[NHIGHPEAKS21];
01215 static double peakvalues[NHIGHPEAKS21];
01216 static double a = 0.1;
01217 double tmp2, f = 0., Fadd, Fval, tmp, Fpen = 0., Ftrue = 0.;
01218 double fac = -0.5 / (double)DIM;
01219 TwoDoubles res;
01220
01221 if (!isInitDone)
01222 {
01223 rseed = funcId + 10000 * trialid;
01224
01225 Fopt = computeFopt(funcId, trialid);
01226 computeRotation(rotation, rseed, DIM);
01227 peaks = peaks21;
01228 unif(peaks, NHIGHPEAKS21 - 1, rseed);
01229 rperm = rperm21;
01230 for (i = 0; i < NHIGHPEAKS21 - 1; i++)
01231 rperm[i] = i;
01232 qsort(rperm, NHIGHPEAKS21 - 1, sizeof(int), compare_doubles);
01233
01234
01235 arrCondition[0] = sqrt(maxcondition);
01236 peakvalues[0] = 10;
01237 for (i = 1; i < NHIGHPEAKS21; i++)
01238 {
01239 arrCondition[i] = pow(maxcondition, (double)(rperm[i-1])/((double)(NHIGHPEAKS21-2)));
01240 peakvalues[i] = (double)(i-1)/(double)(NHIGHPEAKS21-2) * (fitvalues[1] - fitvalues[0]) + fitvalues[0];
01241 }
01242 arrScales = arrScales21;
01243 for (i = 0; i < NHIGHPEAKS21; i++)
01244 {
01245 unif(peaks, DIM, rseed + 1000 * i);
01246 for (j = 0; j < DIM; j++)
01247 rperm[j] = j;
01248 qsort(rperm, DIM, sizeof(int), compare_doubles);
01249 for (j = 0; j < DIM; j++)
01250 {
01251 arrScales[i][j] = pow(arrCondition[i], ((double)rperm[j])/((double)(DIM-1)) - 0.5);
01252 }
01253 }
01254
01255 unif(peaks, DIM * NHIGHPEAKS21, rseed);
01256 Xlocal = Xlocal21;
01257 for (i = 0; i < DIM; i++)
01258 {
01259 Xopt[i] = 0.8 * (10. * peaks[i] -5.);
01260 for (j = 0; j < NHIGHPEAKS21; j++)
01261 {
01262 Xlocal[i][j] = 0.;
01263 for (k = 0; k < DIM; k++)
01264 {
01265 Xlocal[i][j] += rotation[i][k] * (10. * peaks[j * DIM + k] -5.);
01266 }
01267 if (j == 0)
01268 Xlocal[i][j] *= 0.8;
01269 }
01270 }
01271 isInitDone = 1;
01272 }
01273 Fadd = Fopt;
01274
01275
01276 for (i = 0; i < DIM; i++)
01277 {
01278 tmp = fabs(x[i]) - 5.;
01279 if (tmp > 0.)
01280 {
01281 Fpen += tmp * tmp;
01282 }
01283 }
01284 Fadd += Fpen;
01285
01286
01287 for (i = 0; i < DIM; i++)
01288 {
01289 tmx[i] = 0.;
01290 for (j = 0; j < DIM; j++)
01291 {
01292 tmx[i] += rotation[i][j] * x[j];
01293 }
01294 }
01295
01296
01297 for (i = 0; i < NHIGHPEAKS21; i++)
01298 {
01299 tmp2 = 0.;
01300 for (j = 0; j < DIM; j++)
01301 {
01302 tmp = (tmx[j] - Xlocal[j][i]);
01303 tmp2 += arrScales[i][j] * tmp * tmp;
01304 }
01305 tmp2 = peakvalues[i] * exp(fac * tmp2);
01306 f = fmax(f, tmp2);
01307 }
01308
01309 f = 10. - f;
01310 if (f > 0)
01311 {
01312 Ftrue = log(f)/a;
01313 Ftrue = pow(exp(Ftrue + 0.49*(sin(Ftrue) + sin(0.79*Ftrue))), a);
01314 }
01315 else if (f < 0)
01316 {
01317 Ftrue = log(-f)/a;
01318 Ftrue = -pow(exp(Ftrue + 0.49*(sin(0.55 * Ftrue) + sin(0.31*Ftrue))), a);
01319 }
01320 else
01321 Ftrue = f;
01322
01323 Ftrue *= Ftrue;
01324 Ftrue += Fadd;
01325 Fval = Ftrue;
01326
01327 res.Fval = Fval;
01328 res.Ftrue = Ftrue;
01329 return res;
01330 }
01331
01332 TwoDoubles f22(double* x) {
01333
01334 int i, j, k, rseed;
01335 static unsigned int funcId = 22;
01336 static double fitvalues[2] = {1.1, 9.1};
01337 static double maxcondition = 1000.;
01338 static double arrCondition[NHIGHPEAKS22];
01339 static double peakvalues[NHIGHPEAKS22];
01340 static double a = 0.1;
01341 double tmp2, f = 0., Fadd, Fval, tmp, Fpen = 0., Ftrue = 0.;
01342 double fac = -0.5 / (double)DIM;
01343 TwoDoubles res;
01344
01345 if (!isInitDone)
01346 {
01347 rseed = funcId + 10000 * trialid;
01348
01349 Fopt = computeFopt(funcId, trialid);
01350 computeRotation(rotation, rseed, DIM);
01351 peaks = peaks22;
01352 unif(peaks, NHIGHPEAKS22 - 1, rseed);
01353 rperm = rperm22;
01354 for (i = 0; i < NHIGHPEAKS22 - 1; i++)
01355 rperm[i] = i;
01356 qsort(rperm, NHIGHPEAKS22 - 1, sizeof(int), compare_doubles);
01357
01358 arrCondition[0] = maxcondition;
01359 peakvalues[0] = 10;
01360 for (i = 1; i < NHIGHPEAKS22; i++)
01361 {
01362 arrCondition[i] = pow(maxcondition, (double)(rperm[i-1])/((double)(NHIGHPEAKS22-2)));
01363 peakvalues[i] = (double)(i-1)/(double)(NHIGHPEAKS22-2) * (fitvalues[1] - fitvalues[0]) + fitvalues[0];
01364 }
01365 arrScales = arrScales22;
01366 for (i = 0; i < NHIGHPEAKS22; i++)
01367 {
01368 unif(peaks, DIM, rseed + 1000 * i);
01369 for (j = 0; j < DIM; j++)
01370 rperm[j] = j;
01371 qsort(rperm, DIM, sizeof(int), compare_doubles);
01372 for (j = 0; j < DIM; j++)
01373 {
01374 arrScales[i][j] = pow(arrCondition[i], ((double)rperm[j])/((double)(DIM-1)) - 0.5);
01375 }
01376 }
01377
01378 unif(peaks, DIM * NHIGHPEAKS22, rseed);
01379 Xlocal = Xlocal22;
01380 for (i = 0; i < DIM; i++)
01381 {
01382 Xopt[i] = 0.8 * (9.8 * peaks[i] -4.9);
01383 for (j = 0; j < NHIGHPEAKS22; j++)
01384 {
01385 Xlocal[i][j] = 0.;
01386 for (k = 0; k < DIM; k++)
01387 {
01388 Xlocal[i][j] += rotation[i][k] * (9.8 * peaks[j * DIM + k] -4.9);
01389 }
01390 if (j == 0)
01391 Xlocal[i][j] *= 0.8;
01392 }
01393 }
01394 isInitDone = 1;
01395 }
01396 Fadd = Fopt;
01397
01398
01399 for (i = 0; i < DIM; i++)
01400 {
01401 tmp = fabs(x[i]) - 5.;
01402 if (tmp > 0.)
01403 {
01404 Fpen += tmp * tmp;
01405 }
01406 }
01407 Fadd += Fpen;
01408
01409
01410 for (i = 0; i < DIM; i++)
01411 {
01412 tmx[i] = 0.;
01413 for (j = 0; j < DIM; j++)
01414 {
01415 tmx[i] += rotation[i][j] * x[j];
01416 }
01417 }
01418
01419
01420 for (i = 0; i < NHIGHPEAKS22; i++)
01421 {
01422 tmp2 = 0.;
01423 for (j = 0; j < DIM; j++)
01424 {
01425 tmp = (tmx[j] - Xlocal[j][i]);
01426 tmp2 += arrScales[i][j] * tmp * tmp;
01427 }
01428 tmp2 = peakvalues[i] * exp(fac * tmp2);
01429 f = fmax(f, tmp2);
01430 }
01431
01432 f = 10. - f;
01433 if (f > 0)
01434 {
01435 Ftrue = log(f)/a;
01436 Ftrue = pow(exp(Ftrue + 0.49*(sin(Ftrue) + sin(0.79*Ftrue))), a);
01437 }
01438 else if (f < 0)
01439 {
01440 Ftrue = log(-f)/a;
01441 Ftrue = -pow(exp(Ftrue + 0.49*(sin(0.55 * Ftrue) + sin(0.31*Ftrue))), a);
01442 }
01443 else
01444 Ftrue = f;
01445
01446 Ftrue *= Ftrue;
01447 Ftrue += Fadd;
01448 Fval = Ftrue;
01449
01450
01451 res.Fval = Fval;
01452 res.Ftrue = Ftrue;
01453 return res;
01454 }
01455
01456 TwoDoubles f23(double* x) {
01457
01458 int i, j, k, rseed;
01459 static unsigned int funcId = 23;
01460 static double condition = 100.;
01461 double Fadd = 0., Fpen = 0., tmp, Ftrue = 0., arr, prod = 1., tmp2, Fval;
01462 double *ptmx, *plinTF, *ptmp;
01463 TwoDoubles res;
01464
01465 if (!isInitDone)
01466 {
01467 rseed = funcId + 10000 * trialid;
01468
01469 Fopt = computeFopt(funcId, trialid);
01470 computeXopt(rseed, DIM);
01471 computeRotation(rotation, rseed + 1000000, DIM);
01472 computeRotation(rot2, rseed, DIM);
01473
01474 for (i = 0; i < DIM; i++)
01475 {
01476 for (j = 0; j < DIM; j++)
01477 {
01478 linearTF[i][j] = 0.;
01479 for (k = 0; k < DIM; k++)
01480 {
01481 linearTF[i][j] += rotation[i][k] * pow(sqrt(condition), ((double)k)/(double)(DIM - 1)) * rot2[k][j];
01482 }
01483 }
01484 }
01485 isInitDone = 1;
01486 }
01487 Fadd = Fopt;
01488
01489
01490 for (i = 0; i < DIM; i++)
01491 {
01492 tmp = fabs(x[i]) - 5.;
01493 if (tmp > 0.)
01494 {
01495 Fpen += tmp * tmp;
01496 }
01497 }
01498 Fadd += Fpen;
01499
01500
01501
01502 for (j = 0; j < DIM; j++)
01503 tmpvect[j] = x[j] - Xopt[j];
01504 for (i = 0; i < DIM; i++) {
01505 tmx[i] = 0.;
01506 ptmx = &tmx[i];
01507 plinTF = linearTF[i];
01508 ptmp = tmpvect;
01509 for (j = 0; j < DIM; j++) {
01510 *ptmx += *plinTF++ * *ptmp++;
01511 }
01512 }
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522 for (i = 0; i < DIM; i++)
01523 {
01524 tmp = 0.;
01525 for (j = 1; j < 33; j++)
01526 {
01527 tmp2 = pow(2., (double)j);
01528 arr = tmx[i] * tmp2;
01529 tmp += fabs(arr - round(arr)) / tmp2;
01530 }
01531 tmp = 1. + tmp * (double)(i + 1);
01532 prod *= tmp;
01533 }
01534 Ftrue = 10./(double)DIM/(double)DIM * (-1. + pow(prod, 10./pow((double)DIM, 1.2)));
01535 Ftrue += Fadd;
01536 Fval = Ftrue;
01537
01538 res.Fval = Fval;
01539 res.Ftrue = Ftrue;
01540 return res;
01541 }
01542
01543 TwoDoubles f24(double* x) {
01544
01545
01546 int i, j, k, rseed;
01547 static unsigned int funcId = 24;
01548 static double condition = 100.;
01549 static double mu1 = 2.5;
01550 double Fadd, Fpen = 0., tmp, Ftrue = 0., tmp2 = 0., tmp3 = 0., tmp4 = 0., Fval;
01551 double s = 1. - 0.5 / (sqrt((double)(DIM + 20)) - 4.1);
01552 static double d = 1.;
01553 double mu2 = -sqrt((mu1 * mu1 - d) / s);
01554 TwoDoubles res;
01555
01556 if (!isInitDone)
01557 {
01558 rseed = funcId + 10000 * trialid;
01559
01560 Fopt = computeFopt(funcId, trialid);
01561 computeRotation(rotation, rseed + 1000000, DIM);
01562 computeRotation(rot2, rseed, DIM);
01563 gauss(tmpvect, DIM, rseed);
01564 for (i = 0; i < DIM; i++)
01565 {
01566 Xopt[i] = 0.5 * mu1;
01567 if (tmpvect[i] < 0.)
01568 Xopt[i] *= -1.;
01569 }
01570
01571 for (i = 0; i < DIM; i++)
01572 {
01573 for (j = 0; j < DIM; j++)
01574 {
01575 linearTF[i][j] = 0.;
01576 for (k = 0; k < DIM; k++) {
01577 linearTF[i][j] += rotation[i][k] * pow(sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j];
01578 }
01579 }
01580 }
01581 isInitDone = 1;
01582 }
01583 Fadd = Fopt;
01584
01585
01586 for (i = 0; i < DIM; i++)
01587 {
01588 tmp = fabs(x[i]) - 5.;
01589 if (tmp > 0.)
01590 {
01591 Fpen += tmp * tmp;
01592 }
01593 }
01594 Fadd += 1e4 * Fpen;
01595
01596
01597 for (i = 0; i < DIM; i++)
01598 {
01599 tmx[i] = 2. * x[i];
01600 if (Xopt[i] < 0.)
01601 tmx[i] *= -1.;
01602 }
01603
01604
01605 tmp = 0.;
01606 for (i = 0; i < DIM; i++)
01607 {
01608 tmp2 += (tmx[i] - mu1) * (tmx[i] - mu1);
01609 tmp3 += (tmx[i] - mu2) * (tmx[i] - mu2);
01610 tmp4 = 0.;
01611 for (j = 0; j < DIM; j++)
01612 {
01613 tmp4 += linearTF[i][j] * (tmx[j] - mu1);
01614 }
01615 tmp += cos(2 * M_PI * tmp4);
01616 }
01617 Ftrue = fmin(tmp2, d * (double)DIM + s * tmp3) + 10. * ((double)DIM - tmp);
01618 Ftrue += Fadd;
01619 Fval = Ftrue;
01620
01621 res.Fval = Fval;
01622 res.Ftrue = Ftrue;
01623 return res;
01624 }
01625
01626
01627 void initbenchmarks(void)
01628 {
01629
01630 int i;
01631 tmpvect = (double*)malloc(sizeof(double) * DIM);
01632 tmx = (double*)malloc(sizeof(double) * DIM);
01633 rotation = (double**)malloc(sizeof(double*) * DIM);
01634 rot2 = (double**)malloc(sizeof(double*) * DIM);
01635 linearTF = (double**)malloc(sizeof(double*) * DIM);
01636 peaks21 = (double*)malloc(sizeof(double) * DIM * NHIGHPEAKS21);
01637 rperm21 = (int*)malloc(sizeof(int) * (int)fmax(DIM, NHIGHPEAKS21 - 1));
01638 arrScales21 = (double**)malloc(sizeof(double*) * NHIGHPEAKS21);
01639 Xlocal21 = (double**)malloc(sizeof(double*) * DIM);
01640 peaks22 = (double*)malloc(sizeof(double) * DIM * NHIGHPEAKS22);
01641 rperm22 = (int*)malloc(sizeof(int) * (int)fmax(DIM, NHIGHPEAKS22 - 1));
01642 arrScales22 = (double**)malloc(sizeof(double*) * NHIGHPEAKS22);
01643 Xlocal22 = (double**)malloc(sizeof(double*) * DIM);
01644
01645 for (i = 0; i < DIM; i++)
01646 {
01647 rotation[i] = (double*)malloc(sizeof(double) * DIM);
01648 rot2[i] = (double*)malloc(sizeof(double) * DIM);
01649 linearTF[i] = (double*)malloc(sizeof(double) * DIM);
01650 Xlocal21[i] = (double*)malloc(sizeof(double) * NHIGHPEAKS21);
01651 Xlocal22[i] = (double*)malloc(sizeof(double) * NHIGHPEAKS22);
01652 }
01653 for (i = 0; i < NHIGHPEAKS21; i++)
01654 arrScales21[i] = (double*)malloc(sizeof(double) * DIM);
01655 for (i = 0; i < NHIGHPEAKS22; i++)
01656 arrScales22[i] = (double*)malloc(sizeof(double) * DIM);
01657
01658 return;
01659 }
01660
01661 void finibenchmarks(void)
01662 {
01663 free(tmpvect);
01664 free(tmx);
01665 freeStarStar(rotation, DIM);
01666 freeStarStar(rot2, DIM);
01667 freeStarStar(linearTF, DIM);
01668 free(peaks21);
01669 free(rperm21);
01670 freeStarStar(arrScales21, NHIGHPEAKS21);
01671 freeStarStar(Xlocal21, DIM);
01672 free(peaks22);
01673 free(rperm22);
01674 freeStarStar(arrScales22, NHIGHPEAKS22);
01675 freeStarStar(Xlocal22, DIM);
01676 return;
01677 }
01678
01679 bbobFunction handles[24] = { &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8, &f9, &f10, &f11, &f12, &f13, &f14, &f15, &f16, &f17, &f18, &f19, &f20, &f21, &f22, &f23, &f24};
01680 unsigned int handlesLength = 24;
01681