00001
00002
00003
00004
00005
00006 #include <stdio.h>
00007 #include <string.h>
00008 #include <time.h>
00009 #include <stdlib.h>
00010 #include "bbobStructures.h"
00011
00012
00013 void MY_OPTIMIZER(double(*fitnessfunction)(double*), unsigned int dim, double ftarget,
00014 double maxfunevals);
00015
00016 int main(void)
00017 {
00018 unsigned int dim[6] = {2, 3, 5, 10, 20, 40};
00019 unsigned int instances[15] = {1, 2, 3, 4, 5, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
00020 unsigned int idx_dim, ifun, idx_instances, seed;
00021 int independent_restarts;
00022 double maxfunevals, minfunevals;
00023
00024 clock_t t0 = clock();
00025 time_t Tval;
00026
00027
00028
00029
00030 ParamStruct params = fgeneric_getDefaultPARAMS();
00031
00032
00033
00034 strcpy(params.dataPath, "PUT_MY_BBOB_DATA_PATH");
00035
00036
00037 strcpy(params.algName, "PUT ALGORITHM NAME");
00038 strcpy(params.comments, "PUT MORE DETAILED INFORMATION, PARAMETER SETTINGS ETC");
00039
00040 seed = time(NULL);
00041 srand(seed);
00042 printf("random seed set to %d\n", seed);
00043
00044
00045
00046
00047
00048 for (idx_dim = 0; idx_dim < 6; idx_dim++)
00049 {
00050
00051
00052
00053 for (ifun = 1; ifun <= 24; ifun++)
00054 {
00055 for (idx_instances = 0; idx_instances < 15; idx_instances++)
00056 {
00057
00058 params.DIM = dim[idx_dim];
00059 params.funcId = ifun;
00060 params.instanceId = instances[idx_instances];
00061
00062 fgeneric_initialize(params);
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 maxfunevals = 5. * dim[idx_dim];
00077
00078 minfunevals = dim[idx_dim] + 2;
00079 independent_restarts = -1;
00080 while (fgeneric_evaluations() + minfunevals <= maxfunevals)
00081 {
00082 if (++independent_restarts > 0)
00083 fgeneric_restart("independent restart");
00084 MY_OPTIMIZER(&fgeneric_evaluate, dim[idx_dim], fgeneric_ftarget(),
00085 maxfunevals - fgeneric_evaluations());
00086 if (fgeneric_best() < fgeneric_ftarget())
00087 break;
00088 }
00089
00090 printf(" f%d in %d-D, instance %d: FEs=%.0f with %d restarts,", ifun, dim[idx_dim],
00091 instances[idx_instances], fgeneric_evaluations(), independent_restarts);
00092 printf(" fbest-ftarget=%.4e, elapsed time [h]: %.2f\n",
00093 fgeneric_best() - fgeneric_ftarget(), (double)(clock()-t0)/CLOCKS_PER_SEC/60./60.);
00094
00095 fgeneric_finalize();
00096 }
00097 Tval = time(NULL);
00098 printf(" date and time: %s", ctime(&Tval));
00099 }
00100 printf("---- dimension %d-D done ----\n", dim[idx_dim]);
00101 }
00102 return 0;
00103 }