This is George Bilchev's inductive search algorithm (in C++) that won the first place at the 1st International Contest on Evolutionary Computation on a real-valued function testsuite. It builds a population of points in dimensions i=1,2,...,n in turn by starting from a single point population created from the best point of the previous dimension a global one-dimensional search for the best new coordinate, and then growing the population through a sequence of local searches. ************************************************************************ *** The location of this file may change soon. *** Please refer at the moment to *** http://solon.cma.univie.ac.at/~neum/glopt/test_results.html#bilchev *** *** I'd appreciate if someone would remove the dependence of these *** programs on routines not in the public domain, and adds a driver *** routine that allows to optimize a function defined in a *** user-provided subroutine *** ************************************************************************ Dear Arnold, Please find below exactly the version of my algorithm for the EC contest, i.e. an algorithm that is specialized to the test bed of the contest. However, this is the same algorithm which I used for your problems (excluding the toy protein-folding, which required the multi- population generalization.) In order to be compiled the code requires the LEDA C++ library (public domain) and some routines from numerical recipes in C (see Makefile). Best wishes, George %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% *** brent's univariate minimizer is also available publicly in http://www.netlib.no/netlib/c/brent.shar http://www.netlib.no/netlib/c/serv.shar (needed for brent.shar) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% George Bilchev remarks elsewhere: >>you can use your favourite local search and 1-D global search (which I encourage you do since my choice could have been better). For more complex cost functions it is also better to maintain a population of "promising" points at each dimension (the algorithm only explains for one point).<< %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -------------------- Makefile: -------------------- all: gcc -c brent.c -ansi gcc -c nrutil.c -ansi g++ -o main main.cc nrutil.o brent.o -L/home/george/C++/LEDA-3.1c -I/home/george/C++/LEDA-3.1c/incl -lG -lL -lP -lm ------------------ main.cc ------------------ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "main.h" /* ** Include a test case here: ** */ #include "t1.c" float func(float y) /* ** ** Auxiliary 1-D function */ { iter_count++; x[DIM-1] = y; float res = f(x,DIM); return res; } float func_learning(float *y) /* ** ** Auxiliary DIM-dimensional function */ { iter_count++; float res = f(y,DIM); return res; } void oracle(int dim) /* ** ** One possible deterministic implementation ** of the non-deterministic ORACLE function */ { float r,bren,xmin; float ax = LOW; float cx = HIGH; float bx = (ax+cx)/2; DIM = dim; sortseq Population; seq_item S; Interval I; I.low = ax; I.high = cx; Population.insert(cx-ax,I); int STOP = 0; int count = 0; float FMIN = 1e30, XMIN; while (STOP == 0) { S = Population.max(); Population.del_item(S); I = Population.inf(S); ax = I.low; cx = I.high; bx = (ax+cx)/2; bren = brent(ax,bx,cx,func,TOL,&xmin); if (bren < FMIN) { FMIN = bren; XMIN = xmin; } if (bx < xmin) { I.low = ax; I.high = bx; Population.insert(I.high-I.low, I); I.low = bx; I.high = xmin; Population.insert(I.high- I.low, I); I.low = xmin; I.high = cx; Population.insert(I.high- I.low, I); } else { I.low = ax; I.high = xmin; Population.insert(I.high- I.low, I); I.low = xmin; I.high = bx; Population.insert(I.high- I.low, I); I.low = bx; I.high = cx; Population.insert(I.high-I.low, I); } count++; if (count > DELTA_N) break; } // Local learning x[DIM-1] = XMIN; if ( (LEARNING) && (DIM > 1) ) { local_learn(func_learning, x, DIM); } } main() { for(DELTA_N=STOP_CRIT; DELTA_N<=STOP_CRIT; DELTA_N++) { iter_count = 0; for (int i=0; i> I.low >> I.high; } void print(sortseq& S) { seq_item it; forall_items(it,S) cout << S.key(it) << " ==> " << S.inf(it).low << " " << S.inf(it).high << endl; newline; } --------------- rand.c ---------------- float frandom(float l, float h) { float eps = 0.0000001; Uniform rnd(l-eps, h+eps, &generator); return rnd(); } int irandom(int l, int h) { DiscreteUniform rnd(l, h, &generator); return (int)rnd(); } int irandom(int l, int h, int prev) { DiscreteUniform rnd(l, h, &generator); int rand = (int)rnd(); while ( rand == prev ) { rand = (int)rnd(); } return rand; } -------------------- t1.c -------------------- #define STOP_CRIT 0 #define LEARNING 0 #define LOW -5.0 #define HIGH 5.0 float f(float *x,int n) { register int i; float Sum; for (Sum = 0.0, i = 0; i < n; i++) { Sum += x[i]*x[i]; } return (Sum); } --------- t2.c --------- #define STOP_CRIT 0 #define LEARNING 0 #define LOW -600.0 #define HIGH 600.0 #define D 4000.0 float f(float *x,int n) { register int i; float Val1, Val2, Sum; for (Val1 = 0.0, Val2 = 1.0, i = 0; i < n; i++) { Val1 += x[i] * x[i]; Val2 *= cos(x[i] / sqrt((double) (i + 1)) ); } Sum = Val1 / D - Val2 + 1.0; return (Sum); } --------- t3.c --------- #include "shekel.h" #define STOP_CRIT 1 #define LEARNING 1 #define LOW 0.0 #define HIGH 10.0 float f(float *x,int n) { register i, j; float sp, h, result = 0.0; for (i = 0; i < 30; i++) { sp = 0.0; for (j = 0; j < n; j++) { h = x[j] - a[i][j]; sp += h * h; } result += 1.0 / (sp + c[i]); } return( - result); } --------- t4.c --------- #define STOP_CRIT 10 /* 3 if NDIM = 5 */ #define LEARNING 0 /* #define STOP_CRIT 10 if NDIM = 10 */ #define LOW 0.0 #define HIGH 3.14 #define m 10.0 float f(float *x,int n) /* Michalewitz */ { float PI=3.1415927; float u; int i; u=0; for (i=0;i #include #include #define THRESHOLD 1E-4 /* Minimum step size */ #define INIT_SIZE 1.0 /* Initial step size */ /* You should really look at my thesis to understand the following code. */ /* This comes from D. Yuret, From GA's to efficient optimization, MSC thesis MIT May 1994. */ void local_learn(float (*f)(float *x), float *x, int DIM) { float u[DIM], v[DIM], xv[DIM]; float fx,fxv; int vi,vvec; float vr; int i,iter,maxiter; for(i=0; i= THRESHOLD) { maxiter = ((fabs(vr) < 2*THRESHOLD) ? 2*DIM : 2); iter = 0; while((fxv >= fx) && (iter < maxiter)) { if(iter == 0) { for(i=0; i 0) vi = ((vi+1) % DIM); xv[vi] += vr; fxv = f(xv); iter++; } if(fxv >= fx) { fxv = 1E10; vr /= 2; } else { fx = fxv; /* printf("%d. %.7f <= ", iter_count, fx);*/ for(i=0; i= fx) { for(i=0; i