-int main(int argc, const char *const *argv) {
- gsl_multimin_function multimin_function;
- double size;
- Vertices initial, step_size;
- FILE *initial_f;
- gsl_vector initial_gsl, step_size_gsl;
- int r, v, vx,vy, k;
-
- if (argc>1) { fputs("takes no arguments\n",stderr); exit(8); }
-
- minimiser= gsl_multimin_fminimizer_alloc
- (gsl_multimin_fminimizer_nmsimplex, DIM);
- if (!minimiser) { perror("alloc minimiser"); exit(-1); }
-
- multimin_function.f= minfunc_f;
- multimin_function.n= DIM;
- multimin_function.params= 0;
-
- initial_f= fopen(INITIAL_F,"rb"); if (!initial_f) diee("fopen initial");
- errno= 0; r= fread(initial,sizeof(initial),1,initial_f);
- if (r!=1) diee("fread");
- fclose(initial_f);
-
- initial_gsl.size= DIM;
- initial_gsl.stride= 1;
- initial_gsl.block= 0;
- initial_gsl.owner= 0;
- step_size_gsl= initial_gsl;
-
- initial_gsl.data= (double*)initial;
- step_size_gsl.data= (double*)step_size;
-
- FOR_VERTEX(v)
- K step_size[v][k]= 1e-3;
- FOR_RIM_VERTEX(vx,vy,v)
- step_size[v][3] *= 0.1;
-
- r= gsl_multimin_fminimizer_set(minimiser, &multimin_function,
- &initial_gsl, &step_size_gsl);
- if (r) { gsldie("fminimizer_set",r); }
-
- for (;;) {
- r= gsl_multimin_fminimizer_iterate(minimiser);
- if (r) { gsldie("fminimizer_iterate",r); }
-
- size= gsl_multimin_fminimizer_size(minimiser);
- r= gsl_multimin_test_size(size, stop_epsilon);