-static gsl_multimin_fminimizer *minimiser;
-
-static const double stop_epsilon= 1e-4;
-
-static double minfunc_f(const gsl_vector *x, void *params) {
- assert(x->size == DIM);
- assert(x->stride == 1);
- return compute_energy((const double(*)[D3])x->data);
-}
-
-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, k;
-
- if (argc!=3 || argv[1][0]=='-' || strncmp(argv[2],"-o",2))
- { fputs("usage: minimise <input> -o<output\n",stderr); exit(8); }
-
- input_file= argv[1];
- output_file= argv[2]+2;
- if (asprintf(&output_file_tmp,"%s.new",output_file) <= 0) diee("asprintf");
-
- 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(input_file,"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);